diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..13f88f7 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dictionaries/omarv.xml b/.idea/dictionaries/omarv.xml new file mode 100644 index 0000000..83f93a3 --- /dev/null +++ b/.idea/dictionaries/omarv.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e629cf4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c5f3f6b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive" +} \ No newline at end of file diff --git a/nbactions.xml b/nbactions.xml index 78a4e54..a2a7ddf 100644 --- a/nbactions.xml +++ b/nbactions.xml @@ -13,7 +13,7 @@ ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} - com.mycompany.schoolmarket.WinSchoolMarket + com.mycompany.schoolmarket.gui.WinSchoolMarket java @@ -30,7 +30,7 @@ -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} - com.mycompany.schoolmarket.WinSchoolMarket + com.mycompany.schoolmarket.gui.WinSchoolMarket java true @@ -47,7 +47,7 @@ ${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs} - com.mycompany.schoolmarket.WinSchoolMarket + com.mycompany.schoolmarket.gui.WinSchoolMarket java diff --git a/pom.xml b/pom.xml index 17eadcf..b6e724d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,25 +1,51 @@ - + 4.0.0 com.mycompany schoolMarket 1.0-SNAPSHOT jar + - mysql - mysql-connector-java - 8.0.30 + com.mysql + mysql-connector-j + 8.4.0 org.mongodb mongodb-driver-sync 4.2.2 + + org.hibernate.orm + hibernate-core + 6.5.0.CR1 + + + + org.mariadb.jdbc + mariadb-java-client + 3.3.3 + + + + org.hibernate.validator + hibernate-validator + 8.0.1.Final + + + + + org.glassfish.expressly + expressly + 5.0.0 + UTF-8 - 21 - 21 + 22 + 22 com.mycompany.schoolmarket.SchoolMarket \ No newline at end of file diff --git a/src/main/java/com/mycompany/schoolmarket/Book.java b/src/main/java/com/mycompany/schoolmarket/Book.java deleted file mode 100644 index 6446934..0000000 --- a/src/main/java/com/mycompany/schoolmarket/Book.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template - */ -package com.mycompany.schoolmarket; - -/** - * - * @author utentepc - */ -class Book { - - private String bookName; - private int classBefore; - private int cost; - private String bookHealth; - - public Book(String bookName, int classBefore, int cost, String bookHealth) { - this.bookName = bookName; - this.classBefore = classBefore; - this.cost = cost; - this.bookHealth = bookHealth; - } - - public String getBookName() { - return bookName; - } - - public String getBookHealth() { - return bookHealth; - } - - public void setBookName(String bookName) { - this.bookName = bookName; - } - - public void setBookHealth(String bookHealth) { - this.bookHealth = bookHealth; - } - - public int getClassBefore() { - return classBefore; - } - - public void setClassBefore(int classBefore) { - this.classBefore = classBefore; - } - - public int getCost() { - return cost; - } - - public void setCost(int cost) { - this.cost = cost; - } - - - @Override - public String toString() { - return "\nbookName = " + bookName + "\nclassBefore = " + classBefore + "\ncost = " + cost + "\nbookHealth = " + bookHealth; - } - -} diff --git a/src/main/java/com/mycompany/schoolmarket/Student.java b/src/main/java/com/mycompany/schoolmarket/Student.java deleted file mode 100644 index e554fdf..0000000 --- a/src/main/java/com/mycompany/schoolmarket/Student.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template - */ -package com.mycompany.schoolmarket; - -/** - * - * @author utentepc - */ -public class Student { - - private String firstName; - private String lastName; - private int age; - private int classSection; - private String email; - - public Student(String firstName, String lastName, int age, int classSection, String email) { - this.firstName = firstName; - this.lastName = lastName; - this.age = age; - this.classSection = classSection; - this.email = email; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public String getLastName() { - return lastName; - } - - public int getAge() { - return age; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public void setAge(int age) { - this.age = age; - } - - public void setClassSection(int classSection) { - this.classSection = classSection; - } - - public int getClassSection() { - return classSection; - } - - - - - - @Override - public String toString() { - return "\n" +" firstName=" + firstName + "\n lastName=" + lastName + "\n age=" + age + "\n class section=" + classSection + "\n email="+email; - } - - - -} diff --git a/src/main/java/com/mycompany/schoolmarket/WinSchoolMarket.java b/src/main/java/com/mycompany/schoolmarket/WinSchoolMarket.java deleted file mode 100644 index 71e6db4..0000000 --- a/src/main/java/com/mycompany/schoolmarket/WinSchoolMarket.java +++ /dev/null @@ -1,800 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template - */ -package com.mycompany.schoolmarket; - -import com.mysql.cj.jdbc.Driver; -import com.mysql.cj.jdbc.PreparedStatementWrapper; -import com.mysql.cj.xdevapi.Result; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.ArrayList; -import javax.swing.DefaultListModel; -import javax.swing.table.DefaultTableModel; - -/** - * - * @author utentepc - */ -public class WinSchoolMarket extends javax.swing.JFrame { - - - static final String DB_URL = "jdbc:mysql://127.0.0.1:3306/school_market"; - static final String USER = "root"; - static final String PASS = "root"; - Connection conn; - - ArrayList listIdStudents = new ArrayList<>(); - ArrayList listIdClasses = new ArrayList<>(); - ArrayList listIdBooks = new ArrayList<>(); - ArrayList listIdSubjects = new ArrayList<>(); - - /** - * Creates new form WinSchoolMarket - */ - public WinSchoolMarket() { - initComponents(); - refreshListClass(); - refreshListClassBooks(); - refreshListStudents(); - refreshTableBooks(); - refreshListSubjects(); - } - - /** - * 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. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jLabel1 = new javax.swing.JLabel(); - jScrollPane2 = new javax.swing.JScrollPane(); - tb_booksList = new javax.swing.JTable(); - jLabel2 = new javax.swing.JLabel(); - jLabel3 = new javax.swing.JLabel(); - jLabel4 = new javax.swing.JLabel(); - jLabel5 = new javax.swing.JLabel(); - jLabel6 = new javax.swing.JLabel(); - jLabel7 = new javax.swing.JLabel(); - tx_firstName = new javax.swing.JTextField(); - tx_lastName = new javax.swing.JTextField(); - tx_age = new javax.swing.JTextField(); - btInsertStudentSubscription = new javax.swing.JButton(); - jLabel8 = new javax.swing.JLabel(); - jLabel9 = new javax.swing.JLabel(); - jLabel10 = new javax.swing.JLabel(); - jLabel11 = new javax.swing.JLabel(); - tx_bookName = new javax.swing.JTextField(); - sp_bookCost = new javax.swing.JSpinner(); - lb_logMessage = new javax.swing.JLabel(); - jScrollPane3 = new javax.swing.JScrollPane(); - tp_showStudent = new javax.swing.JTextPane(); - btInsertBook = new javax.swing.JButton(); - jLabel12 = new javax.swing.JLabel(); - tx_email = new javax.swing.JTextField(); - jScrollPane4 = new javax.swing.JScrollPane(); - lst_studentsList = new javax.swing.JList<>(); - jLabel13 = new javax.swing.JLabel(); - tx_bookHealth = new javax.swing.JTextField(); - jLabel14 = new javax.swing.JLabel(); - jScrollPane1 = new javax.swing.JScrollPane(); - lst_classesList = new javax.swing.JList<>(); - jScrollPane5 = new javax.swing.JScrollPane(); - lst_classesBook = new javax.swing.JList<>(); - jLabel15 = new javax.swing.JLabel(); - jLabel16 = new javax.swing.JLabel(); - jLabel17 = new javax.swing.JLabel(); - jLabel18 = new javax.swing.JLabel(); - jSeparator1 = new javax.swing.JSeparator(); - jLabel19 = new javax.swing.JLabel(); - jLabel20 = new javax.swing.JLabel(); - jLabel21 = new javax.swing.JLabel(); - jScrollPane6 = new javax.swing.JScrollPane(); - lst_subjects = new javax.swing.JList<>(); - jLabel22 = new javax.swing.JLabel(); - jLabel23 = new javax.swing.JLabel(); - jLabel24 = new javax.swing.JLabel(); - jLabel25 = new javax.swing.JLabel(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - - jLabel1.setText("SCHOOL MARKET"); - - tb_booksList.setModel(new javax.swing.table.DefaultTableModel( - new Object [][] { - - }, - new String [] { - "nome", "classe", "costo", "grado", "quantity" - } - ) { - boolean[] canEdit = new boolean [] { - false, false, false, false, false - }; - - public boolean isCellEditable(int rowIndex, int columnIndex) { - return canEdit [columnIndex]; - } - }); - jScrollPane2.setViewportView(tb_booksList); - - jLabel2.setText("Inserisci i tuoi dati nelle caselle sottostanti per registrarti nel e-commerce!"); - - jLabel3.setText("INSERIRE I DATI DEL NUOVO STUDENTE :"); - - jLabel4.setText("Nome : "); - - jLabel5.setText("Cognome :"); - - jLabel6.setText("Età : "); - - jLabel7.setText("Sezione classe :"); - - tx_firstName.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - tx_firstNameActionPerformed(evt); - } - }); - - btInsertStudentSubscription.setText("OKAY"); - btInsertStudentSubscription.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btInsertStudentSubscriptionActionPerformed(evt); - } - }); - - jLabel8.setText("INSERIRE I DATI DEL NUOVO LIBRO:"); - - jLabel9.setText("Nome libro :"); - - jLabel10.setText("Costo :"); - - jLabel11.setText("Classe :"); - - tx_bookName.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - tx_bookNameActionPerformed(evt); - } - }); - - lb_logMessage.setText("nessun dato ancora fornito..."); - - jScrollPane3.setViewportView(tp_showStudent); - - btInsertBook.setText("OKAY"); - btInsertBook.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btInsertBookActionPerformed(evt); - } - }); - - jLabel12.setText("E-mail : "); - - lst_studentsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - lst_studentsList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { - public void valueChanged(javax.swing.event.ListSelectionEvent evt) { - lst_studentsListValueChanged(evt); - } - }); - jScrollPane4.setViewportView(lst_studentsList); - - jLabel13.setText("Stato dell'oggetto :"); - - jLabel14.setText("(es. Grado A, B o C)"); - - lst_classesList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - lst_classesList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { - public void valueChanged(javax.swing.event.ListSelectionEvent evt) { - lst_classesListValueChanged(evt); - } - }); - jScrollPane1.setViewportView(lst_classesList); - - lst_classesBook.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - lst_classesBook.addListSelectionListener(new javax.swing.event.ListSelectionListener() { - public void valueChanged(javax.swing.event.ListSelectionEvent evt) { - lst_classesBookValueChanged(evt); - } - }); - jScrollPane5.setViewportView(lst_classesBook); - - jLabel15.setText("LISTA LIBRI"); - - jLabel16.setText("Sei nuovo? "); - - jLabel17.setText("Premi il pulsante \"OKAY\" "); - - jLabel18.setText("per aggiungere il libro."); - - jLabel19.setText("Vuoi vendere un libro?"); - - jLabel20.setText("Compila i dati sottostanti per aggiungerlo nel catalogo!"); - - jLabel21.setText("Materia :"); - - lst_subjects.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - lst_subjects.addListSelectionListener(new javax.swing.event.ListSelectionListener() { - public void valueChanged(javax.swing.event.ListSelectionEvent evt) { - lst_subjectsValueChanged(evt); - } - }); - jScrollPane6.setViewportView(lst_subjects); - - jLabel22.setText("Premi \"OKAY\" per completare"); - - jLabel23.setText("la registrazione"); - - jLabel24.setText("SELEZIONARE ACCOUNT ESISTENTE : "); - - jLabel25.setText("Se invece ti sei già registrato/a puoi scegliere tra gli utenti esistenti : "); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel19) - .addComponent(jLabel20)) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel3) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING)) - .addGap(21, 21, 21)) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel12) - .addGap(33, 33, 33))) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addComponent(tx_firstName) - .addComponent(tx_lastName, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE) - .addComponent(tx_age)) - .addGap(23, 23, 23) - .addComponent(jLabel7) - .addGap(18, 18, 18) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addComponent(tx_email, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel22) - .addComponent(btInsertStudentSubscription) - .addComponent(jLabel23))))) - .addGroup(layout.createSequentialGroup() - .addGap(8, 8, 8) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(layout.createSequentialGroup() - .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(jLabel9) - .addComponent(tx_bookName)) - .addGap(24, 24, 24)) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel21) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel10) - .addComponent(sp_bookCost, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel13) - .addComponent(tx_bookHealth, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(jLabel17) - .addComponent(jLabel18) - .addComponent(btInsertBook))) - .addComponent(jLabel8)) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGap(107, 107, 107) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane2) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, Short.MAX_VALUE)))) - .addGroup(layout.createSequentialGroup() - .addGap(101, 101, 101) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel24, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel25) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(jScrollPane4) - .addGap(18, 18, 18) - .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addGap(6, 6, 6) - .addComponent(lb_logMessage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))))) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGap(414, 414, 414) - .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel16)) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 458, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGap(0, 0, Short.MAX_VALUE)) - .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1037, Short.MAX_VALUE)) - .addContainerGap()) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(3, 3, 3) - .addComponent(jLabel16) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel2) - .addComponent(jLabel25)) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel3) - .addComponent(jLabel24)) - .addGap(27, 27, 27) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jScrollPane3) - .addComponent(jScrollPane4) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(tx_lastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(tx_firstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(tx_age, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(tx_email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel22) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel23))))) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGap(69, 69, 69) - .addComponent(jLabel19) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel20) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGap(23, 23, 23) - .addComponent(jLabel15) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addGap(17, 17, 17) - .addComponent(jLabel8) - .addGap(10, 10, 10) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel9) - .addComponent(jLabel10)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(sp_bookCost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(tx_bookName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(12, 12, 12) - .addComponent(jLabel13) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel14) - .addComponent(jLabel11) - .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(tx_bookHealth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(jLabel17) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jLabel18) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(btInsertBook, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, Short.MAX_VALUE)) - .addComponent(jScrollPane6) - .addComponent(jScrollPane5)))) - .addGap(29, 29, 29)) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(lb_logMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(btInsertStudentSubscription)) - .addGap(26, 26, 26) - .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) - ); - - pack(); - }// //GEN-END:initComponents - - private void tx_firstNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tx_firstNameActionPerformed - // TODO add your handling code here: - }//GEN-LAST:event_tx_firstNameActionPerformed - - private void btInsertStudentSubscriptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInsertStudentSubscriptionActionPerformed - // TODO add your handling code here: - - String newStudent = "Le credenziali del nuovo studente sono: \n"; - String firstName = tx_firstName.getText(); - String lastName = tx_lastName.getText(); - String email = tx_email.getText(); - int idc = listIdClasses.get(lst_classesList.getSelectedIndex()); - int age = Integer.parseInt(tx_age.getText()); - - Student st = new Student(firstName, lastName, age, idc, email); - - newStudent += st.toString(); - System.out.println(newStudent); - newStudent = tp_showStudent.getText()+ "\n" + newStudent; - tp_showStudent.setText(newStudent); - - tx_firstName.setText(""); - tx_lastName.setText(""); - tx_age.setText(""); - tx_email.setText(""); - - - lb_logMessage.setText("Studente aggiunto con successo!"); - - try { - conn = DriverManager.getConnection(DB_URL, USER, PASS); - PreparedStatement stmt = conn.prepareStatement("INSERT INTO t_students(id_class, firstname, lastname, age, email)" - + "values (?,?,?,?,?)"); - stmt.setInt(1, idc); - stmt.setString(2, firstName); - stmt.setString(3, lastName); - stmt.setInt(4, age); - stmt.setString(5, email); - int rows = stmt.executeUpdate(); - System.out.println("Rows impacted: "+rows); - refreshListStudents(); - ResultSet rs = stmt.executeQuery("select * from t_students order by id_student desc"); - while (rs.next()){ - System.out.println("ID: "+rs.getInt("id_student")); - System.out.println("Firstname: "+ rs.getString("firstname")); - System.out.println("Lastname: "+rs.getString("lastname")); - } - - } catch (Exception e) { - System.out.println(e.getMessage()); - } - - }//GEN-LAST:event_btInsertStudentSubscriptionActionPerformed - - private void lst_studentsListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lst_studentsListValueChanged - // TODO add your handling code here: - int index = lst_studentsList.getSelectedIndex(); - String name = lst_studentsList.getSelectedValue(); - int classSection = listIdClasses.get(index); - lb_logMessage.setText(" STUDENT_NAME: "+ name); - }//GEN-LAST:event_lst_studentsListValueChanged - - private void btInsertBookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInsertBookActionPerformed - // TODO add your handling code here: - String newBook = "\nDati del nuovo libro inserito: "; - String bookName = tx_bookName.getText(); - int classBefore = listIdClasses.get(lst_classesBook.getSelectedIndex()); - int cost = (Integer) sp_bookCost.getValue(); - String bookHealth = tx_bookHealth.getText(); - int ids = listIdStudents.get(lst_studentsList.getSelectedIndex()); - int idsu = listIdSubjects.get(lst_subjects.getSelectedIndex()); - Book bk = new Book(bookName, classBefore, cost, bookHealth); - - newBook+= bk.toString(); - System.out.println(newBook); - newBook = tp_showStudent.getText()+ "\n" + newBook; - tp_showStudent.setText(newBook); - - lb_logMessage.setText("Nuovo libro aggiunto con successo!"); - - try { - - conn = DriverManager.getConnection(DB_URL, USER, PASS); - PreparedStatement stmt = conn.prepareStatement("INSERT INTO t_books(id_student, book_name, id_class, cost, grade, id_subject)" - + "values (?,?,?,?,?,?)"); - stmt.setInt(1, ids); - stmt.setString(2, bookName); - stmt.setInt(3, classBefore); - stmt.setInt(4, cost); - stmt.setString(5, bookHealth); - stmt.setInt(6, idsu); - - - int rows = stmt.executeUpdate(); - System.out.println("Rows impacted: " + rows); - - refreshTableBooks(); - ResultSet rs = stmt.executeQuery("select tb.id_book, tb.book_name, tb.cost, tb.grade, tc.section from t_books tb join t_classes tc on tc.id_class = tb.id_class order by id_book desc "); - while (rs.next()){ - System.out.println("ID: "+rs.getInt("tb.id_book")); - System.out.println("BOOK_NAME: " + rs.getString("tb.book_name")); - System.out.println("SECTION: " + rs.getString("tc.section")); - System.out.println("COST: " + rs.getInt("tb.cost")); - System.out.println("GRADE: " + rs.getString("tb.grade")); - } - - } catch (Exception e) { - System.out.println(e.getMessage()); - } - - - }//GEN-LAST:event_btInsertBookActionPerformed - - private void lst_classesListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lst_classesListValueChanged - // TODO add your handling code here: - int index = lst_classesList.getSelectedIndex(); - String section = lst_classesList.getSelectedValue(); - int classId = listIdClasses.get(index); - lb_logMessage.setText("CLASS_ID: "+ classId+" SECTION: "+ section); - }//GEN-LAST:event_lst_classesListValueChanged - - private void tx_bookNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tx_bookNameActionPerformed - // TODO add your handling code here: - }//GEN-LAST:event_tx_bookNameActionPerformed - - private void lst_classesBookValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lst_classesBookValueChanged - // TODO add your handling code here: - int index = lst_classesBook.getSelectedIndex(); - String section = lst_classesBook.getSelectedValue(); - int classId = listIdClasses.get(index); - lb_logMessage.setText("CLASS_ID: "+ classId+" SECTION: "+ section); - }//GEN-LAST:event_lst_classesBookValueChanged - - private void lst_subjectsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lst_subjectsValueChanged - // TODO add your handling code here: - int index = lst_subjects.getSelectedIndex(); - String subject = lst_subjects.getSelectedValue(); - int classId = listIdSubjects.get(index); - lb_logMessage.setText("SUBJECT: "+ subject); - - }//GEN-LAST:event_lst_subjectsValueChanged - - public void refreshListClass () { - try { - conn = DriverManager.getConnection(DB_URL, USER, PASS); - PreparedStatement stmt = conn.prepareStatement("SELECT id_class, section FROM t_classes ORDER BY section"); - ResultSet rs = stmt.executeQuery(); - DefaultListModel model = new DefaultListModel(); - listIdClasses.clear(); - - while (rs.next()) { - model.addElement(rs.getString("section")); - listIdClasses.add(rs.getInt("id_class")); - } - lst_classesList.setModel(model); - - } catch (Exception e) { - System.out.println(e.getMessage()); - } - } - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(WinSchoolMarket.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(WinSchoolMarket.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(WinSchoolMarket.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(WinSchoolMarket.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the form */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - new WinSchoolMarket().setVisible(true); - } - }); - } - - public void refreshListStudents () { - try { - conn = DriverManager.getConnection(DB_URL, USER, PASS); - PreparedStatement stmt = conn.prepareStatement("SELECT ts.id_student, concat(ts.lastname, \" \", ts.firstname, \" - \", tc.section) as nominatives FROM t_students ts join t_classes tc on tc.id_class = ts.id_class ORDER BY nominatives"); - ResultSet rs = stmt.executeQuery(); - DefaultListModel model = new DefaultListModel(); - listIdStudents.clear(); - - while (rs.next()) { - model.addElement(rs.getString("nominatives" )); - listIdStudents.add(rs.getInt("id_student")); - //model.addElement(rs.getString("tc.section")); - } - lst_studentsList.setModel(model); - - } catch (Exception e) { - System.out.println(e.getMessage()); - } - } - - private void refreshListClassBooks() { - try { - conn = DriverManager.getConnection(DB_URL, USER, PASS); - PreparedStatement stmt = conn.prepareStatement("SELECT id_class, section FROM t_classes ORDER BY section"); - ResultSet rs = stmt.executeQuery(); - DefaultListModel model = new DefaultListModel(); - listIdClasses.clear(); - - while (rs.next()) { - model.addElement(rs.getString("section")); - listIdClasses.add(rs.getInt("id_class")); - } - lst_classesBook.setModel(model); - - } catch (Exception e) { - System.out.println(e.getMessage()); - } - } - - private void refreshTableBooks() { - try { - conn = DriverManager.getConnection(DB_URL, USER, PASS); - PreparedStatement stmt = conn.prepareStatement("SELECT tb.book_name, tc.section, tb.cost, tb.grade, count(tb.id_subject) as quantity " + - "FROM t_books as tb " + - "join t_subjects tsu on tsu.id_subjects = tb.id_subject " + - "join t_classes tc on tc.id_class = tb.id_class " + - "group by tb.id_subject, tb.grade, tb.id_class, tc.section, tb.book_name, tb.cost " + - "order by tc.section"); - ResultSet rs = stmt.executeQuery(); - DefaultTableModel model = (DefaultTableModel) tb_booksList.getModel(); - - DefaultTableModel dm = (DefaultTableModel)tb_booksList.getModel(); - - while(dm.getRowCount() > 0) - { - dm.removeRow(0); - } - - while (rs.next()) { - String tb = rs.getString("tb.book_name"); - String cl = rs.getString("tc.section"); - String gr = rs.getString("tb.grade"); - int co = rs.getInt("tb.cost"); - int qua = rs.getInt("quantity"); - Object[] obj = new Object[]{ - tb,cl,co,gr,qua - }; - model.addRow(obj); - - } - tb_booksList.setModel(model); - } catch (Exception e) { - System.out.println(e.getMessage()); - } - - } - - private void refreshListSubjects() { - try { - conn = DriverManager.getConnection(DB_URL, USER, PASS); - PreparedStatement stmt = conn.prepareStatement("SELECT id_subjects, subject_name FROM t_subjects ORDER BY id_subjects"); - ResultSet rs = stmt.executeQuery(); - DefaultListModel model = new DefaultListModel(); - listIdSubjects.clear(); - - while (rs.next()) { - model.addElement(rs.getString("subject_name")); - listIdSubjects.add(rs.getInt("id_subjects")); - } - lst_subjects.setModel(model); - - } catch (Exception e) { - System.out.println(e.getMessage()); - } - } - - - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton btInsertBook; - private javax.swing.JButton btInsertStudentSubscription; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel10; - private javax.swing.JLabel jLabel11; - private javax.swing.JLabel jLabel12; - private javax.swing.JLabel jLabel13; - private javax.swing.JLabel jLabel14; - private javax.swing.JLabel jLabel15; - private javax.swing.JLabel jLabel16; - private javax.swing.JLabel jLabel17; - private javax.swing.JLabel jLabel18; - private javax.swing.JLabel jLabel19; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel20; - private javax.swing.JLabel jLabel21; - private javax.swing.JLabel jLabel22; - private javax.swing.JLabel jLabel23; - private javax.swing.JLabel jLabel24; - private javax.swing.JLabel jLabel25; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JLabel jLabel6; - private javax.swing.JLabel jLabel7; - private javax.swing.JLabel jLabel8; - private javax.swing.JLabel jLabel9; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JScrollPane jScrollPane2; - private javax.swing.JScrollPane jScrollPane3; - private javax.swing.JScrollPane jScrollPane4; - private javax.swing.JScrollPane jScrollPane5; - private javax.swing.JScrollPane jScrollPane6; - private javax.swing.JSeparator jSeparator1; - private javax.swing.JLabel lb_logMessage; - private javax.swing.JList lst_classesBook; - private javax.swing.JList lst_classesList; - private javax.swing.JList lst_studentsList; - private javax.swing.JList lst_subjects; - private javax.swing.JSpinner sp_bookCost; - private javax.swing.JTable tb_booksList; - private javax.swing.JTextPane tp_showStudent; - private javax.swing.JTextField tx_age; - private javax.swing.JTextField tx_bookHealth; - private javax.swing.JTextField tx_bookName; - private javax.swing.JTextField tx_email; - private javax.swing.JTextField tx_firstName; - private javax.swing.JTextField tx_lastName; - // End of variables declaration//GEN-END:variables - - - - - -} diff --git a/src/main/java/com/mycompany/schoolmarket/boundary/RegistrationException.java b/src/main/java/com/mycompany/schoolmarket/boundary/RegistrationException.java new file mode 100644 index 0000000..e9735f3 --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/boundary/RegistrationException.java @@ -0,0 +1,8 @@ +package com.mycompany.schoolmarket.boundary; + +public class RegistrationException extends RuntimeException{ + + public RegistrationException (String msg){ + super(msg); + } +} diff --git a/src/main/java/com/mycompany/schoolmarket/boundary/SchoolMarket.java b/src/main/java/com/mycompany/schoolmarket/boundary/SchoolMarket.java new file mode 100644 index 0000000..c40af1b --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/boundary/SchoolMarket.java @@ -0,0 +1,97 @@ +package com.mycompany.schoolmarket.boundary; + +import java.math.BigDecimal; +import java.util.List; +import com.mycompany.schoolmarket.control.Store; +import com.mycompany.schoolmarket.entity.Book; +import com.mycompany.schoolmarket.entity.BookCondition; +import com.mycompany.schoolmarket.entity.StudentClass; +import com.mycompany.schoolmarket.entity.Student; +import com.mycompany.schoolmarket.entity.Subject; + +public class SchoolMarket { + + public static Student studentRegistration(String fname, String lname, int age, String email, String tel, + StudentClass classSection) { + + try { + Store.openConnection(); + // New Student's class instance + Student st = new Student(fname, lname, age, email, classSection, tel); + Student saveStudent = Store.saveStudent(st); + Store.closeConnection(); + return saveStudent; + } catch (Exception e) { + Store.rollConnection(); + throw new RegistrationException("Account registration failed!"); + } + } + + public static void studentRegistration(String fname, String lname, int age, String email, + StudentClass classSection) { + studentRegistration(fname, lname, age, email, null, classSection); + } + + public static Book bookVending(String bookName, BigDecimal cost, BookCondition grade, Student student, + StudentClass classSection, Subject subject) { + + try { + + Store.openConnection(); + + // New Book's class instance + + Book bk = new Book(bookName, cost, grade, student, classSection, subject); + + Book saveBook = Store.saveBook(bk); + + Store.closeConnection(); + return saveBook; + } catch (Exception e) { + Store.rollConnection(); + throw new RegistrationException("Book registration failed!"); + } + } + + // Methods used on WinSchoolMarket + + // Returnes all classes + public static List classesList() { + return Store.findAllClasses(); + } + + // Returnes all students + public static List studentsList() { + return Store.allStudentsList(); + } + + // Returnes all subjects + public static List subjectList() { + return Store.allSubjectList(); + } + + // Returns the Book's health-grade based on given data + public static BookCondition getBookCondition(String grade) { + return Store.getBookConditionIndex(grade); + } + + // Returns all books based on student id + public static List booksByUser(int idStudent) { + return Store.findBooksByStudentId(idStudent); + } + + // Returns student based on selected student id + public static Student getStudent(long idStudent) { + return Store.getStudentIndex(idStudent); + } + + // Returns class section of the book based on class id + public static StudentClass getClass(int idClass) { + return Store.getClassIndex(idClass); + } + + // Returns book's subject based on subject id + public static Subject getSubject(int idSubject) { + return Store.getSubjectIndex(idSubject); + } +} diff --git a/src/main/java/com/mycompany/schoolmarket/boundary/SearchException.java b/src/main/java/com/mycompany/schoolmarket/boundary/SearchException.java new file mode 100644 index 0000000..5f688a7 --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/boundary/SearchException.java @@ -0,0 +1,8 @@ +package com.mycompany.schoolmarket.boundary; + +public class SearchException extends RuntimeException { + + public SearchException(String msg){ + super(msg); + } +} diff --git a/src/main/java/com/mycompany/schoolmarket/control/Store.java b/src/main/java/com/mycompany/schoolmarket/control/Store.java new file mode 100644 index 0000000..76b0051 --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/control/Store.java @@ -0,0 +1,128 @@ +package com.mycompany.schoolmarket.control; + +import java.util.List; +import com.mycompany.schoolmarket.entity.Book; +import com.mycompany.schoolmarket.entity.BookCondition; +import com.mycompany.schoolmarket.entity.Student; +import com.mycompany.schoolmarket.entity.StudentClass; +import com.mycompany.schoolmarket.entity.Subject; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; +import jakarta.persistence.TypedQuery; + +public class Store { + + private static EntityManagerFactory emf = Persistence.createEntityManagerFactory("schoolMarket"); + private static EntityManager em = emf.createEntityManager(); + + { + + } + + // New database connection opened + public static void openConnection() { + if (em.getTransaction().isActive()) { + throw new StoreException("Connection is already open!"); + } + em.getTransaction().begin(); + + } + + // Close connection to database + public static void closeConnection() { + if (!em.getTransaction().isActive()) { + throw new StoreException("Connection is not already active!"); + } + em.getTransaction().commit(); + + } + + // Roll back connection if something went wrong during the process of + // registration + public static void rollConnection() { + if (!em.getTransaction().isActive()) { + throw new StoreException("Connection is not already active!"); + } + em.getTransaction().rollback(); + + } + + // Save the student on database using entity Student.class + public static Student saveStudent(Student e) { + if (em.getTransaction().isActive()) { + return em.merge(e); + } + em.getTransaction().begin(); + Student saved = em.merge(e); + em.getTransaction().commit(); + return saved; + } + + // Save the book on database using entity Book.class + public static Book saveBook(Book b) { + + if (em.getTransaction().isActive()) { + return em.merge(b); + } + em.getTransaction().begin(); + Book saved = em.merge(b); + em.getTransaction().commit(); + return saved; + } + + public static StudentClass getClassIndex(int idClass) { + TypedQuery query = em + .createNamedQuery(StudentClass.FIND_BY_CLASS_ID, StudentClass.class); + StudentClass cl = query + .setParameter("id", idClass).getSingleResult(); + return cl; + } + + public static BookCondition getBookConditionIndex(String idBookCondition) { + TypedQuery query = em + .createNamedQuery(BookCondition.FIND_BY_CONDITION_ID, BookCondition.class); + BookCondition bc = query + .setParameter("grade", idBookCondition).getSingleResult(); + return bc; + } + + public static Student getStudentIndex(long idStudent) { + TypedQuery query = em + .createNamedQuery(Student.FIND_BY_STUDENT_ID, Student.class); + Student st = query + .setParameter("id", idStudent).getSingleResult(); + return st; + } + + public static Subject getSubjectIndex(long idSubject) { + TypedQuery query = em + .createNamedQuery(Subject.FIND_BY_SUBJECT_ID, Subject.class); + Subject sb = query + .setParameter("id", idSubject).getSingleResult(); + return sb; + } + + public static List findBooksByStudentId(int idStudent) { + return em.createNamedQuery(Book.FIND_BY_STUDENT_ID, Book.class) + .setParameter("id", idStudent) + .getResultList(); + + } + + public static List findAllClasses() { + return em.createQuery("select e from StudentClass e order by e.section", StudentClass.class) + .getResultList(); + } + + public static List allStudentsList() { + return em.createQuery("SELECT e FROM Student e", Student.class) + .getResultList(); + } + + public static List allSubjectList() { + return em.createQuery("SELECT e FROM Subject e", Subject.class) + .getResultList(); + } +} diff --git a/src/main/java/com/mycompany/schoolmarket/control/StoreException.java b/src/main/java/com/mycompany/schoolmarket/control/StoreException.java new file mode 100644 index 0000000..51b0d70 --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/control/StoreException.java @@ -0,0 +1,8 @@ +package com.mycompany.schoolmarket.control; + +public class StoreException extends RuntimeException { + + public StoreException(String msg){ + super(msg); + } +} diff --git a/src/main/java/com/mycompany/schoolmarket/entity/Book.java b/src/main/java/com/mycompany/schoolmarket/entity/Book.java new file mode 100644 index 0000000..5d1a082 --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/entity/Book.java @@ -0,0 +1,158 @@ +package com.mycompany.schoolmarket.entity; + +import java.math.BigDecimal; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.Table; +import jakarta.validation.constraints.PositiveOrZero; + +@NamedQueries({ + @NamedQuery(name = Book.FIND_BY_STUDENT_ID, query = "SELECT e FROM Book e WHERE e.student.idStudent = :id") +}) + +@Entity +@Table(name = "t_books") +public class Book { + + public static final String FIND_BY_STUDENT_ID = "Book.findByStudentId"; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id_book") + private int idBook; + + @Column(name = "book_name", nullable = false) + private String bookName; + + + @PositiveOrZero(message = "The credit should be more or equals to 0.") + @Column(name = "cost", nullable = false, precision = 8, scale = 2) + private BigDecimal cost; + + @ManyToOne(optional = false) + @JoinColumn(name = "grade", nullable = false) + private BookCondition grade; + + @ManyToOne(optional = false) + @JoinColumn(name = "id_student") + private Student student; + + + @ManyToOne(optional = false) + @JoinColumn(name = "id_class") + private StudentClass classSection; + + + @ManyToOne(optional = false) + @JoinColumn(name = "id_subject") + private Subject subject; + + public Book (){ + + } + + public Book(String bookName, + @PositiveOrZero(message = "The credit should be more or equals to 0.") BigDecimal cost, BookCondition grade, + Student idStudent, StudentClass classSection, Subject subject) { + this.bookName = bookName; + this.cost = cost; + this.grade = grade; + this.student = idStudent; + this.classSection = classSection; + this.subject = subject; + } + + + + public int getIdBook() { + return idBook; + } + + public void setIdBook(int idBook) { + this.idBook = idBook; + } + + public String getBookName() { + return bookName; + } + + public void setBookName(String bookName) { + this.bookName = bookName; + } + + public BigDecimal getCost() { + return cost; + } + + public void setCost(BigDecimal cost) { + this.cost = cost; + } + + public BookCondition getGrade() { + return grade; + } + + public void setGrade(BookCondition grade) { + this.grade = grade; + } + + public Student getStudent() { + return student; + } + + public void setStudent(Student student) { + this.student = student; + } + + public StudentClass getClassSection() { + return classSection; + } + + public void setClassSection(StudentClass classSection) { + this.classSection = classSection; + } + + public Subject getSubject() { + return subject; + } + + public void setSubject(Subject subject) { + this.subject = subject; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (idBook ^ (idBook >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Book other = (Book) obj; + if (idBook != other.idBook) + return false; + return true; + } + + @Override + public String toString() { + return "\nBook [idBook=" + idBook + ", bookName=" + bookName + ", cost=" + cost + ", grade=" + grade + + ", student=" + student + ", classSection=" + classSection + ", subject=" + subject + "]"; + } +} diff --git a/src/main/java/com/mycompany/schoolmarket/entity/BookCondition.java b/src/main/java/com/mycompany/schoolmarket/entity/BookCondition.java new file mode 100644 index 0000000..571af8b --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/entity/BookCondition.java @@ -0,0 +1,84 @@ +package com.mycompany.schoolmarket.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.Table; +import jakarta.validation.constraints.Size; + +@NamedQueries({ + @NamedQuery(name = BookCondition.FIND_BY_CONDITION_ID, query = "SELECT e FROM BookCondition e WHERE e.grade = :grade") +}) +@Entity +@Table(name = "t_conditions") +public class BookCondition { + + public static final String FIND_BY_CONDITION_ID = "BookCondition.findByClassId"; + + + @Id + @Size(max = 1) + @Column(name = "grade") + private String grade; + + @Size(max = 1000) + @Column(name = "", nullable = true) + private String description; + + public BookCondition() { + } + + public BookCondition(@Size(max = 1) String grade, @Size(max = 1000) String description) { + this.grade = grade; + this.description = description; + } + + public String getGrade() { + return grade; + } + + public void setGrade(String grade) { + this.grade = grade; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((grade == null) ? 0 : grade.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BookCondition other = (BookCondition) obj; + if (grade == null) { + if (other.grade != null) + return false; + } else if (!grade.equals(other.grade)) + return false; + return true; + } + + @Override + public String toString() { + return grade; + } + +} diff --git a/src/main/java/com/mycompany/schoolmarket/entity/Student.java b/src/main/java/com/mycompany/schoolmarket/entity/Student.java new file mode 100644 index 0000000..4f9e425 --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/entity/Student.java @@ -0,0 +1,133 @@ +package com.mycompany.schoolmarket.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.Table; +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.Email; + +@NamedQueries({ + @NamedQuery(name = Student.FIND_BY_STUDENT_ID, query = "SELECT e FROM Student e WHERE e.idStudent = :id"), +}) + +@Entity +@Table(name = "t_students") +public class Student { + + public static final String FIND_BY_STUDENT_ID = "Student.findByStudentId"; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id_student") + private int idStudent; + + @Column(name = "firstname", nullable = false) + private String fname; + + @Column(name = "lastname", nullable = false) + private String lname; + + + @Column(name = "age", nullable = false) + @Digits(integer = 2, fraction = 0) + private Integer age; + + @Email(message = "The email is not valid!") + @Column(name = "email", nullable = false, unique = true) + private String email; + + @Column(name = "tel", nullable = true) + private String tel; + + @ManyToOne(optional = false) + @JoinColumn(name = "id_class") + private StudentClass classSection; + + public Student() { + } + + public Student(String fname, String lname, int age, @Email(message = "The email is not valid!") String email, + StudentClass classSection) { + this(fname, lname, age, email, classSection, null); + } + + public Student(String fname, String lname, int age, @Email(message = "The email is not valid!") String email, + StudentClass classSection, String tel) { + this.fname = fname; + this.lname = lname; + this.age = age; + this.email = email; + this.classSection = classSection; + this.tel = tel; + } + + public int getIdStudent() { + return idStudent; + } + + public void setIdStudent(int idStudent) { + this.idStudent = idStudent; + } + + public String getFname() { + return fname; + } + + public void setFname(String fname) { + this.fname = fname; + } + + public String getLname() { + return lname; + } + + public void setLname(String lname) { + this.lname = lname; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getTel() { + return tel; + } + + public void setTel(String tel) { + this.tel = tel; + } + + public StudentClass getClassSection() { + return classSection; + } + + public void setClassSection(StudentClass classSection) { + this.classSection = classSection; + } + + @Override + public String toString() { + return " \nNOME: " + fname + " \nCOGNOME: " + lname + " \nEMAIL: " + + email + " \nSEZIONE: " + classSection; + } + +} diff --git a/src/main/java/com/mycompany/schoolmarket/entity/StudentClass.java b/src/main/java/com/mycompany/schoolmarket/entity/StudentClass.java new file mode 100644 index 0000000..44c7cd8 --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/entity/StudentClass.java @@ -0,0 +1,99 @@ +package com.mycompany.schoolmarket.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.Table; +import jakarta.validation.constraints.Size; + +@NamedQueries({ + @NamedQuery(name = StudentClass.FIND_BY_CLASS_ID, query = "SELECT e FROM StudentClass e WHERE e.idClass = :id") + +}) + +@Entity +@Table(name = "t_classes") +public class StudentClass { + + public static final String FIND_BY_CLASS_ID = "StudentClass.findByClassId"; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id_class") + private int idClass; + + @Size(max = 5) + @Column(name = "section", nullable = false) + private String section; + + @Column(name = "scholar_year", nullable = true) + private String schoolarYear; + + public StudentClass() { + + } + + public StudentClass(int idClass, @Size(max = 5) String section) { + this.idClass = idClass; + this.section = section; + } + + public StudentClass(String schoolarYear) { + this.schoolarYear = schoolarYear; + } + + public int getIdClass() { + return idClass; + } + + public void setIdClass(int idClass) { + this.idClass = idClass; + } + + public String getSection() { + return section; + } + + public void setSection(String section) { + this.section = section; + } + + public String getSchoolarYear() { + return schoolarYear; + } + + public void setSchoolarYear(String schoolarYear) { + this.schoolarYear = schoolarYear; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (idClass ^ (idClass >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + StudentClass other = (StudentClass) obj; + if (idClass != other.idClass) + return false; + return true; + } + + @Override + public String toString() { + return this.getSection(); + } +} diff --git a/src/main/java/com/mycompany/schoolmarket/entity/Subject.java b/src/main/java/com/mycompany/schoolmarket/entity/Subject.java new file mode 100644 index 0000000..a93ac6d --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/entity/Subject.java @@ -0,0 +1,81 @@ +package com.mycompany.schoolmarket.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.Table; + +@NamedQueries({ + @NamedQuery(name = Subject.FIND_BY_SUBJECT_ID, query = "SELECT e FROM Subject e WHERE e.idSubject = :id") +}) + +@Entity +@Table(name = "t_subjects") +public class Subject { + + public static final String FIND_BY_SUBJECT_ID = "Subject.findBySubjectId"; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id_subjects") + private int idSubject; + + @Column(name = "subject_name", nullable = false) + private String subjectName; + + public Subject() { + } + + public Subject(int idSubject, String subjectName) { + this.idSubject = idSubject; + this.subjectName = subjectName; + } + + public int getIdSubject() { + return idSubject; + } + + public void setIdSubject(int idSubject) { + this.idSubject = idSubject; + } + + public String getSubjectName() { + return subjectName; + } + + public void setSubjectName(String subjectName) { + this.subjectName = subjectName; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (idSubject ^ (idSubject >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Subject other = (Subject) obj; + if (idSubject != other.idSubject) + return false; + return true; + } + + @Override + public String toString() { + return subjectName; + } + +} diff --git a/src/main/java/com/mycompany/schoolmarket/gui/BookVendingGui.java b/src/main/java/com/mycompany/schoolmarket/gui/BookVendingGui.java new file mode 100644 index 0000000..925a910 --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/gui/BookVendingGui.java @@ -0,0 +1,42 @@ +package com.mycompany.schoolmarket.gui; + +import java.math.BigDecimal; +import javax.swing.JLabel; +import javax.swing.JTextPane; +import com.mycompany.schoolmarket.boundary.SchoolMarket; +import com.mycompany.schoolmarket.entity.Book; +import com.mycompany.schoolmarket.entity.BookCondition; +import com.mycompany.schoolmarket.entity.Student; +import com.mycompany.schoolmarket.entity.StudentClass; +import com.mycompany.schoolmarket.entity.Subject; + +public class BookVendingGui { + + public static Book BookVending(String bookName, BookCondition bc, BigDecimal cost, Student st, StudentClass cl, Subject sb) { + + // Inserting new book on batabase + Book bv = SchoolMarket.bookVending(bookName, cost, bc, st, cl, sb); + return bv; + + } + + public static void logMessage(JTextPane tpShowStudent, JLabel lbLogMessage, Book bv) { + + String newBook = "Le credenziali del nuovo libro sono: \n"; + + String newBookMsg = "\n NOME LIBRO: " + bv.getBookName() + + "\n SEZZIONE CLASSE: " + bv.getClassSection() + + "\n DA: " + bv.getStudent().getLname() + " " + + bv.getStudent().getFname(); + + newBook += newBookMsg; + System.out.println(newBook); + newBook = tpShowStudent.getText() + "\n" + newBook; + tpShowStudent.setText(newBook); + + // Finale message + lbLogMessage.setText("Libro aggiunto con successo!"); + + } + +} diff --git a/src/main/java/com/mycompany/schoolmarket/gui/StudentSubscriptionGui.java b/src/main/java/com/mycompany/schoolmarket/gui/StudentSubscriptionGui.java new file mode 100644 index 0000000..10de1fc --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/gui/StudentSubscriptionGui.java @@ -0,0 +1,28 @@ +package com.mycompany.schoolmarket.gui; + +import javax.swing.JLabel; +import javax.swing.JTextPane; +import com.mycompany.schoolmarket.boundary.SchoolMarket; +import com.mycompany.schoolmarket.entity.Student; +import com.mycompany.schoolmarket.entity.StudentClass; + +public class StudentSubscriptionGui { + + public static Student StudentSubscription(String firstName, String lastName, int ageNum, String email, StudentClass ci) { + // Student registration (Method created on SchoolMarket.class under boundary + // package) + Student str = SchoolMarket.studentRegistration(firstName, lastName, ageNum, email, null, ci); + return str; + } + + public static void logMessage(Student str, JTextPane tpShowStudent, JLabel lbLogMessage) { + + String newStudent = " \nLe credenziali del nuovo studente sono: \n"; + + // Data insert on GUI log window + newStudent += " \nNOME: " + str.getFname() + " \nCOGNOME: " + str.getLname() + " \nCLASSE E SEZIONE: " + str.getClassSection() + " \nEMAIL: " + str.getEmail(); + System.out.println(newStudent); + newStudent = tpShowStudent.getText() + "\n" + newStudent; + tpShowStudent.setText(newStudent + " \n\nUtente aggiunto con successo!"); + } +} diff --git a/src/main/java/com/mycompany/schoolmarket/WinSchoolMarket.form b/src/main/java/com/mycompany/schoolmarket/gui/WinSchoolMarket.form similarity index 59% rename from src/main/java/com/mycompany/schoolmarket/WinSchoolMarket.form rename to src/main/java/com/mycompany/schoolmarket/gui/WinSchoolMarket.form index dc2c579..3b41847 100644 --- a/src/main/java/com/mycompany/schoolmarket/WinSchoolMarket.form +++ b/src/main/java/com/mycompany/schoolmarket/gui/WinSchoolMarket.form @@ -23,150 +23,153 @@ + + - + + + + - - - - - - - - + + - - - - - - - - - - + - - + + + + + - - - - - - - - - + + - - - - - - - - - + + + - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + - - + + + + + + + + - + + + + + + + + + - - - + + + + + + + + + + + + + @@ -182,120 +185,113 @@ - + - + - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - + + + - + - - - - - - - - - + + + + - - - - - - + + - + + + + + + + + + + + + + + - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - + + + - + - - + + + + + - - + + + + + - - - - - - - - - - + @@ -313,15 +309,14 @@ - + - +
-
@@ -362,6 +357,9 @@ + + + @@ -390,14 +388,14 @@
- + - + - + - + @@ -427,14 +425,19 @@ - + - + - + + + + + + - + @@ -446,7 +449,7 @@ - + @@ -463,7 +466,7 @@ - + @@ -472,15 +475,15 @@ - + - + - + @@ -490,7 +493,7 @@ - + @@ -504,15 +507,15 @@ - + - + - + @@ -524,15 +527,15 @@ - + - + - + @@ -544,28 +547,37 @@ + + + - + + + + - - - + + + + + + @@ -581,27 +593,25 @@ - + - + - + - - - - - - + + + + @@ -611,8 +621,31 @@ + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/mycompany/schoolmarket/gui/WinSchoolMarket.java b/src/main/java/com/mycompany/schoolmarket/gui/WinSchoolMarket.java new file mode 100644 index 0000000..75d20f5 --- /dev/null +++ b/src/main/java/com/mycompany/schoolmarket/gui/WinSchoolMarket.java @@ -0,0 +1,719 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package com.mycompany.schoolmarket.gui; + +import com.mycompany.schoolmarket.boundary.SchoolMarket; +import com.mycompany.schoolmarket.entity.Book; +import com.mycompany.schoolmarket.entity.BookCondition; +import com.mycompany.schoolmarket.entity.Student; +import com.mycompany.schoolmarket.entity.StudentClass; +import com.mycompany.schoolmarket.entity.Subject; + +import java.math.BigDecimal; +import java.util.List; +import javax.swing.DefaultListModel; +import javax.swing.table.DefaultTableModel; + +/** + * + * @author utentepc + */ +public class WinSchoolMarket extends javax.swing.JFrame { + + /** + * Creates new form WinSchoolMarket + */ + public WinSchoolMarket() { + initComponents(); + refreshListClass(); + refreshListStudents(); + refreshListClassBooks(); + refreshListSubjects(); + } + + /** + * 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 + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jScrollPane2 = new javax.swing.JScrollPane(); + tbBooksList = new javax.swing.JTable(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + jLabel7 = new javax.swing.JLabel(); + txFirstName = new javax.swing.JTextField(); + txLastName = new javax.swing.JTextField(); + txAge = new javax.swing.JTextField(); + btInsertStudentSubscription = new javax.swing.JButton(); + jLabel8 = new javax.swing.JLabel(); + jLabel9 = new javax.swing.JLabel(); + jLabel10 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + txBookName = new javax.swing.JTextField(); + spBookCost = new javax.swing.JSpinner(); + lbLogMessage = new javax.swing.JLabel(); + jScrollPane3 = new javax.swing.JScrollPane(); + tpShowStudent = new javax.swing.JTextPane(); + btInsertBook = new javax.swing.JButton(); + jLabel12 = new javax.swing.JLabel(); + txEmail = new javax.swing.JTextField(); + jScrollPane4 = new javax.swing.JScrollPane(); + lstStudentsList = new javax.swing.JList<>(); + jLabel13 = new javax.swing.JLabel(); + txBookHealth = new javax.swing.JTextField(); + jLabel14 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + lstClassesList = new javax.swing.JList<>(); + jScrollPane5 = new javax.swing.JScrollPane(); + lstClassesBook = new javax.swing.JList<>(); + jLabel15 = new javax.swing.JLabel(); + jLabel16 = new javax.swing.JLabel(); + jLabel17 = new javax.swing.JLabel(); + jLabel18 = new javax.swing.JLabel(); + jSeparator1 = new javax.swing.JSeparator(); + jLabel19 = new javax.swing.JLabel(); + jLabel20 = new javax.swing.JLabel(); + jLabel21 = new javax.swing.JLabel(); + jScrollPane6 = new javax.swing.JScrollPane(); + lstSubjects = new javax.swing.JList<>(); + jLabel22 = new javax.swing.JLabel(); + jLabel24 = new javax.swing.JLabel(); + jLabel25 = new javax.swing.JLabel(); + jLabel23 = new javax.swing.JLabel(); + jLabel26 = new javax.swing.JLabel(); + jLabel27 = new javax.swing.JLabel(); + jLabel28 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jLabel1.setText("SCHOOL MARKET"); + + tbBooksList.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + "nome", "classe", "costo", "grado" + } + ) { + boolean[] canEdit = new boolean [] { + false, false, false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jScrollPane2.setViewportView(tbBooksList); + + jLabel2.setFont(new java.awt.Font("sansserif", 3, 12)); // NOI18N + jLabel2.setText("Inserisci i tuoi dati nelle caselle sottostanti per registrarti nel e-commerce!"); + + jLabel3.setText("INSERIRE I DATI DEL NUOVO STUDENTE :"); + + jLabel4.setText("Nome : "); + + jLabel5.setText("Cognome :"); + + jLabel6.setText("Età : "); + + jLabel7.setText("Sezione classe :"); + + txFirstName.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txFirstNameActionPerformed(evt); + } + }); + + btInsertStudentSubscription.setText("OKAY"); + btInsertStudentSubscription.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btInsertStudentSubscriptionActionPerformed(evt); + } + }); + + jLabel8.setText("INSERIRE I DATI DEL NUOVO LIBRO:"); + + jLabel9.setText("Nome libro :"); + + jLabel10.setText("Costo :"); + + jLabel11.setText("Classe :"); + + txBookName.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txBookNameActionPerformed(evt); + } + }); + + spBookCost.setModel(new javax.swing.SpinnerNumberModel(0.0d, null, null, 1.0d)); + + lbLogMessage.setText("nessun dato ancora fornito..."); + + jScrollPane3.setViewportView(tpShowStudent); + + btInsertBook.setText("OKAY"); + btInsertBook.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btInsertBookActionPerformed(evt); + } + }); + + jLabel12.setText("E-mail : "); + + lstStudentsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + lstStudentsList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstStudentsListValueChanged(evt); + } + }); + jScrollPane4.setViewportView(lstStudentsList); + + jLabel13.setText("Stato dell'oggetto :"); + + jLabel14.setText("(es. Grado A, B o C)"); + + lstClassesList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + lstClassesList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstClassesListValueChanged(evt); + } + }); + jScrollPane1.setViewportView(lstClassesList); + + lstClassesBook.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + lstClassesBook.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstClassesBookValueChanged(evt); + } + }); + jScrollPane5.setViewportView(lstClassesBook); + + jLabel15.setText("LISTA LIBRI"); + + jLabel16.setFont(new java.awt.Font("sansserif", 3, 14)); // NOI18N + jLabel16.setText("Sei nuovo? "); + + jLabel17.setFont(new java.awt.Font("sansserif", 2, 12)); // NOI18N + jLabel17.setText("Premi \"OKAY\" per aggiungere il libro"); + + jLabel19.setFont(new java.awt.Font("sansserif", 3, 14)); // NOI18N + jLabel19.setText("Vuoi vendere un libro?"); + + jLabel20.setFont(new java.awt.Font("sansserif", 3, 12)); // NOI18N + jLabel20.setText("Compila i dati sottostanti per aggiungerlo nel catalogo!"); + + jLabel21.setText("Materia :"); + + lstSubjects.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + lstSubjects.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + lstSubjectsValueChanged(evt); + } + }); + jScrollPane6.setViewportView(lstSubjects); + + jLabel22.setFont(new java.awt.Font("sansserif", 2, 12)); // NOI18N + jLabel22.setText("Premi \"OKAY\" per completare la registrazione"); + + jLabel24.setText("SELEZIONARE ACCOUNT ESISTENTE : "); + + jLabel25.setFont(new java.awt.Font("sansserif", 3, 12)); // NOI18N + jLabel25.setText("Se invece ti sei già registrato/a puoi scegliere tra gli utenti esistenti : "); + + jLabel23.setText("(es. 45,55)"); + + jLabel26.setText("A: Ben conservato"); + + jLabel27.setText("B: Pochi segni di usura visibili"); + + jLabel28.setText("C: Evidente usura, ma utilizzabile"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(408, 408, 408)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(8, 8, 8) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel9) + .addComponent(txBookName, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(btInsertBook) + .addComponent(jLabel17))) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(spBookCost, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel10) + .addGroup(layout.createSequentialGroup() + .addGap(6, 6, 6) + .addComponent(jLabel23)))) + .addGroup(layout.createSequentialGroup() + .addGap(27, 27, 27) + .addComponent(jLabel18))) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel28) + .addComponent(jLabel14) + .addComponent(txBookHealth, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel13) + .addComponent(jLabel26) + .addComponent(jLabel27))))) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel21) + .addGap(81, 81, 81) + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addComponent(jLabel8)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane2) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel19) + .addComponent(jLabel20)) + .addGap(1051, 1051, 1051)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5) + .addComponent(jLabel4) + .addComponent(jLabel6) + .addComponent(jLabel12)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(txAge, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE) + .addComponent(txLastName, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txFirstName, javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txEmail)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel7) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel22) + .addGap(18, 18, 18) + .addComponent(btInsertStudentSubscription)) + .addComponent(jLabel3)) + .addGap(164, 164, 164) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 455, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 323, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel25) + .addComponent(lbLogMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 358, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, Short.MAX_VALUE)))))) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel16)) + .addGroup(layout.createSequentialGroup() + .addGap(521, 521, 521) + .addComponent(jLabel1))) + .addGap(0, 0, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(3, 3, 3) + .addComponent(jLabel16) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(jLabel25)) + .addGap(44, 44, 44) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel24) + .addComponent(jLabel3)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(8, 8, 8) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txAge, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(19, 19, 19) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel22) + .addComponent(btInsertStudentSubscription) + .addComponent(lbLogMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE) + .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE) + .addComponent(jLabel19) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel20) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel15) + .addComponent(jLabel8)) + .addGap(18, 18, 18) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9) + .addComponent(jLabel10) + .addComponent(jLabel13)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txBookName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(spBookCost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txBookHealth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel21) + .addComponent(jLabel11) + .addComponent(jLabel14) + .addComponent(jLabel23)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE) + .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(17, 17, 17) + .addComponent(jLabel26) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel27) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel28)) + .addGroup(layout.createSequentialGroup() + .addGap(77, 77, 77) + .addComponent(jLabel18))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btInsertBook) + .addGap(24, 24, 24))))) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void txFirstNameActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_tx_firstNameActionPerformed + + }// GEN-LAST:event_tx_firstNameActionPerformed + + private void btInsertStudentSubscriptionActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btInsertStudentSubscriptionActionPerformed + + // Method for registering a new student via the GUI (eventListener JButton) + + String firstName = txFirstName.getText(); + String lastName = txLastName.getText(); + String email = txEmail.getText(); + String age = txAge.getText(); + int ageNum = Integer.parseInt(age); + StudentClass ci = SchoolMarket.getClass(lstClassesList.getSelectedValue().getIdClass()); + + Student str = StudentSubscriptionGui.StudentSubscription(firstName, lastName, ageNum, email, ci); + StudentSubscriptionGui.logMessage(str, tpShowStudent, lbLogMessage); + + txFirstName.setText(""); + txLastName.setText(""); + txAge.setText(""); + txEmail.setText(""); + + refreshListStudents(); + lstStudentsList.setSelectedValue(str, rootPaneCheckingEnabled); + + + }// GEN-LAST:event_btInsertStudentSubscriptionActionPerformed + + private void btInsertBookActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btInsertBookActionPerformed + + // Method to insert a new student's book via the GUI (eventListener JButton) + + + // New book's data + String bookName = txBookName.getText(); + BigDecimal cost = BigDecimal.valueOf((double) spBookCost.getValue()); + BookCondition bc = SchoolMarket.getBookCondition(txBookHealth.getText().toUpperCase()); + Student st = SchoolMarket.getStudent(lstStudentsList.getSelectedValue().getIdStudent()); + StudentClass cl = SchoolMarket.getClass(lstClassesBook.getSelectedValue().getIdClass()); + Subject sb = SchoolMarket.getSubject(lstSubjects.getSelectedValue().getIdSubject()); + + Book bv = BookVendingGui.BookVending(bookName, bc, cost, st, cl, sb); + BookVendingGui.logMessage(tpShowStudent, lbLogMessage, bv); + + + txBookName.setText(""); + txBookHealth.setText(""); + spBookCost.setValue(0); + + refreshTableBooks(); + + }// GEN-LAST:event_btInsertBookActionPerformed + + private void lstStudentsListValueChanged(javax.swing.event.ListSelectionEvent evt) {// GEN-FIRST:event_lst_studentsListValueChanged + + if (!evt.getValueIsAdjusting() && lstStudentsList.getSelectedValue() != null) { + Student st = lstStudentsList.getSelectedValue();/* */ + String name = st.getFname() + " " + st.getLname(); + int idStudent = lstStudentsList.getSelectedValue().getIdStudent(); + lbLogMessage.setText(" STUDENT_NAME: " + name + " ID: " + idStudent); + refreshTableBooks(); + } + + }// GEN-LAST:event_lst_studentsListValueChanged + + private void lstClassesListValueChanged(javax.swing.event.ListSelectionEvent evt) {// GEN-FIRST:event_lst_classesListValueChanged + + String section = lstClassesList.getSelectedValue().getSection(); + int classId = lstClassesList.getSelectedValue().getIdClass(); + lbLogMessage.setText("CLASS_ID: " + classId + " SECTION: " + section); + + }// GEN-LAST:event_lst_classesListValueChanged + + private void txBookNameActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_tx_bookNameActionPerformed + + }// GEN-LAST:event_tx_bookNameActionPerformed + + private void lstClassesBookValueChanged(javax.swing.event.ListSelectionEvent evt) {// GEN-FIRST:event_lst_classesBookValueChanged + + String section = lstClassesBook.getSelectedValue().getSection(); + int classId = lstClassesBook.getSelectedValue().getIdClass(); + lbLogMessage.setText("CLASS_ID: " + classId + " SECTION: " + section); + + }// GEN-LAST:event_lst_classesBookValueChanged + + private void lstSubjectsValueChanged(javax.swing.event.ListSelectionEvent evt) {// GEN-FIRST:event_lst_subjectsValueChanged + + String subject = lstSubjects.getSelectedValue().getSubjectName(); + int subjectId = lstSubjects.getSelectedValue().getIdSubject(); + lbLogMessage.setText("SUBJECT: " + subject + " ID: " + subjectId); + + }// GEN-LAST:event_lst_subjectsValueChanged + + public void refreshListClass() { + + // Class list repopulation method executed at programme start-up + + List result = SchoolMarket.classesList(); + DefaultListModel model = new DefaultListModel<>(); + result.forEach(model::addElement); + lstClassesList.setModel(model); + + } + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* + * If Nimbus (introduced in Java SE 6) is not available, stay with the default + * look and feel. + * For details see + * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(WinSchoolMarket.class.getName()).log(java.util.logging.Level.SEVERE, + null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(WinSchoolMarket.class.getName()).log(java.util.logging.Level.SEVERE, + null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(WinSchoolMarket.class.getName()).log(java.util.logging.Level.SEVERE, + null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(WinSchoolMarket.class.getName()).log(java.util.logging.Level.SEVERE, + null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new WinSchoolMarket().setVisible(true); + } + }); + } + + public void refreshListStudents() { + + // Method for populating the list of students executed at the start of the + // programme and subsequently when inserting a new student + + List result = SchoolMarket.studentsList(); + DefaultListModel model = new DefaultListModel<>(); + result.forEach(v -> model.addElement(v)); + lstStudentsList.setModel(model); + + } + + private void refreshListClassBooks() { + + // Method to populate the list of classes to which the book belongs, executed at + // programme start-up + + List result = SchoolMarket.classesList(); + DefaultListModel model = new DefaultListModel<>(); + result.forEach(v -> model.addElement(v)); + lstClassesBook.setModel(model); + + } + + private void refreshTableBooks() { + + /* + * Method to populate the table (JTabel) executed on the basis of + * the selection of the student from the list (JList) and + * subsequently the insertion of a new book via the form + */ + + int index = lstStudentsList.getSelectedValue().getIdStudent(); + List booksByUser = SchoolMarket.booksByUser(index); + DefaultTableModel model = (DefaultTableModel) tbBooksList.getModel(); + model.setRowCount(0); + String euro = "€ "; + + booksByUser.stream().map(book -> new Object[] { + book.getBookName().toString(), + book.getClassSection().toString(), + euro + book.getCost().toString(), + book.getGrade().toString() + }).forEach(row -> model.addRow(row)); + + } + + private void refreshListSubjects() { + + // Method for populating the list of school subjects executed at programme + // start-up + + List result = SchoolMarket.subjectList(); + DefaultListModel model = new DefaultListModel<>(); + result.forEach(v -> model.addElement(v)); + lstSubjects.setModel(model); + + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btInsertBook; + private javax.swing.JButton btInsertStudentSubscription; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel16; + private javax.swing.JLabel jLabel17; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel19; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel20; + private javax.swing.JLabel jLabel21; + private javax.swing.JLabel jLabel22; + private javax.swing.JLabel jLabel23; + private javax.swing.JLabel jLabel24; + private javax.swing.JLabel jLabel25; + private javax.swing.JLabel jLabel26; + private javax.swing.JLabel jLabel27; + private javax.swing.JLabel jLabel28; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JScrollPane jScrollPane4; + private javax.swing.JScrollPane jScrollPane5; + private javax.swing.JScrollPane jScrollPane6; + private javax.swing.JSeparator jSeparator1; + private javax.swing.JLabel lbLogMessage; + private javax.swing.JList lstClassesBook; + private javax.swing.JList lstClassesList; + private javax.swing.JList lstStudentsList; + private javax.swing.JList lstSubjects; + private javax.swing.JSpinner spBookCost; + private javax.swing.JTable tbBooksList; + private javax.swing.JTextPane tpShowStudent; + private javax.swing.JTextField txAge; + private javax.swing.JTextField txBookHealth; + private javax.swing.JTextField txBookName; + private javax.swing.JTextField txEmail; + private javax.swing.JTextField txFirstName; + private javax.swing.JTextField txLastName; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..4335f87 --- /dev/null +++ b/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,17 @@ + + + + + AUTO + + + + + + + + + + + + \ No newline at end of file diff --git a/target/classes/META-INF/persistence.xml b/target/classes/META-INF/persistence.xml new file mode 100644 index 0000000..4335f87 --- /dev/null +++ b/target/classes/META-INF/persistence.xml @@ -0,0 +1,17 @@ + + + + + AUTO + + + + + + + + + + + + \ No newline at end of file diff --git a/target/classes/com/mycompany/schoolmarket/boundary/RegistrationException.class b/target/classes/com/mycompany/schoolmarket/boundary/RegistrationException.class new file mode 100644 index 0000000..66cb253 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/boundary/RegistrationException.class differ diff --git a/target/classes/com/mycompany/schoolmarket/boundary/SchoolMarket.class b/target/classes/com/mycompany/schoolmarket/boundary/SchoolMarket.class new file mode 100644 index 0000000..9b62c99 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/boundary/SchoolMarket.class differ diff --git a/target/classes/com/mycompany/schoolmarket/boundary/SearchException.class b/target/classes/com/mycompany/schoolmarket/boundary/SearchException.class new file mode 100644 index 0000000..672adee Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/boundary/SearchException.class differ diff --git a/target/classes/com/mycompany/schoolmarket/control/Store.class b/target/classes/com/mycompany/schoolmarket/control/Store.class new file mode 100644 index 0000000..c14fc67 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/control/Store.class differ diff --git a/target/classes/com/mycompany/schoolmarket/control/StoreException.class b/target/classes/com/mycompany/schoolmarket/control/StoreException.class new file mode 100644 index 0000000..fbb91ef Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/control/StoreException.class differ diff --git a/target/classes/com/mycompany/schoolmarket/entity/Book.class b/target/classes/com/mycompany/schoolmarket/entity/Book.class new file mode 100644 index 0000000..4a34e1f Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/entity/Book.class differ diff --git a/target/classes/com/mycompany/schoolmarket/entity/BookCondition.class b/target/classes/com/mycompany/schoolmarket/entity/BookCondition.class new file mode 100644 index 0000000..6ee45a1 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/entity/BookCondition.class differ diff --git a/target/classes/com/mycompany/schoolmarket/entity/Student.class b/target/classes/com/mycompany/schoolmarket/entity/Student.class new file mode 100644 index 0000000..2a5251e Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/entity/Student.class differ diff --git a/target/classes/com/mycompany/schoolmarket/entity/StudentClass.class b/target/classes/com/mycompany/schoolmarket/entity/StudentClass.class new file mode 100644 index 0000000..f3eb460 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/entity/StudentClass.class differ diff --git a/target/classes/com/mycompany/schoolmarket/entity/Subject.class b/target/classes/com/mycompany/schoolmarket/entity/Subject.class new file mode 100644 index 0000000..aaf01c7 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/entity/Subject.class differ diff --git a/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$1.class b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$1.class new file mode 100644 index 0000000..cb3ccd2 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$1.class differ diff --git a/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$10.class b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$10.class new file mode 100644 index 0000000..fe94b64 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$10.class differ diff --git a/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$2.class b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$2.class new file mode 100644 index 0000000..a2ca3d3 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$2.class differ diff --git a/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$3.class b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$3.class new file mode 100644 index 0000000..ca7fe45 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$3.class differ diff --git a/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$4.class b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$4.class new file mode 100644 index 0000000..9dd1360 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$4.class differ diff --git a/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$5.class b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$5.class new file mode 100644 index 0000000..484ad90 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$5.class differ diff --git a/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$6.class b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$6.class new file mode 100644 index 0000000..2086de6 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$6.class differ diff --git a/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$7.class b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$7.class new file mode 100644 index 0000000..f7309bd Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$7.class differ diff --git a/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$8.class b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$8.class new file mode 100644 index 0000000..d3c3ffa Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$8.class differ diff --git a/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$9.class b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$9.class new file mode 100644 index 0000000..dba3d88 Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket$9.class differ diff --git a/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket.class b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket.class new file mode 100644 index 0000000..04c736f Binary files /dev/null and b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket.class differ diff --git a/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket.form b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket.form new file mode 100644 index 0000000..3b41847 --- /dev/null +++ b/target/classes/com/mycompany/schoolmarket/gui/WinSchoolMarket.form @@ -0,0 +1,651 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="sansserif" size="12" style="3"/> + </Property> + <Property name="text" type="java.lang.String" value="Inserisci i tuoi dati nelle caselle sottostanti per registrarti nel e-commerce!"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="text" type="java.lang.String" value="INSERIRE I DATI DEL NUOVO STUDENTE :"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="text" type="java.lang.String" value="Nome : "/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="text" type="java.lang.String" value="Cognome :"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="text" type="java.lang.String" value="Età : "/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="text" type="java.lang.String" value="Sezione classe :"/> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txFirstName"> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txFirstNameActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="txLastName"> + </Component> + <Component class="javax.swing.JTextField" name="txAge"> + </Component> + <Component class="javax.swing.JButton" name="btInsertStudentSubscription"> + <Properties> + <Property name="text" type="java.lang.String" value="OKAY"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btInsertStudentSubscriptionActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="text" type="java.lang.String" value="INSERIRE I DATI DEL NUOVO LIBRO:"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel9"> + <Properties> + <Property name="text" type="java.lang.String" value="Nome libro :"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel10"> + <Properties> + <Property name="text" type="java.lang.String" value="Costo :"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel11"> + <Properties> + <Property name="text" type="java.lang.String" value="Classe :"/> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txBookName"> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txBookNameActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JSpinner" name="spBookCost"> + <Properties> + <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor"> + <SpinnerModel initial="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="lbLogMessage"> + <Properties> + <Property name="text" type="java.lang.String" value="nessun dato ancora fornito..."/> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane3"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextPane" name="tpShowStudent"> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="btInsertBook"> + <Properties> + <Property name="text" type="java.lang.String" value="OKAY"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btInsertBookActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel12"> + <Properties> + <Property name="text" type="java.lang.String" value="E-mail : "/> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txEmail"> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane4"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstStudentsList"> + <Properties> + <Property name="selectionMode" type="int" value="0"/> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstStudentsListValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<Student>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel13"> + <Properties> + <Property name="text" type="java.lang.String" value="Stato dell'oggetto :"/> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txBookHealth"> + </Component> + <Component class="javax.swing.JLabel" name="jLabel14"> + <Properties> + <Property name="text" type="java.lang.String" value="(es. Grado A, B o C)"/> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstClassesList"> + <Properties> + <Property name="selectionMode" type="int" value="0"/> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstClassesListValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<StudentClass>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane5"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstClassesBook"> + <Properties> + <Property name="selectionMode" type="int" value="0"/> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstClassesBookValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<StudentClass>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel15"> + <Properties> + <Property name="text" type="java.lang.String" value="LISTA LIBRI"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel16"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="sansserif" size="14" style="3"/> + </Property> + <Property name="text" type="java.lang.String" value="Sei nuovo? "/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel17"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="sansserif" size="12" style="2"/> + </Property> + <Property name="text" type="java.lang.String" value="Premi "OKAY" per aggiungere il libro"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel18"> + </Component> + <Component class="javax.swing.JSeparator" name="jSeparator1"> + </Component> + <Component class="javax.swing.JLabel" name="jLabel19"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="sansserif" size="14" style="3"/> + </Property> + <Property name="text" type="java.lang.String" value="Vuoi vendere un libro?"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel20"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="sansserif" size="12" style="3"/> + </Property> + <Property name="text" type="java.lang.String" value="Compila i dati sottostanti per aggiungerlo nel catalogo!"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel21"> + <Properties> + <Property name="text" type="java.lang.String" value="Materia :"/> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane6"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="lstSubjects"> + <Properties> + <Property name="selectionMode" type="int" value="0"/> + </Properties> + <Events> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="lstSubjectsValueChanged"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<Subject>"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel22"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="sansserif" size="12" style="2"/> + </Property> + <Property name="text" type="java.lang.String" value="Premi "OKAY" per completare la registrazione"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel24"> + <Properties> + <Property name="text" type="java.lang.String" value="SELEZIONARE ACCOUNT ESISTENTE : "/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel25"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="sansserif" size="12" style="3"/> + </Property> + <Property name="text" type="java.lang.String" value="Se invece ti sei già registrato/a puoi scegliere tra gli utenti esistenti : "/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel23"> + <Properties> + <Property name="text" type="java.lang.String" value="(es. 45,55)"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel26"> + <Properties> + <Property name="text" type="java.lang.String" value="A: Ben conservato"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel27"> + <Properties> + <Property name="text" type="java.lang.String" value="B: Pochi segni di usura visibili"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel28"> + <Properties> + <Property name="text" type="java.lang.String" value="C: Evidente usura, ma utilizzabile"/> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..0a07c9d --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=schoolMarket +groupId=com.mycompany +version=1.0-SNAPSHOT diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..59ec977 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,23 @@ +com\mycompany\schoolmarket\entity\StudentClass.class +com\mycompany\schoolmarket\boundary\SchoolMarket.class +com\mycompany\schoolmarket\gui\WinSchoolMarket$2.class +com\mycompany\schoolmarket\gui\WinSchoolMarket$1.class +com\mycompany\schoolmarket\control\Store.class +com\mycompany\schoolmarket\gui\WinSchoolMarket$8.class +com\mycompany\schoolmarket\gui\BookVendingGui.class +com\mycompany\schoolmarket\gui\StudentSubscriptionGui.class +com\mycompany\schoolmarket\entity\Subject.class +com\mycompany\schoolmarket\gui\WinSchoolMarket$9.class +com\mycompany\schoolmarket\control\StoreException.class +com\mycompany\schoolmarket\entity\Book.class +com\mycompany\schoolmarket\gui\WinSchoolMarket$5.class +com\mycompany\schoolmarket\entity\BookCondition.class +com\mycompany\schoolmarket\gui\WinSchoolMarket.class +com\mycompany\schoolmarket\gui\WinSchoolMarket$4.class +com\mycompany\schoolmarket\entity\Student.class +com\mycompany\schoolmarket\gui\WinSchoolMarket$10.class +com\mycompany\schoolmarket\gui\WinSchoolMarket$6.class +com\mycompany\schoolmarket\gui\WinSchoolMarket$3.class +com\mycompany\schoolmarket\gui\WinSchoolMarket$7.class +com\mycompany\schoolmarket\boundary\RegistrationException.class +com\mycompany\schoolmarket\boundary\SearchException.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..a708c7a --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,13 @@ +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\boundary\SchoolMarket.java +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\control\StoreException.java +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\boundary\SearchException.java +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\boundary\RegistrationException.java +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\gui\WinSchoolMarket.java +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\gui\StudentSubscriptionGui.java +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\entity\Subject.java +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\entity\StudentClass.java +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\gui\BookVendingGui.java +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\entity\Book.java +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\entity\Student.java +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\entity\BookCondition.java +C:\Users\utentepc\Linguaggio Java\schoolMarket-jpa-linux\schoolMarket\src\main\java\com\mycompany\schoolmarket\control\Store.java diff --git a/target/schoolMarket-1.0-SNAPSHOT.jar b/target/schoolMarket-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..a82dffd Binary files /dev/null and b/target/schoolMarket-1.0-SNAPSHOT.jar differ