diff --git a/.idea/dataSources/356b1cbb-8e8d-401f-bdfc-b3e917bc8301.xml b/.idea/dataSources/356b1cbb-8e8d-401f-bdfc-b3e917bc8301.xml
index b94984a..bd4fedb 100644
--- a/.idea/dataSources/356b1cbb-8e8d-401f-bdfc-b3e917bc8301.xml
+++ b/.idea/dataSources/356b1cbb-8e8d-401f-bdfc-b3e917bc8301.xml
@@ -1315,11 +1315,844 @@
utf8mb4
0
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ char(255)|0s
+ 1
+ normal
+
+
+ 3
+ char(30)|0s
+ normal
+
+
+ 4
+ char(40)|0s
+ normal
+
+
+ 5
+ char(20)|0s
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ text|0s
+ normal
+
+
+ 3
+ text|0s
+ normal
+
+
+ 4
+ date|0s
+ normal
+
+
+ 5
+ varchar(255)|0s
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ char(20)|0s
+ normal
+
+
+ 3
+ char(20)|0s
+ normal
+
+
+ 4
+ varchar(255)|0s
+ normal
+
+
+ 5
+ float|0s
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ int(11)|0s
+ normal
+
+
+ 3
+ date|0s
+ normal
+
+
+ 4
+ varchar(255)|0s
+ normal
+
+
+ 5
+ text|0s
+ normal
+
+
+ 6
+ text|0s
+ normal
+
+
+ 7
+ text|0s
+ normal
+
+
+ 8
+ text|0s
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ float|0s
+ normal
+
+
+ 3
+ float|0s
+ normal
+
+
+ 4
+ float|0s
+ normal
+
+
+ 5
+ float|0s
+ normal
+
+
+ 6
+ float|0s
+ normal
+
+
+ 7
+ float|0s
+ normal
+
+
+ 8
+ float|0s
+ normal
+
+
+ 9
+ float|0s
+ normal
+
+
+ 10
+ float|0s
+ normal
+
+
+ 11
+ float|0s
+ normal
+
+
+ 12
+ float|0s
+ normal
+
+
+ 13
+ float|0s
+ normal
+
+
+ 14
+ float|0s
+ normal
+
+
+ 15
+ float|0s
+ normal
+
+
+ 16
+ float|0s
+ normal
+
+
+ 17
+ text|0s
+ normal
+
+
+ 18
+ date|0s
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ float|0s
+ normal
+
+
+ 3
+ text|0s
+ normal
+
+
+ 4
+ date|0s
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ varchar(255)|0s
+ normal
+
+
+ 3
+ varchar(255)|0s
+ normal
+
+
+ 4
+ varchar(255)|0s
+ normal
+
+
+ 5
+ varchar(255)|0s
+ normal
+
+
+ 6
+ text|0s
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ date|0s
+ normal
+
+
+ 3
+ varchar(255)|0s
+ normal
+
+
+ 4
+ varchar(255)|0s
+ normal
+
+
+ 5
+ char(20)|0s
+ normal
+
+
+ 6
+ char(20)|0s
+ normal
+
+
+ 7
int(11)|0s
normal
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ text|0s
+ normal
+
+
+ 3
+ date|0s
+ normal
+
+
+ 4
+ text|0s
+ normal
+
+
+ 5
+ date|0s
+ normal
+
+
+ 6
+ text|0s
+ normal
+
+
+ 7
+ date|0s
+ normal
+
+
+ 8
+ text|0s
+ normal
+
+
+ 9
+ date|0s
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ date|0s
+ normal
+
+
+ 3
+ varchar(255)|0s
+ normal
+
+
+ 4
+ char(20)|0s
+ normal
+
+
+ 5
+ char(20)|0s
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ text|0s
+ normal
+
+
+ 3
+ date|0s
+ normal
+
+
+ 4
+ text|0s
+ normal
+
+
+ 5
+ date|0s
+ normal
+
+
+ 6
+ text|0s
+ normal
+
+
+ 7
+ float|0s
+ normal
+
+
+ 8
+ date|0s
+ normal
+
+
+ 9
+ text|0s
+ normal
+
+
+ 10
+ float|0s
+ normal
+
+
+ 11
+ date|0s
+ normal
+
+
+ 12
+ text|0s
+ normal
+
+
+ 13
+ float|0s
+ normal
+
+
+ 14
+ date|0s
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ char(1)|0s
+ normal
+
+
+ 3
+ char(1)|0s
+ normal
+
+
+ 4
+ char(1)|0s
+ normal
+
+
+ 5
+ char(1)|0s
+ normal
+
+
+ 6
+ char(1)|0s
+ normal
+
+
+ 7
+ char(1)|0s
+ normal
+
+
+ 8
+ char(1)|0s
+ normal
+
+
+ 9
+ char(1)|0s
+ normal
+
+
+ 10
+ char(1)|0s
+ normal
+
+
+ 11
+ char(1)|0s
+ normal
+
+
+ 12
+ char(1)|0s
+ normal
+
+
+ 13
+ char(1)|0s
+ normal
+
+
+ 14
+ char(1)|0s
+ normal
+
+
+ 15
+ char(1)|0s
+ normal
+
+
+ 16
+ char(1)|0s
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ char(20)|0s
+ normal
+
+
+ 3
+ char(20)|0s
+ normal
+
+
+ 1
+ leader_student_id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ char(20)|0s
+ normal
+
+
+ 3
+ char(20)|0s
+ normal
+
+
+ 1
+ leader_teacher_id
+ 1
+
+
+ 1
+ char(8)|0s
+ 1
+ normal
+
+
+ 2
+ varchar(255)|0s
+ normal
+
+
+ 3
+ varchar(255)|0s
+ normal
+
+
+ 4
+ varchar(255)|0s
+ normal
+
+
+ 1
+ profession_code
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ char(20)|0s
+ normal
+
+
+ 3
+ char(20)|0s
+ normal
+
+
+ 1
+ leader_student_id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ char(20)|0s
+ normal
+
+
+ 3
+ char(20)|0s
+ normal
+
+
+ 1
+ leader_teacher_id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ char(255)|0s
+ 1
+ normal
+
+
+ 3
+ char(30)|0s
+ normal
+
+
+ 4
+ char(40)|0s
+ normal
+
+
+ 5
+ char(20)|0s
+ normal
+
+
+ 6
+ char(8)|0s
+ normal
+
+
+ 7
+ char(4)|0s
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ char(20)|0s
+ 1
+ normal
+
+
+ 2
+ char(255)|0s
+ 1
+ normal
+
+
+ 3
+ char(30)|0s
+ normal
+
+
+ 4
+ char(40)|0s
+ normal
+
+
+ 5
+ char(20)|0s
+ normal
+
+
+ 6
+ char(8)|0s
+ normal
+
+
+ 7
+ varchar(255)|0s
+ normal
+
+
+ 8
+ varchar(255)|0s
+ normal
+
+
+ 1
+ id
+ 1
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 0548357..11bca97 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/deployment/init.sql b/deployment/init.sql
deleted file mode 100644
index e379d84..0000000
--- a/deployment/init.sql
+++ /dev/null
@@ -1 +0,0 @@
-CREATE DATABASE `GDMS`;
\ No newline at end of file
diff --git a/src/core/process/Process.java b/src/core/process/Process.java
index 966aa17..bcdf14f 100644
--- a/src/core/process/Process.java
+++ b/src/core/process/Process.java
@@ -5,14 +5,19 @@ import core.user.User;
import error.GExcptFactory;
import error.GExcptSQL;
-public abstract class Process {
+public abstract class Process implements Cloneable{
private String permission;
private Operation operation;
private String buttonName;
private String info;
private String processOptions;
-
+ private String UserOptions;
+ @Override
+ public Process clone(){
+ //todo
+ return null;
+ }
public Process(String permission, String operationName, String processOptions, String info) throws Exception {
super();
this.setPermission(permission);
diff --git a/src/core/process/ProcessManagement.java b/src/core/process/ProcessManagement.java
index 7223a47..aafefa0 100644
--- a/src/core/process/ProcessManagement.java
+++ b/src/core/process/ProcessManagement.java
@@ -12,7 +12,7 @@ public class ProcessManagement {
//todo
}
public Process getTemporaryProcess(int index){
- return temporaryProcesses.get(index);
+ return temporaryProcesses.get(index).clone();
}
public Condition getCondition(String userType, List index){
Condition condition = new Condition(this.lastProcesses.get(userType));
diff --git a/src/core/user/User.java b/src/core/user/User.java
index 8048293..5c34eb0 100644
--- a/src/core/user/User.java
+++ b/src/core/user/User.java
@@ -10,8 +10,60 @@ public abstract class User implements AccountManageable, ProcessConfigurable{
private String id;
private String password;
- private List permissions = null;
+ private String name;
+ private String e_mail_location;
+ private String phone_number;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getE_mail_location() {
+ return e_mail_location;
+ }
+
+ public void setE_mail_location(String e_mail_location) {
+ this.e_mail_location = e_mail_location;
+ }
+
+ public String getPhone_number() {
+ return phone_number;
+ }
+
+ public void setPhone_number(String phone_number) {
+ this.phone_number = phone_number;
+ }
+
+ public List getPermissions() {
+ return permissions;
+ }
+
+ public void setPermissions(List permissions) {
+ this.permissions = permissions;
+ }
+
+ private String phonenumber;
+ private List permissions = null;
public Condition getCondition() {
return condition;
}
diff --git a/src/core/user/utils/AccountManagement.java b/src/core/user/utils/AccountManagement.java
index 8c8df7a..cdb726f 100644
--- a/src/core/user/utils/AccountManagement.java
+++ b/src/core/user/utils/AccountManagement.java
@@ -1,12 +1,47 @@
package core.user.utils;
import core.user.User;
+import dao.DBManagement;
+import error.GExcptAccount;
+import error.GExcptSQL;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.List;
public interface AccountManagement {
- static User login(String id, String password){
- //todo
+ static String[] userTables = {
+ "administrator",
+ "student",
+ "teacher"
+ };
+ static User login(String id, String password) throws GExcptSQL, GExcptAccount {
+ ResultSet rs = null;
+ String sql = null;
+ String userType = null;
+ for(String userTable:userTables){
+ sql = "SELECT * FROM "+userTable+"WHERE id="+id;
+ try {
+ rs = DBManagement.query(sql);
+ } catch (Exception e) {
+ throw new GExcptSQL("QUERY\n\t"+sql+"\nfailure");
+ }
+ if(rs!=null){
+ userType = userTable;
+ break;
+ }
+ }
+ if(rs==null){
+ throw new GExcptAccount("id "+id+"don't exists");
+ }
+ try {
+ if(rs.getString("password")!=password)
+ throw new GExcptAccount("password wrong");
+ return createUser(userType,rs);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
return null;
}
static User register(List necessaryInfo, String User){
@@ -19,4 +54,32 @@ public interface AccountManagement {
static void destroy(User user){
//todo
}
+ static User getUser(String userType){
+ try {
+ return (User)Class.forName("core.user."+userType).getDeclaredConstructor().newInstance();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+ static User createUser(String userType, ResultSet rs) {
+ User user = getUser(userType);
+ try {
+ user.setId(rs.getString("id"));
+ user.setName(rs.getString("name"));
+ user.setE_mail_location(rs.getString("e_mail_location"));
+ user.setPhone_number(rs.getString("phone_number"));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return user;
+ }
}
diff --git a/src/error/GExcptAccount.java b/src/error/GExcptAccount.java
new file mode 100644
index 0000000..bef9348
--- /dev/null
+++ b/src/error/GExcptAccount.java
@@ -0,0 +1,8 @@
+package error;
+
+public class GExcptAccount extends GExcpt{
+
+ public GExcptAccount(String info) {
+ super(info);
+ }
+}
diff --git a/src/init/Init.java b/src/init/Init.java
index 3d42bad..0e284b7 100644
--- a/src/init/Init.java
+++ b/src/init/Init.java
@@ -1,7 +1,6 @@
package init;
import dao.DBManagement;
-import gdms.test;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
@@ -14,7 +13,6 @@ import java.io.IOException;
public class Init extends HttpServlet {
public void init(){
DBManagement.init();
- new test();
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {