From 85913e42f5387265f80a2793f86c50906f559431 Mon Sep 17 00:00:00 2001 From: mostafa_benalaa <118845123+Mosteben@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:11:41 +0300 Subject: [PATCH 1/9] First Commit --- .idea/.gitignore | 3 + .idea/compiler.xml | 13 ++ .idea/jarRepositories.xml | 25 +++ .idea/misc.xml | 14 ++ .idea/runConfigurations.xml | 10 + .idea/uiDesigner.xml | 124 +++++++++++ .idea/vcs.xml | 6 + pom.xml | 76 +++++++ .../java/com/example/EmployeeCRUDApp.java | 210 ++++++++++++++++++ .../com/example/dao/EmployeeRepository.java | 86 +++++++ .../com/example/factory/EmployeeFactory.java | 16 ++ .../java/com/example/model/Developer.java | 12 + src/main/java/com/example/model/Employee.java | 66 ++++++ src/main/java/com/example/model/Manager.java | 11 + .../com/example/service/EmployeeService.java | 35 +++ .../com/example/util/DatabaseConnection.java | 15 ++ src/main/java/com/example/util/employee.sql | 73 ++++++ target/classes/EmployeeCRUDApp$1.class | Bin 0 -> 2532 bytes target/classes/EmployeeCRUDApp.class | Bin 0 -> 9707 bytes .../com/example/dao/EmployeeRepository.class | Bin 0 -> 4969 bytes .../com/example/factory/EmployeeFactory.class | Bin 0 -> 1483 bytes .../classes/com/example/model/Developer.class | Bin 0 -> 462 bytes .../classes/com/example/model/Employee.class | Bin 0 -> 1748 bytes .../classes/com/example/model/Manager.class | Bin 0 -> 456 bytes .../com/example/service/EmployeeService.class | Bin 0 -> 1270 bytes .../com/example/util/DatabaseConnection.class | Bin 0 -> 770 bytes 26 files changed, 795 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 pom.xml create mode 100644 src/main/java/com/example/EmployeeCRUDApp.java create mode 100644 src/main/java/com/example/dao/EmployeeRepository.java create mode 100644 src/main/java/com/example/factory/EmployeeFactory.java create mode 100644 src/main/java/com/example/model/Developer.java create mode 100644 src/main/java/com/example/model/Employee.java create mode 100644 src/main/java/com/example/model/Manager.java create mode 100644 src/main/java/com/example/service/EmployeeService.java create mode 100644 src/main/java/com/example/util/DatabaseConnection.java create mode 100644 src/main/java/com/example/util/employee.sql create mode 100644 target/classes/EmployeeCRUDApp$1.class create mode 100644 target/classes/EmployeeCRUDApp.class create mode 100644 target/classes/com/example/dao/EmployeeRepository.class create mode 100644 target/classes/com/example/factory/EmployeeFactory.class create mode 100644 target/classes/com/example/model/Developer.class create mode 100644 target/classes/com/example/model/Employee.class create mode 100644 target/classes/com/example/model/Manager.class create mode 100644 target/classes/com/example/service/EmployeeService.class create mode 100644 target/classes/com/example/util/DatabaseConnection.class 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..539c473 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..947ef88 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..82dbec8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..78ee5bd --- /dev/null +++ b/pom.xml @@ -0,0 +1,76 @@ + + + 4.0.0 + + org.example + EmployeeconfigrationWithSQL + 1.0-SNAPSHOT + + + 17 + 17 + 20.0.1 + + + + + com.microsoft.sqlserver + mssql-jdbc + 9.4.1.jre8 + + + de.jensd + fontawesomefx + 8.9.1 + + + junit + junit + 4.13.2 + test + + + org.openjfx + javafx-controls + ${javafx.version} + + + com.jfoenix + jfoenix + 9.0.10 + + + + + + + + + + jitpack.io + https://jitpack.io + + + + + + + org.openjfx + javafx-maven-plugin + 0.0.13 + + com.example.EmployeeCRUDApp + + + + + run + + + + + + + diff --git a/src/main/java/com/example/EmployeeCRUDApp.java b/src/main/java/com/example/EmployeeCRUDApp.java new file mode 100644 index 0000000..3e5ac11 --- /dev/null +++ b/src/main/java/com/example/EmployeeCRUDApp.java @@ -0,0 +1,210 @@ +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.layout.*; +import javafx.stage.Stage; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.geometry.Insets; + +import com.example.dao.EmployeeRepository; +import com.example.model.Employee; +import com.example.model.Developer; + +import java.sql.SQLException; +import java.util.List; + +public class EmployeeCRUDApp extends Application { + + private TableView table; + private TextField nameField, emailField, positionField, salaryField; + private Button addButton, cancelButton; + private EmployeeRepository repository; + + public static void main(String[] args) { + launch(args); + } + + @Override + public void start(Stage primaryStage) { + repository = new EmployeeRepository(); + + primaryStage.setTitle("Employee CRUD Operations"); + + table = new TableView<>(); + loadTableData(); + table.getColumns().addAll( + createColumn("ID", "id", 50), + createColumn("Name", "name", 150), + createColumn("Email", "email", 200), + createColumn("Position", "position", 100), + createColumn("Salary", "salary", 100), + createActionColumn() + ); + + nameField = new TextField(); + nameField.setPromptText("Enter name"); + nameField.setMinWidth(200); + + emailField = new TextField(); + emailField.setPromptText("Enter email"); + emailField.setMinWidth(200); + + positionField = new TextField(); + positionField.setPromptText("Enter position"); + positionField.setMinWidth(200); + + salaryField = new TextField(); + salaryField.setPromptText("Enter salary"); + salaryField.setMinWidth(200); + + addButton = new Button("Add"); + addButton.setStyle("-fx-background-color: #4CAF50; -fx-text-fill: white;"); + addButton.setMinWidth(120); + addButton.setOnAction(e -> addEmployee()); + + cancelButton = new Button("Cancel"); + cancelButton.setStyle("-fx-background-color: #f44336; -fx-text-fill: white;"); + cancelButton.setMinWidth(120); + cancelButton.setOnAction(e -> clearFields()); + + HBox buttonBox = new HBox(10, addButton, cancelButton); + + VBox formLayout = new VBox(15, + createFormRow("Name:", nameField), + createFormRow("Email:", emailField), + createFormRow("Position:", positionField), + createFormRow("Salary:", salaryField), + buttonBox); + formLayout.setPadding(new Insets(25)); + formLayout.setStyle("-fx-background-color: white; -fx-border-color: #dcdcdc; -fx-border-width: 1px;"); + + BorderPane mainLayout = new BorderPane(); + mainLayout.setCenter(table); + mainLayout.setRight(formLayout); + mainLayout.setPadding(new Insets(25)); + mainLayout.setStyle("-fx-background-color: white;"); + BorderPane.setMargin(table, new Insets(0, 25, 0, 0)); + + Scene scene = new Scene(mainLayout, 1200, 700); + primaryStage.setScene(scene); + primaryStage.setResizable(false); + primaryStage.show(); + } + + private HBox createFormRow(String labelText, TextField textField) { + Label label = new Label(labelText); + label.setMinWidth(100); + HBox row = new HBox(10, label, textField); + row.setStyle("-fx-alignment: center-left;"); + return row; + } + + private TableColumn createColumn(String title, String property, int width) { + TableColumn column = new TableColumn<>(title); + column.setCellValueFactory(new PropertyValueFactory<>(property)); + column.setMinWidth(width); + return column; + } + + private TableColumn createActionColumn() { + TableColumn col = new TableColumn<>("Actions"); + col.setCellFactory(param -> new TableCell<>() { + final Button editButton = new Button("Edit"); + final Button deleteButton = new Button("Delete"); + + { + editButton.setStyle("-fx-background-color: yellow;"); + deleteButton.setStyle("-fx-background-color: red;"); + editButton.setOnAction(e -> editEmployee(getIndex())); + deleteButton.setOnAction(e -> deleteEmployee(getIndex())); + } + + @Override + protected void updateItem(Void item, boolean empty) { + super.updateItem(item, empty); + if (empty) { + setGraphic(null); + } else { + HBox actions = new HBox(5, editButton, deleteButton); + setGraphic(actions); + } + } + }); + return col; + } + + private void loadTableData() { + try { + table.setItems(getEmployeeList()); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + private ObservableList getEmployeeList() throws SQLException { + List employees = repository.getAllEmployees(); + return FXCollections.observableArrayList(employees); + } + + private void addEmployee() { + Employee emp = new Developer( + nameField.getText(), + emailField.getText(), + positionField.getText(), + Double.parseDouble(salaryField.getText()) + ); + try { + repository.addEmployee(emp); + table.getItems().add(emp); + clearFields(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + private void editEmployee(int index) { + Employee selectedEmployee = table.getItems().get(index); + nameField.setText(selectedEmployee.getName()); + emailField.setText(selectedEmployee.getEmail()); + positionField.setText(selectedEmployee.getPosition()); + salaryField.setText(String.valueOf(selectedEmployee.getSalary())); + + addButton.setText("Update"); + addButton.setOnAction(e -> { + selectedEmployee.setName(nameField.getText()); + selectedEmployee.setEmail(emailField.getText()); + selectedEmployee.setPosition(positionField.getText()); + selectedEmployee.setSalary(Double.parseDouble(salaryField.getText())); + try { + repository.updateEmployee(selectedEmployee); + table.refresh(); + clearFields(); + addButton.setText("Add"); + addButton.setOnAction(event -> addEmployee()); + } catch (SQLException ex) { + ex.printStackTrace(); + } + }); + } + + private void deleteEmployee(int index) { + Employee selectedEmployee = table.getItems().get(index); + try { + repository.deleteEmployee(selectedEmployee.getId()); + table.getItems().remove(index); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + private void clearFields() { + nameField.clear(); + emailField.clear(); + positionField.clear(); + salaryField.clear(); + addButton.setText("Add"); + addButton.setOnAction(event -> addEmployee()); + } +} diff --git a/src/main/java/com/example/dao/EmployeeRepository.java b/src/main/java/com/example/dao/EmployeeRepository.java new file mode 100644 index 0000000..be0d0e8 --- /dev/null +++ b/src/main/java/com/example/dao/EmployeeRepository.java @@ -0,0 +1,86 @@ +package com.example.dao; + +import com.example.model.Employee; +import com.example.model.Developer; +import com.example.util.DatabaseConnection; + +import java.sql.*; +import java.util.ArrayList; +import java.util.List; + +public class EmployeeRepository { + + public void addEmployee(Employee employee) throws SQLException { + String query = "INSERT INTO employees (name, email, position, salary) VALUES (?, ?, ?, ?)"; + try (Connection conn = DatabaseConnection.getConnection(); + PreparedStatement stmt = conn.prepareStatement(query)) { + stmt.setString(1, employee.getName()); + stmt.setString(2, employee.getEmail()); + stmt.setString(3, employee.getPosition()); + stmt.setDouble(4, employee.getSalary()); + stmt.executeUpdate(); + } + } + + public List getAllEmployees() throws SQLException { + List employees = new ArrayList<>(); + String query = "SELECT * FROM employees"; + try (Connection conn = DatabaseConnection.getConnection(); + Statement stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery(query)) { + while (rs.next()) { + Employee employee = new Developer( + rs.getString("name"), + rs.getString("email"), + rs.getString("position"), + rs.getDouble("salary") + ); + employee.setId(rs.getInt("id")); + employees.add(employee); + } + } + return employees; + } + + public Employee getEmployeeById(int id) throws SQLException { + String query = "SELECT * FROM employees WHERE id = ?"; + Employee employee = null; + try (Connection conn = DatabaseConnection.getConnection(); + PreparedStatement stmt = conn.prepareStatement(query)) { + stmt.setInt(1, id); + ResultSet rs = stmt.executeQuery(); + if (rs.next()) { + employee = new Developer( + rs.getString("name"), + rs.getString("email"), + rs.getString("position"), + rs.getDouble("salary") + ); + employee.setId(rs.getInt("id")); + } + } + return employee; + } + + public void updateEmployee(Employee employee) throws SQLException { + String query = "UPDATE employees SET name = ?, email = ?, position = ?, salary = ? WHERE id = ?"; + try (Connection conn = DatabaseConnection.getConnection(); + PreparedStatement stmt = conn.prepareStatement(query)) { + stmt.setString(1, employee.getName()); + stmt.setString(2, employee.getEmail()); + stmt.setString(3, employee.getPosition()); + stmt.setDouble(4, employee.getSalary()); + stmt.setInt(5, employee.getId()); + stmt.executeUpdate(); + } + } + + public void deleteEmployee(int id) throws SQLException { + String query = "DELETE FROM employees WHERE id = ?"; + try (Connection conn = DatabaseConnection.getConnection(); + PreparedStatement stmt = conn.prepareStatement(query)) { + stmt.setInt(1, id); + stmt.executeUpdate(); + } + } +} diff --git a/src/main/java/com/example/factory/EmployeeFactory.java b/src/main/java/com/example/factory/EmployeeFactory.java new file mode 100644 index 0000000..9d16c63 --- /dev/null +++ b/src/main/java/com/example/factory/EmployeeFactory.java @@ -0,0 +1,16 @@ +package com.example.factory; + +import com.example.model.Developer; +import com.example.model.Employee; +import com.example.model.Manager; + +public class EmployeeFactory { + public static Employee createEmployee(String type, String name, String email, String position, double salary) { + if ("Developer".equalsIgnoreCase(type)) { + return new Developer(name, email, position, salary); + } else if ("Manager".equalsIgnoreCase(type)) { + return new Manager(name, email, position, salary); + } + throw new IllegalArgumentException("Unknown employee type: " + type); + } +} diff --git a/src/main/java/com/example/model/Developer.java b/src/main/java/com/example/model/Developer.java new file mode 100644 index 0000000..6ccbde7 --- /dev/null +++ b/src/main/java/com/example/model/Developer.java @@ -0,0 +1,12 @@ +package com.example.model; + +public class Developer extends Employee { + public Developer(String name, String email, String position, double salary) { + super(name, email, position, salary); + } + + //@Override + //public void performDuties() { + //System.out.println("Writing code, debugging, and reviewing pull requests."); + //} +} \ No newline at end of file diff --git a/src/main/java/com/example/model/Employee.java b/src/main/java/com/example/model/Employee.java new file mode 100644 index 0000000..74e28b9 --- /dev/null +++ b/src/main/java/com/example/model/Employee.java @@ -0,0 +1,66 @@ +package com.example.model; + +public class Employee { + private int id; + private String name; + private String email; + private String position; + private double salary; + + public Employee() {} + + public Employee(int id, String name, String email, String position, double salary) { + this.id = id; + this.name = name; + this.email = email; + this.position = position; + this.salary = salary; + } + + public Employee(String name, String email, String position, double salary) { + this.id = 0; + this.name = name; + this.email = email; + this.position = position; + this.salary = salary; + } + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this.salary = salary; + } +} diff --git a/src/main/java/com/example/model/Manager.java b/src/main/java/com/example/model/Manager.java new file mode 100644 index 0000000..7e970bf --- /dev/null +++ b/src/main/java/com/example/model/Manager.java @@ -0,0 +1,11 @@ +package com.example.model; + +public class Manager extends Employee { + public Manager(String name, String email, String position, double salary) { + super(name, email, position, salary); + } + + //@Override + //public void performDuties() { + //System.out.println("Managing teams, conducting meetings, and planning projects."); + } diff --git a/src/main/java/com/example/service/EmployeeService.java b/src/main/java/com/example/service/EmployeeService.java new file mode 100644 index 0000000..a5d7e4f --- /dev/null +++ b/src/main/java/com/example/service/EmployeeService.java @@ -0,0 +1,35 @@ +package com.example.service; + +import com.example.dao.EmployeeRepository; +import com.example.model.Employee; + +import java.sql.SQLException; +import java.util.List; + +public class EmployeeService { + private final EmployeeRepository employeeRepository; + + public EmployeeService() { + this.employeeRepository = new EmployeeRepository(); + } + + public void addEmployee(Employee employee) throws SQLException { + employeeRepository.addEmployee(employee); + } + + public List getAllEmployees() throws SQLException { + return employeeRepository.getAllEmployees(); + } + + public Employee getEmployeeById(int id) throws SQLException { + return employeeRepository.getEmployeeById(id); + } + + public void updateEmployee(Employee employee) throws SQLException { + employeeRepository.updateEmployee(employee); + } + + public void deleteEmployee(int id) throws SQLException { + employeeRepository.deleteEmployee(id); + } +} \ No newline at end of file diff --git a/src/main/java/com/example/util/DatabaseConnection.java b/src/main/java/com/example/util/DatabaseConnection.java new file mode 100644 index 0000000..82b6878 --- /dev/null +++ b/src/main/java/com/example/util/DatabaseConnection.java @@ -0,0 +1,15 @@ +package com.example.util; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +public class DatabaseConnection { + private static final String URL = "jdbc:sqlserver://localhost:1433;databaseName=EmployeeDB"; + private static final String USER = "User"; + private static final String PASSWORD = "Newpassword12"; + + public static Connection getConnection() throws SQLException { + return DriverManager.getConnection(URL, USER, PASSWORD); + } +} diff --git a/src/main/java/com/example/util/employee.sql b/src/main/java/com/example/util/employee.sql new file mode 100644 index 0000000..0ecc0e4 --- /dev/null +++ b/src/main/java/com/example/util/employee.sql @@ -0,0 +1,73 @@ +-- phpMyAdmin SQL Dump +-- version 5.1.1 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Dec 12, 2022 at 12:32 AM +-- Server version: 10.4.22-MariaDB +-- PHP Version: 8.1.1 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `employee` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `employee` +-- + +CREATE TABLE `employee` ( + `id` int(11) NOT NULL, + `employee_id` int(100) NOT NULL, + `firstName` varchar(100) NOT NULL, + `lastName` varchar(100) NOT NULL, + `gender` varchar(100) NOT NULL, + `phoneNum` varchar(100) NOT NULL, + `position` varchar(100) NOT NULL, + `image` varchar(100) NOT NULL, + `date` date DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- +-- Dumping data for table `employee` +-- + +INSERT INTO `employee` (`id`, `employee_id`, `firstName`, `lastName`, `gender`, `phoneNum`, `position`, `image`, `date`) VALUES +(1, 1, 'Ahmed', 'Hesham', 'Male', '01272026038', 'Web Developer (Front End)', 'C:\\\\Users\\\\Lenovo\\\\Pictures\\\\20211206_163643.jpg', '2022-12-11'), +(2, 2, 'aaaaa', 'aaaaaaaa', 'Female', '01830283', 'Marketer Coordinator', 'C:\\\\Users\\\\Lenovo\\\\Pictures\\\\20211220_144148.jpg', '2022-12-11'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `employee` +-- +ALTER TABLE `employee` + ADD PRIMARY KEY (`id`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `employee` +-- +ALTER TABLE `employee` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/target/classes/EmployeeCRUDApp$1.class b/target/classes/EmployeeCRUDApp$1.class new file mode 100644 index 0000000000000000000000000000000000000000..510ed69b2d619cbaa461d58ab747d4daf57ea3f6 GIT binary patch literal 2532 zcma)7YjYD-7=BKhHtBXtLkPE0kW0`swFH#vNC2T}q18~(K(wIfc5~V;-RudwCvAd? zh~tlN{Ngu1J0tB3jE!~q;+FgU4%CK!%t>6bu-*SQ!D6RKJ6a>diHH##H*rD%j0Id4Wy9q$oMIT; zUC-y`T!K5J_*D zcpK+Qp1fW6t?HU%x8>VJFN!j!yhQO1!=bJuyH-QgWOjZ=)CaF5i39qJ;sVuImzXkO zU>X-y-Y=1n^z6MB4Pk+`UA)h*XQw7g!YM15S5;Uu49U(&)MYDio)EM)&AuXLNG(qx zl7oWd@x@wYnftm`7!n0xTW-nn9o0I`!-#4_hJC%Js5}^=md-idk9Bj@K{km+9G%;^ zmI*sZ6T&dSD^=NGV0RftijwO5hE;8PHeIW-T((jk-&FJ9Xir&%<)&*=hs7wSHj1$F zIz@<`4trE~Lq%uRvt-RDy~S?yFO86k1zS|Iyl&B$;@JxE=Vn{f=6a*LOc5JJQS)tn z%~8FTY>76ra7Go4%CKj@|YUIdaMJ|lz-B=t#XJs2HC#efG9Mb*SZ_zWj^s@L&0#5&IwH07jWtx#%(PpKKM zbngD{tm>vx=pY;nL8>6cdac^YN^@Fv@YJPvyHVwx;{X3LbopxCkhietnwImH>lUdb zb8!$+2Yc$ORZ*h@*iikvX~M$&IPTNIBX#hViO+GL>S@9AxSw~eAmBk1k7=yE#OH3* zMDe8gW_6+J5~ax;@`&T)F-D`RA93}}&?>Ip3i`y=+e!NY`X9zE8mk}C>Sshq1Gtr$ zd%2)^b1TcCGqaS?|5&iUm-0nMHHgqHgb!ZDH2kU`Zc66O~hmR z{T2qEAc3dkg+D=5#-NkO%x_h#Ans})C78- z^pvKNnfw!%$G320hmb+7|4@4}_1XyS$NN;JG%Z{q+bS_81;H{~$Zz3#uZ>0rab_E% zi7)Ua7+Ir2{BLVFdac!8WsSI6CNzDpQPy9M75YZ#Ia$R6eKL=A`l>X#6nlUgB{*C) TX!SMSC7LnO65kN_-{J7TvlVYR literal 0 HcmV?d00001 diff --git a/target/classes/EmployeeCRUDApp.class b/target/classes/EmployeeCRUDApp.class new file mode 100644 index 0000000000000000000000000000000000000000..a2388db2eb339b1cdeb8ca81a7c2bca4214e5aa2 GIT binary patch literal 9707 zcmb_i3w%`Nl|N@P$xMa|gdw8wMIur2AdC`xkSHZ2p$0>E1Ofq6Zf0)6z+@)O+yP?k z%huXftD@HTR_$tiwgSooh+3`B`gU8beOYb0uXelJ-F3J7Z2Ldocki9a3;FGD!|ylW z>wM=s?{mKI^2#5NJWWIw@?VF@M@0eh8&pgsOs8%)cbWZrBIeLgA|5sEcq$ob$@iH` zE{G@N_7bL|n%bTa1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Oldf35y*ED~7Rd&8rL)g08pJW*t0=J#LG6KjJ?F4Qf*d&F^7Lq71VhqdBYJ_Blf>?}Z4 z>XBN?hb5SUB3wHrp=kbiwJt9}Q>a$qQ_$c#GYOgr*3oh_G!W{OV8zEz@zZD})Moj+ z=%KbiO;W@!@%Q;Pr}w(kdyD^y-*M*N^;UoE^?rulFMtCdx;Tp#fBXUel7CGVe+FTx B?mz$l literal 0 HcmV?d00001 diff --git a/target/classes/com/example/dao/EmployeeRepository.class b/target/classes/com/example/dao/EmployeeRepository.class new file mode 100644 index 0000000000000000000000000000000000000000..2129cfcaf591c0af87cd010d15b49a8b2eadb4e2 GIT binary patch literal 4969 zcmcInTXR#_75P%-k)2B8sozB$#_POcEGRaIk zU|{dF&f06Oy}oa)b^O79e*YeTVO(v53k@>d3Ow*iXgQ-Us=XOCd%Abx)EO;VlHlE! z&ZbNIB{YP(W_<8Th(^cbk*P#5I-ZyaY76;HZducc!BAFR(0V9P)0v)NK37ba(z$F; zu&8F#!g5z|W+XNpi3dXmdV=QPu0}MXNrs}}F07Yue=@hwt1YQCsr8mi=}d1}Evcu} zqBfe#W*H6bNx18@R&qYKhq_{V*u}G%-s+2?CbZyg8GZ%#pjE;>Yv}O8`GS^L3tGIS zmb3*e%M15~40C!G;-x}5dwR&>VbVB|vQG>(q7Cgb?o|-LMhP38w^+!fv`lZrOp*kd z!H+Xf5?ZaWoqn3of%{}^RM7CAI{UR(MJx2sK zLih;<+l8=+!buY;ArC3&LN{$w9@lZxaSw~QdKB!!Zo_XlS3Z^DB|M>MxNAnd?Njgo z9wa*2l9nu&wCQ|`8P!im#ru8*4+(~Ol9^mllku>Hh<^RVd?EL=N|TKkz#|FcCaUj{j9fUHwzq)n8b0XZCgcxJF6{`t*pv98F2}l>S-6&7PU++uN8cl z76-^XVR=@;V>n@gtn*vK_S=W%46dP3&+B>#Iq1W@1XnsGoS#wf6f%s5ERKqjUej|_5I(CQhdl4Z zVv3Su?od?lseq!4l7cc8C9Kz>)k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1ynSAD?VHZ=hFZ4Fp!JD_qX=u+037 j>#W+w3P+1N=(3MRtBkCFfHg+V8uhRahu=4tHL&>&`JHK> literal 0 HcmV?d00001 diff --git a/target/classes/com/example/model/Employee.class b/target/classes/com/example/model/Employee.class new file mode 100644 index 0000000000000000000000000000000000000000..a370afc4c3059b623fe5526d316f771a7c7380a0 GIT binary patch literal 1748 zcma)+T~8B16o%hvcUxMvK(TzIt%|Z;K8nhP3N{+SqzOS24EIaf;F5ljwix*d-up95 z)P%;w3x9w=%J`nyg~oQ9kR~%{X3m`RoOjOl&);9a0ldIw8ZpF^Ff5ozC`_EXAKg;T zZJdUa8(Z_G+bF+RY2k zQ;7M;3aTPk#w?6uLcwUbb)HP__0k-4T7KhXOS~p6+!8O-tGj+pcBU*$%g)GIv+Z~M zWqlPey?a#CxtdkCcIdWzS%;fO=Y!u? zSlk=VzooEcR|Y|Eva?e>RCsRR#C6a|Up7y?PKEMO^9luN2P?y_NaQ3B_qC8YyEqtt z4)hNkrXnCD#0W#|ipn(U9GauteHSXNFv^48D#f#dP;gRF@)Xanb_`o%rw^Lvt*ZCN z7v(cot*|byjk|oh7@N-I$mXFHlcvx!pIy&I$%Rf)6WY&t)oerUHv zj&cm7ahszRIN%QQT*>7EN4fk3aU?kx>%$u>>$LpBR&i zC0GW5?%{rj)l>Zv$***Zp{M#{r0Pp}5MD0RTT&#n;yrEUPX|;+s+V`04!o{06QPa@ z53w8plKI{TvJ?qoqc{K}n)ZX(1St*ykq(uf;<`mBE2Ud ztC1kNevr*bkhN%#TtCQDf;<}nBHbb&>-vifzRVcc@?~CP=3C#>Y)67@u+E_G%WOSq azJ#;7J_@lu zrHhbo;hh=p&aU_S=kp7|B{pMJP>m2YP(w)A8MrJ_Z=8*cN;3DPOmZXGO_d^q7uxFL zig3Q4zVIt2hV3xv7P+>=_J5SlK`%m`usz@9jx7&WP6)20E1{WctL`URU*!+nH=?vs zH(=A_TzftfgW_3_3A^c^j%~5DoRtQ1LlbH$V{HiaksIqmJ1gHDv*CP7pbjDKx=B7z zx7v@;m`!==jj)GEmgkS8`t`}ZAnZ|4C^0@fIzHJ7K0xonDu}&SR@5Xf#G>#ssq<R?&dm8P=j8DB->*Laj`1de3522u8+e3>z|5s}Wtp~BubS^mm$K{$ zM2=Klc_#v)bfy?ZOklI@)J%D8)f%=mE0$xPGjiHeev}QzRi4vqClEy_j!76%Oc_XG zT43uo%$3b6RhE5dp_>cL$q_Pv?fh-*{gQ`TbJoBd<^?9LN~PyYU_E^YUvnzb?kgW= ziW-?Ru!zS3(^cu6+IA1@(os5-_s7!mlx^mf>-kbk2A*QM3+Pp!wR06Mm&-gPsO44- ztZAdkR-g5q zjJeqSZZSJUh!HT8y@AO7M)dOy;y;o2&btY0^P6M^U?7Ys;*;3%GarNJc)?6_&$C+d zo$}Or@$3&Ib~~6E5b6IFFpC(=HOXSPFd!iWX=F&22`gXc!R{7V~9r`zxD@m@E=Gp^n3sS literal 0 HcmV?d00001 diff --git a/target/classes/com/example/util/DatabaseConnection.class b/target/classes/com/example/util/DatabaseConnection.class new file mode 100644 index 0000000000000000000000000000000000000000..7b22a94641279c3d71bdab87ad93b704cdbf8273 GIT binary patch literal 770 zcma)4T~8B16g|@xcDuBKtAOGsAW8AT4Pau@iiy(tv=r=0eV*M;$~4>EIy2?tU+I&^ z2Y&!Rig*VIB_SqkvUld(d(S<0?#$WwpT7XMvF4$GqJvTeQ%%u6iP^_(Y9k>juNj?n32_KG95sZyYgC;jT=34CJSw)b;mN z3w0z^JqXe~;pt(nO?~6-)>fl;#cT7S*ltn1{8WhMCl?il(gCqt++(P=#qo%1eVnV_ z#-@ik+;`wt@Bj}P7A`s_ji9L{iR|)>_k|)>UzkZh47;^(a=6GSne`iY@vL7aS%pct z294vO6EgU>OOP}rYQr^@1qeQI^gS-DRioWf2n&jEZdlZ-rWhUC=VJy^F9;f8- zLpz}^SJL7uXUQB&&9D~UVer)1V(ouDd##g1jO_hr2P+Ko*Tajxgx4_!FUrR%5uc@P zY4P^$zOg(k!=cv$6tRSPEPzr86;LMp=mwr4{P+g0QVz54jqDOJ0$LfZQ?Gx4{k$mg zgscsNB%YG3TqfWdo)aq5)xV%3mb^mp_VfI*KjT+_WA+CjhDn7gUXrIozGeDXX Date: Mon, 19 Aug 2024 03:16:55 +0300 Subject: [PATCH 2/9] Update employee.sql --- src/main/java/com/example/util/employee.sql | 84 +++++---------------- 1 file changed, 20 insertions(+), 64 deletions(-) diff --git a/src/main/java/com/example/util/employee.sql b/src/main/java/com/example/util/employee.sql index 0ecc0e4..fedaa82 100644 --- a/src/main/java/com/example/util/employee.sql +++ b/src/main/java/com/example/util/employee.sql @@ -1,73 +1,29 @@ --- phpMyAdmin SQL Dump --- version 5.1.1 --- https://www.phpmyadmin.net/ --- --- Host: 127.0.0.1 --- Generation Time: Dec 12, 2022 at 12:32 AM --- Server version: 10.4.22-MariaDB --- PHP Version: 8.1.1 +CREATE DATABASE EmployeeDB; -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -START TRANSACTION; -SET time_zone = "+00:00"; +USE EmployeeDB; +CREATE TABLE employees ( + id INT PRIMARY KEY IDENTITY(1,1), + name NVARCHAR(100) NOT NULL, + email NVARCHAR(100) NOT NULL UNIQUE, + position NVARCHAR(50) NOT NULL, + salary DECIMAL(10, 2) NOT NULL +); -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; --- --- Database: `employee` --- +INSERT INTO employees (name, email, position, salary) +VALUES +('mohamed Ali', 'mohamed.ali@gmail.com', 'Developer', 7000.00), +('Mona Hassan', 'mona.hassan@gmail.com', 'Manager', 12000.00), +('Youssef Ibrahim', 'youssef.ibrahim@gmail.com', 'Developer', 8000.00); --- -------------------------------------------------------- +SELECT * FROM employees; --- --- Table structure for table `employee` --- +UPDATE employees +SET name = 'Ali Ahmed', email = 'ali.ahmed@gmail.com', position = 'Senior Developer', salary = 9000.00 +WHERE id = 1; -CREATE TABLE `employee` ( - `id` int(11) NOT NULL, - `employee_id` int(100) NOT NULL, - `firstName` varchar(100) NOT NULL, - `lastName` varchar(100) NOT NULL, - `gender` varchar(100) NOT NULL, - `phoneNum` varchar(100) NOT NULL, - `position` varchar(100) NOT NULL, - `image` varchar(100) NOT NULL, - `date` date DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +DELETE FROM employees WHERE id = 2; --- --- Dumping data for table `employee` --- +SELECT * FROM employees WHERE id = 1; -INSERT INTO `employee` (`id`, `employee_id`, `firstName`, `lastName`, `gender`, `phoneNum`, `position`, `image`, `date`) VALUES -(1, 1, 'Ahmed', 'Hesham', 'Male', '01272026038', 'Web Developer (Front End)', 'C:\\\\Users\\\\Lenovo\\\\Pictures\\\\20211206_163643.jpg', '2022-12-11'), -(2, 2, 'aaaaa', 'aaaaaaaa', 'Female', '01830283', 'Marketer Coordinator', 'C:\\\\Users\\\\Lenovo\\\\Pictures\\\\20211220_144148.jpg', '2022-12-11'); - --- --- Indexes for dumped tables --- - --- --- Indexes for table `employee` --- -ALTER TABLE `employee` - ADD PRIMARY KEY (`id`); - --- --- AUTO_INCREMENT for dumped tables --- - --- --- AUTO_INCREMENT for table `employee` --- -ALTER TABLE `employee` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -COMMIT; - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; From 1b641e1257aca1ec605862d6006a35bfefb0313c Mon Sep 17 00:00:00 2001 From: mostafa_benalaa <118845123+Mosteben@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:20:41 +0300 Subject: [PATCH 3/9] Update README.md --- README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a95b725..ec1567a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,26 @@ -# EmployeeconfigrationWithSQL -This project is a simple Java application that manages employee data using an SQL database. It demonstrates basic CRUD (Create, Read, Update, Delete) operations using JDBC for database interactions. + +Here's a condensed, single-page README for your project: + +Employee Configuration with SQL +A Java application for managing employee data using an SQL database. Demonstrates basic CRUD (Create, Read, Update, Delete) operations via JDBC. + +Features +CRUD Operations: Add, view, update, and delete employee records. +JDBC Integration: Connects to SQL database for data manipulation. +Factory Pattern: Creates employee objects with modular design. +Console Interface: Basic user interaction through command line. +Project Structure +com.example.model: Employee class. +com.example.dao: EmployeeRepository for DB operations. +com.example.service: EmployeeService for business logic. +com.example.factory: EmployeeFactory for creating employees. +com.example: Main class (Main) for application execution. +Setup and Configuration +Clone Repository: +git clone https://github.com//EmployeeConfigurationWithSQL.git +JDBC Driver: Include SQL Server JDBC Driver JAR in your classpath. +Configure Database: Update DatabaseConnection with your DB credentials. +Build Project: +mvn clean install +Run Application: +java -cp target/EmployeeConfigurationWithSQL-1.0-SNAPSHOT.jar com.example.Main From 2812b2c52cac7f191d9490264f1e88be2c677ce6 Mon Sep 17 00:00:00 2001 From: mostafa_benalaa <118845123+Mosteben@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:22:23 +0300 Subject: [PATCH 4/9] Update README.md --- README.md | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index ec1567a..559c918 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,18 @@ +# Employee Configuration with SQL -Here's a condensed, single-page README for your project: - -Employee Configuration with SQL A Java application for managing employee data using an SQL database. Demonstrates basic CRUD (Create, Read, Update, Delete) operations via JDBC. -Features -CRUD Operations: Add, view, update, and delete employee records. -JDBC Integration: Connects to SQL database for data manipulation. -Factory Pattern: Creates employee objects with modular design. -Console Interface: Basic user interaction through command line. -Project Structure -com.example.model: Employee class. -com.example.dao: EmployeeRepository for DB operations. -com.example.service: EmployeeService for business logic. -com.example.factory: EmployeeFactory for creating employees. -com.example: Main class (Main) for application execution. -Setup and Configuration -Clone Repository: -git clone https://github.com//EmployeeConfigurationWithSQL.git -JDBC Driver: Include SQL Server JDBC Driver JAR in your classpath. -Configure Database: Update DatabaseConnection with your DB credentials. -Build Project: -mvn clean install -Run Application: -java -cp target/EmployeeConfigurationWithSQL-1.0-SNAPSHOT.jar com.example.Main +## Features + +- **CRUD Operations:** Add, view, update, and delete employee records. +- **JDBC Integration:** Connects to SQL database for data manipulation. +- **Factory Pattern:** Creates employee objects with modular design. +- **Console Interface:** Basic user interaction through command line. + +## Project Structure + +- **`com.example.model`**: `Employee` class. +- **`com.example.dao`**: `EmployeeRepository` for DB operations. +- **`com.example.service`**: `EmployeeService` for business logic. +- **`com.example.factory`**: `EmployeeFactory` for creating employees. +- **`com.example`**: Main class (`Main`) for application execution. From 41be46403c4968817cdaa630c41ba9e12032c93c Mon Sep 17 00:00:00 2001 From: mostafa_benalaa <118845123+Mosteben@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:23:54 +0300 Subject: [PATCH 5/9] Update README.md --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 559c918..f716ea2 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,25 @@ A Java application for managing employee data using an SQL database. Demonstrate - **`com.example.service`**: `EmployeeService` for business logic. - **`com.example.factory`**: `EmployeeFactory` for creating employees. - **`com.example`**: Main class (`Main`) for application execution. +## Database Connection and Setup + +### Database Setup + +1. **Create Database and Table:** + Set up your SQL Server database and table by executing the following SQL commands: + + ```sql + -- Create the database + CREATE DATABASE EmployeeDB; + + -- Use the database + USE EmployeeDB; + + -- Create the employees table + CREATE TABLE employees ( + id INT PRIMARY KEY IDENTITY, + name VARCHAR(255) NOT NULL, + email VARCHAR(255) NOT NULL UNIQUE, + position VARCHAR(255), + salary DECIMAL(10, 2) NOT NULL + ); From 7f6fa03fc087c5a5460ec8a9e5d394b5fa741cb6 Mon Sep 17 00:00:00 2001 From: mostafa_benalaa <118845123+Mosteben@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:25:42 +0300 Subject: [PATCH 6/9] Update README.md --- README.md | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f716ea2..5330657 100644 --- a/README.md +++ b/README.md @@ -21,20 +21,17 @@ A Java application for managing employee data using an SQL database. Demonstrate ### Database Setup 1. **Create Database and Table:** - Set up your SQL Server database and table by executing the following SQL commands: + Set up your SQL Server database and table by executing the file in util - ```sql - -- Create the database - CREATE DATABASE EmployeeDB; - - -- Use the database - USE EmployeeDB; - - -- Create the employees table - CREATE TABLE employees ( - id INT PRIMARY KEY IDENTITY, - name VARCHAR(255) NOT NULL, - email VARCHAR(255) NOT NULL UNIQUE, - position VARCHAR(255), - salary DECIMAL(10, 2) NOT NULL - ); + ## Running the Application + +To run the application, follow these steps: + +### 1. Build the Project + +Ensure you have Maven installed. Open a terminal or command prompt and navigate to the project root directory where the `pom.xml` file is located. + +Run the following Maven command to build the project: + +```bash +mvn clean install From 29e6975a6cf786614617098d12ee36282e6da8c6 Mon Sep 17 00:00:00 2001 From: mostafa_benalaa <118845123+Mosteben@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:28:19 +0300 Subject: [PATCH 7/9] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 5330657..e0534a5 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ A Java application for managing employee data using an SQL database. Demonstrate - **`com.example.service`**: `EmployeeService` for business logic. - **`com.example.factory`**: `EmployeeFactory` for creating employees. - **`com.example`**: Main class (`Main`) for application execution. +- - **`com.example.util`**: Contains `DatabaseConnection` class for managing database connections. ## Database Connection and Setup ### Database Setup @@ -35,3 +36,10 @@ Run the following Maven command to build the project: ```bash mvn clean install + +Verify Application: + +The application should start, and you will see output in the terminal based on the operations performed in the Main class: + +Employee records will be retrieved and displayed. +Any updates or deletions made will be reflected in the output. From 3995fa1f222eed58fcff40f5d139101f62e15cce Mon Sep 17 00:00:00 2001 From: mostafa_benalaa <118845123+Mosteben@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:29:27 +0300 Subject: [PATCH 8/9] Update README.md --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index e0534a5..e1e0745 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ A Java application for managing employee data using an SQL database. Demonstrate To run the application, follow these steps: -### 1. Build the Project +### Build the Project Ensure you have Maven installed. Open a terminal or command prompt and navigate to the project root directory where the `pom.xml` file is located. @@ -37,9 +37,3 @@ Run the following Maven command to build the project: ```bash mvn clean install -Verify Application: - -The application should start, and you will see output in the terminal based on the operations performed in the Main class: - -Employee records will be retrieved and displayed. -Any updates or deletions made will be reflected in the output. From 97ff746ec682d81848ed4847e6d7e9fbf0d1772d Mon Sep 17 00:00:00 2001 From: mostafa_benalaa <118845123+Mosteben@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:31:19 +0300 Subject: [PATCH 9/9] Create maven.yml --- .github/workflows/maven.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..c6bb036 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,35 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6