修复errors
This commit is contained in:
parent
6cdec726ca
commit
8ff882cdd0
@ -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;
|
||||
}
|
||||
|
||||
@ -33,10 +33,6 @@ public class ProjectBean implements Serializable {
|
||||
|
||||
public List<String> selectedKeywords; // List of selected keywords for the current project
|
||||
|
||||
private static String getJDBCurl() {
|
||||
return "jdbc:derby:testDB;create=true";
|
||||
}
|
||||
|
||||
private List<String> 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,21 +50,17 @@ public class ProjectBean implements Serializable {
|
||||
}
|
||||
|
||||
public void loadUserInfo() {
|
||||
try {
|
||||
UserInfo info = databaseService.getUserInfo(username);
|
||||
if (info != null) {
|
||||
userInfo = info;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateUserInfo() {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -28,8 +28,4 @@
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.jsf</welcome-file>
|
||||
</welcome-file-list>
|
||||
<!-- Weld listener -->
|
||||
<listener>
|
||||
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
|
||||
</listener>
|
||||
</web-app>
|
||||
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
>
|
||||
<h:head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user