1 | |
package org.kuali.student.lum.lu.ui.dependency.server; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.List; |
5 | |
|
6 | |
import org.kuali.student.core.statement.dto.ReqComponentInfo; |
7 | |
import org.kuali.student.core.statement.dto.StatementTreeViewInfo; |
8 | |
import org.kuali.student.core.statement.service.StatementService; |
9 | |
import org.kuali.student.core.statement.ui.client.widgets.rules.ReqComponentInfoUi; |
10 | |
import org.kuali.student.core.statement.ui.client.widgets.rules.RulesUtil; |
11 | |
import org.kuali.student.lum.lu.ui.dependency.client.service.DependencyAnalysisRpcService; |
12 | |
import org.kuali.student.lum.program.dto.ProgramRequirementInfo; |
13 | |
import org.kuali.student.lum.program.service.ProgramService; |
14 | |
|
15 | |
import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
16 | |
|
17 | 0 | public class DependencyAnalysisRpcServlet extends RemoteServiceServlet implements DependencyAnalysisRpcService{ |
18 | |
|
19 | |
private static final long serialVersionUID = 1L; |
20 | |
|
21 | |
StatementService statementService; |
22 | |
ProgramService programService; |
23 | |
|
24 | |
@Override |
25 | |
public String getRequirementComponentNL(String reqComponentId) { |
26 | 0 | return null; |
27 | |
} |
28 | |
|
29 | |
@Override |
30 | |
public List<String> getRequirementComponentNL(List<String> reqComponentIds) throws Exception{ |
31 | 0 | List<String> reqComponents = new ArrayList<String>(); |
32 | 0 | for (String reqComponentId:reqComponentIds){ |
33 | 0 | String reqCompNL = statementService.getNaturalLanguageForReqComponent(reqComponentId, "KUALI.RULE", "en"); |
34 | 0 | reqComponents.add(reqCompNL); |
35 | 0 | } |
36 | |
|
37 | 0 | return reqComponents; |
38 | |
} |
39 | |
|
40 | |
|
41 | |
@Override |
42 | |
public ProgramRequirementInfo getProgramRequirement(String reqId) throws Exception { |
43 | 0 | ProgramRequirementInfo programRequirementInfo = programService.getProgramRequirement(reqId, null, null); |
44 | |
|
45 | 0 | setProgReqNL(programRequirementInfo); |
46 | 0 | return programRequirementInfo; |
47 | |
} |
48 | |
|
49 | |
public StatementService getStatementService() { |
50 | 0 | return statementService; |
51 | |
} |
52 | |
|
53 | |
public void setStatementService(StatementService statementService) { |
54 | 0 | this.statementService = statementService; |
55 | 0 | } |
56 | |
|
57 | |
public ProgramService getProgramService() { |
58 | 0 | return programService; |
59 | |
} |
60 | |
|
61 | |
public void setProgramService(ProgramService programService) { |
62 | 0 | this.programService = programService; |
63 | 0 | } |
64 | |
|
65 | |
private void setProgReqNL(ProgramRequirementInfo programRequirementInfo) throws Exception { |
66 | 0 | setReqCompNL(programRequirementInfo.getStatement()); |
67 | 0 | } |
68 | |
|
69 | |
private void setReqCompNL(StatementTreeViewInfo tree) throws Exception { |
70 | 0 | List<StatementTreeViewInfo> statements = tree.getStatements(); |
71 | 0 | List<ReqComponentInfo> reqComponentInfos = tree.getReqComponents(); |
72 | |
|
73 | 0 | if ((statements != null) && (statements.size() > 0)) { |
74 | |
|
75 | 0 | for (StatementTreeViewInfo statement : statements) { |
76 | 0 | setReqCompNL(statement); |
77 | |
} |
78 | 0 | } else if ((reqComponentInfos != null) && (reqComponentInfos.size() > 0)) { |
79 | |
|
80 | 0 | for (int i = 0; i < reqComponentInfos.size(); i++) { |
81 | 0 | ReqComponentInfoUi reqUi = RulesUtil.clone(reqComponentInfos.get(i)); |
82 | 0 | reqUi.setNaturalLanguageTranslation(statementService.translateReqComponentToNL(reqUi, "KUALI.RULE", "en")); |
83 | 0 | reqUi.setPreviewNaturalLanguageTranslation(statementService.translateReqComponentToNL(reqUi, "KUALI.RULE.PREVIEW", "en")); |
84 | 0 | reqComponentInfos.set(i, reqUi); |
85 | |
} |
86 | |
} |
87 | 0 | } |
88 | |
|
89 | |
} |