diff --git a/src/main/java/com/web/web_assignment/DatabaseService.java b/src/main/java/com/web/web_assignment/DatabaseService.java index 8e321be..65f7ee0 100644 --- a/src/main/java/com/web/web_assignment/DatabaseService.java +++ b/src/main/java/com/web/web_assignment/DatabaseService.java @@ -29,7 +29,7 @@ public class DatabaseService { try (Connection conn = getConnection()) { createTables(conn); } catch (SQLException e) { - e.printStackTrace(); +// e.printStackTrace(); } try { String sql = "SELECT * FROM users"; @@ -60,7 +60,7 @@ public class DatabaseService { return dataSource.getConnection(); } - private void createTables(Connection conn) throws SQLException { + private void createTables(Connection conn){ String createUsersTable = "CREATE TABLE users (" + "id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, " + "username VARCHAR(255) UNIQUE, " + @@ -121,7 +121,7 @@ public class DatabaseService { projects.add(project); } } catch (SQLException e) { - e.printStackTrace(); +// e.printStackTrace(); } return projects; } @@ -167,7 +167,7 @@ public class DatabaseService { } } - public UserInfo getUserInfo(String username) throws SQLException { + public UserInfo getUserInfo(String username){ String sql = "SELECT * FROM users WHERE username = ?"; try (Connection conn = getConnection(); PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -183,7 +183,7 @@ public class DatabaseService { rs.getString("careerGoals")); } } catch (SQLException e) { - e.printStackTrace(); +// e.printStackTrace(); } return null; } @@ -198,7 +198,7 @@ public class DatabaseService { users.add(rs.getString("username")); } } catch (SQLException e) { - e.printStackTrace(); +// e.printStackTrace(); } return users; } diff --git a/src/main/java/com/web/web_assignment/ProjectBean.java b/src/main/java/com/web/web_assignment/ProjectBean.java index 76e8212..39d3c88 100644 --- a/src/main/java/com/web/web_assignment/ProjectBean.java +++ b/src/main/java/com/web/web_assignment/ProjectBean.java @@ -33,10 +33,6 @@ public class ProjectBean implements Serializable { public List selectedKeywords; // List of selected keywords for the current project - private static String getJDBCurl() { - return "jdbc:derby:testDB;create=true"; - } - private List users; @PostConstruct @@ -44,9 +40,6 @@ public class ProjectBean implements Serializable { loadProjects(); // Load projects from the database System.out.println("Projects loaded: " + projects.size()); loadAllKeywords(); // Load all unique keywords from all projects - if (projects.isEmpty()) { - Project emptyProject = new Project("", "", "", new ArrayList<>(), "", new ArrayList<>(), "", ""); - } setProject(projects.get(0)); // Set the first project as the current project users = databaseService.getAllUsers(); } @@ -57,13 +50,9 @@ public class ProjectBean implements Serializable { } public void loadUserInfo() { - try { - UserInfo info = databaseService.getUserInfo(username); - if (info != null) { - userInfo = info; - } - } catch (SQLException e) { - e.printStackTrace(); + UserInfo info = databaseService.getUserInfo(username); + if (info != null) { + userInfo = info; } } @@ -71,7 +60,7 @@ public class ProjectBean implements Serializable { try { databaseService.updateUserInfo(username, userInfo); } catch (SQLException e) { - e.printStackTrace(); +// e.printStackTrace(); } } @@ -122,11 +111,6 @@ public class ProjectBean implements Serializable { projects.add(project); } - public String loadProject(String title) { - project = projects.stream().filter(p -> p.getTitle().equals(title)).findFirst().orElse(null); - return "project.xhtml?faces-redirect=true"; - } - public String saveProject() { FacesContext context = FacesContext.getCurrentInstance(); @@ -152,7 +136,7 @@ public class ProjectBean implements Serializable { loadAllKeywords(); } catch (SQLException e) { context.addMessage("saveButton", new FacesMessage(FacesMessage.SEVERITY_ERROR, "Submission Failed", null)); - e.printStackTrace(); +// e.printStackTrace(); } return "project"; } @@ -196,7 +180,7 @@ public class ProjectBean implements Serializable { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Login failed", null)); FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("username"); isLoggedIn = false; - e.printStackTrace(); +// e.printStackTrace(); return "login"; } } @@ -243,14 +227,6 @@ public class ProjectBean implements Serializable { return project != null ? String.join(", ", project.getCollaborators()) : ""; } - public String getProjectKeywords() { - return projectKeywords; - } - - public void setProjectKeywords(String projectKeywords) { - this.projectKeywords = projectKeywords; - } - public String getProjectCollaborators() { return projectCollaborators; } diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 06f6af7..10d84ac 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -28,8 +28,4 @@ index.jsf - - - org.jboss.weld.environment.servlet.Listener - \ No newline at end of file diff --git a/src/main/webapp/header.xhtml b/src/main/webapp/header.xhtml index aea42a3..ac41fdb 100644 --- a/src/main/webapp/header.xhtml +++ b/src/main/webapp/header.xhtml @@ -1,7 +1,7 @@ +>