diff --git a/.run/Tomcat 9.0.40.run.xml b/.run/Tomcat 9.0.40.run.xml index 48a1bed5..5aec9311 100644 --- a/.run/Tomcat 9.0.40.run.xml +++ b/.run/Tomcat 9.0.40.run.xml @@ -1,10 +1,11 @@ - + + diff --git a/.vs/ProiectColectiv/v16/.suo b/.vs/ProiectColectiv/v16/.suo new file mode 100644 index 00000000..618411ad Binary files /dev/null and b/.vs/ProiectColectiv/v16/.suo differ diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 00000000..b4acb70f --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,16 @@ +{ + "ExpandedNodes": [ + "", + "\\EmployeeManagementApp", + "\\EmployeeManagementApp\\EmployeeAppPersistence", + "\\EmployeeManagementApp\\EmployeeAppPersistence\\src", + "\\EmployeeManagementApp\\EmployeeAppPersistence\\src\\main", + "\\EmployeeManagementApp\\EmployeeAppPersistence\\src\\main\\java", + "\\EmployeeManagementApp\\EmployeeAppPersistence\\src\\main\\java\\ro", + "\\EmployeeManagementApp\\EmployeeAppPersistence\\src\\main\\java\\ro\\ubb", + "\\EmployeeManagementApp\\EmployeeAppPersistence\\src\\main\\java\\ro\\ubb\\constants", + "\\EmployeeManagementApp\\EmployeeAppPersistence\\src\\main\\java\\ro\\ubb\\exceptions" + ], + "SelectedNode": "\\EmployeeManagementApp\\EmployeeAppPersistence\\src\\main\\java\\ro\\ubb\\interfaces\\TechnologiesAreasDao.java", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 00000000..8f48f931 Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/EmployeeManagementApp/EmployeeAppBusiness/src/main/java/ro/ubb/interfaces/TechnologiesService.java b/EmployeeManagementApp/EmployeeAppBusiness/src/main/java/ro/ubb/interfaces/TechnologiesService.java new file mode 100644 index 00000000..c192b52a --- /dev/null +++ b/EmployeeManagementApp/EmployeeAppBusiness/src/main/java/ro/ubb/interfaces/TechnologiesService.java @@ -0,0 +1,12 @@ +package ro.ubb.interfaces; + +import ro.ubb.exceptions.DbException; + +import java.util.List; + +public interface TechnologiesService { + + List findAll() throws DbException; + + +} diff --git a/EmployeeManagementApp/EmployeeAppBusiness/src/main/java/ro/ubb/services/TechnologiesServiceImpl.java b/EmployeeManagementApp/EmployeeAppBusiness/src/main/java/ro/ubb/services/TechnologiesServiceImpl.java new file mode 100644 index 00000000..32a70369 --- /dev/null +++ b/EmployeeManagementApp/EmployeeAppBusiness/src/main/java/ro/ubb/services/TechnologiesServiceImpl.java @@ -0,0 +1,18 @@ +package ro.ubb.services; + +import ro.ubb.exceptions.DbException; +import ro.ubb.implementations.TechnologiesDaoImpl; +import ro.ubb.interfaces.TechnologiesDao; +import ro.ubb.interfaces.TechnologiesService; + +import java.util.List; + +public class TechnologiesServiceImpl implements TechnologiesService { + + @Override + public List findAll() throws DbException { + TechnologiesDao technologiesDao=new TechnologiesDaoImpl(); + + return (technologiesDao).findAll(); + } +} diff --git a/EmployeeManagementApp/EmployeeAppFront/src/main/java/ro/ubb/controllers/TechnologiesController.java b/EmployeeManagementApp/EmployeeAppFront/src/main/java/ro/ubb/controllers/TechnologiesController.java new file mode 100644 index 00000000..52a1c9a6 --- /dev/null +++ b/EmployeeManagementApp/EmployeeAppFront/src/main/java/ro/ubb/controllers/TechnologiesController.java @@ -0,0 +1,19 @@ +package ro.ubb.controllers; + +import ro.ubb.exceptions.DbException; +import ro.ubb.services.TechnologiesServiceImpl; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import java.util.List; + +@Path("/technologies") +public class TechnologiesController { + + @GET + @Path("/technologies") + @Produces(MediaType.APPLICATION_JSON) + public List getAllTechnologies() throws DbException { + return new TechnologiesServiceImpl().findAll(); + } +} diff --git a/EmployeeManagementApp/EmployeeAppPersistence/src/main/java/ro/ubb/constants/Technologies.java b/EmployeeManagementApp/EmployeeAppPersistence/src/main/java/ro/ubb/constants/Technologies.java new file mode 100644 index 00000000..0a1d95bd --- /dev/null +++ b/EmployeeManagementApp/EmployeeAppPersistence/src/main/java/ro/ubb/constants/Technologies.java @@ -0,0 +1,17 @@ +package ro.ubb.constants; + +public enum Technologies { + DATABASES("Databases"), + FRAMEWORKS("Frameworks"), + PROGRAMMING_LANGUAGE("Programming language"); + + private final String Technologies; + + Technologies(String Technologies) { + this.Technologies = Technologies; + } + + public String getTechnologies() { + return Technologies; + } +} \ No newline at end of file diff --git a/EmployeeManagementApp/EmployeeAppPersistence/src/main/java/ro/ubb/implementations/TechnologiesDaoImpl.java b/EmployeeManagementApp/EmployeeAppPersistence/src/main/java/ro/ubb/implementations/TechnologiesDaoImpl.java new file mode 100644 index 00000000..3fabcd19 --- /dev/null +++ b/EmployeeManagementApp/EmployeeAppPersistence/src/main/java/ro/ubb/implementations/TechnologiesDaoImpl.java @@ -0,0 +1,74 @@ +package ro.ubb.implementations; + +import ro.ubb.constants.TechnologyArea; +import ro.ubb.exceptions.DbException; +import ro.ubb.interfaces.GenericDao; +import ro.ubb.interfaces.TechnologiesDao; +import ro.ubb.models.Technologies; +import ro.ubb.utilities.DatabaseConnection; + +import java.sql.*; +import java.util.ArrayList; +import java.util.List; + +public class TechnologiesDaoImpl implements GenericDao, TechnologiesDao { + @Override + public List findAll() throws DbException { + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + + try { + DatabaseConnection databaseConnection = new DatabaseConnection(); + Connection connection = databaseConnection.getConnection(); + + String querySelect = "SELECT Technologies_Area FROM skills " ; + Statement statement = connection.createStatement(); + ResultSet resultSet = statement.executeQuery(querySelect); + + + String technologyAreaName; + + List names=new ArrayList<>(); + + if (resultSet.next()) { + + technologyAreaName = resultSet.getString("Technologies_Area"); + TechnologyArea[] technologyAreas = TechnologyArea.values(); + for (TechnologyArea area : technologyAreas) { + if (area.getTechnologyArea().equals(technologyAreaName)) { + names.add(area.name()); + } + } + } else + return null; + + return names; + } catch (SQLException sqlException) { + throw new DbException("Something went wrong with the database"); + } + } + + @Override + public Object find(int id) throws DbException { + return null; + } + + @Override + public Object save(Object entity) throws DbException { + return null; + } + + @Override + public Object delete(int id) throws DbException { + return null; + } + + + @Override + public Technologies update(Object entity) throws DbException { + return null; + } +} diff --git a/EmployeeManagementApp/EmployeeAppPersistence/src/main/java/ro/ubb/interfaces/TechnologiesDao.java b/EmployeeManagementApp/EmployeeAppPersistence/src/main/java/ro/ubb/interfaces/TechnologiesDao.java new file mode 100644 index 00000000..7ff37481 --- /dev/null +++ b/EmployeeManagementApp/EmployeeAppPersistence/src/main/java/ro/ubb/interfaces/TechnologiesDao.java @@ -0,0 +1,9 @@ +package ro.ubb.interfaces; + +import ro.ubb.exceptions.DbException; + +import java.util.List; + +public interface TechnologiesDao { + List findAll() throws DbException; +} diff --git a/EmployeeManagementApp/EmployeeAppPersistence/src/main/java/ro/ubb/models/Technologies.java b/EmployeeManagementApp/EmployeeAppPersistence/src/main/java/ro/ubb/models/Technologies.java new file mode 100644 index 00000000..cdeee1ff --- /dev/null +++ b/EmployeeManagementApp/EmployeeAppPersistence/src/main/java/ro/ubb/models/Technologies.java @@ -0,0 +1,27 @@ +package ro.ubb.models; + +public class Technologies { + private int idTech; + private String techName; + + public Technologies(int idTech, String techName) { + this.idTech = idTech; + this.techName = techName; + } + + public int getIdTech() { + return idTech; + } + + public void setIdTech(int idTech) { + this.idTech = idTech; + } + + public String getTechName() { + return techName; + } + + public void setTechName(String techName) { + this.techName = techName; + } +}