You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.4 KiB
66 lines
2.4 KiB
package core.process;
|
|
import core.user.User;
|
|
import dao.DBManagement;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
public class ProcessManagement {
|
|
public static Condition getCondition(User user) throws Exception {
|
|
Map<String,String> status = getStatus(user);
|
|
return getCondition(user,status);
|
|
}
|
|
public static Condition getCondition(User user, Map<String, String> status){
|
|
Condition condition = new Condition();
|
|
for(Map.Entry<String,String> entry:status.entrySet()){
|
|
String[] s = entry.getKey().split(".");
|
|
TempProcess tempProcess = (TempProcess) getProcess(s[1]);
|
|
tempProcess.setGraduationDesignId(s[0]);
|
|
tempProcess.setStatus(entry.getValue());
|
|
condition.add(tempProcess);
|
|
}
|
|
condition.add(getLastProcesses(user));
|
|
return condition;
|
|
}
|
|
|
|
private static List<Process> getLastProcesses(User user) {
|
|
return null;
|
|
}
|
|
|
|
//Map<graduation_design_id.x_status,status>
|
|
public static Map<String,String> getStatus(User user) throws Exception {
|
|
Map<String, String> status = new HashMap<>();
|
|
Map<String,String> userTables = DBManagement.getUserStatusTables(user.getType());
|
|
String graduationDesignId = null;
|
|
for(Map.Entry<String,String> entry:userTables.entrySet()){
|
|
String[] ti = entry.getKey().split("\\.");
|
|
String[] ts = entry.getValue().split("\\.");
|
|
List<String> ls = new ArrayList<>();
|
|
ls.add("id");
|
|
Map<String,String> limits = new HashMap<>();
|
|
limits.put(ti[1],user.getId());
|
|
List<String[]> resultLs = DBManagement.select(ls,ti[0],limits,0,1);
|
|
if(resultLs.size()==0) continue;
|
|
graduationDesignId = resultLs.get(0)[0];
|
|
|
|
ls = new ArrayList<>();
|
|
ls.add(ts[1]);
|
|
limits = new HashMap<>();
|
|
limits.put("id",graduationDesignId);
|
|
resultLs = DBManagement.select(ls,ts[0],limits,0,1);
|
|
status.put(graduationDesignId+"."+ts[1],resultLs.get(0)[0]);
|
|
}
|
|
return status;
|
|
}
|
|
public static Process getProcess(String process){
|
|
switch (process){
|
|
case "finished_product_status":
|
|
return new C_StudentUploadFinishedProduct();
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
}
|