1 | |
package org.kuali.student.lum.program.server; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.List; |
5 | |
|
6 | |
import org.apache.log4j.Logger; |
7 | |
import org.kuali.student.common.dictionary.old.dto.ObjectStructure; |
8 | |
import org.kuali.student.common.exceptions.DoesNotExistException; |
9 | |
import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo; |
10 | |
import org.kuali.student.common.search.dto.SearchRequest; |
11 | |
import org.kuali.student.common.search.dto.SearchResult; |
12 | |
import org.kuali.student.common.search.dto.SearchResultTypeInfo; |
13 | |
import org.kuali.student.common.search.dto.SearchTypeInfo; |
14 | |
import org.kuali.student.common.ui.client.widgets.rules.ReqComponentInfoUi; |
15 | |
import org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo; |
16 | |
import org.kuali.student.core.statement.dto.ReqComponentInfo; |
17 | |
import org.kuali.student.core.statement.dto.ReqComponentTypeInfo; |
18 | |
import org.kuali.student.core.statement.dto.StatementTreeViewInfo; |
19 | |
import org.kuali.student.core.statement.dto.StatementTypeInfo; |
20 | |
import org.kuali.student.core.statement.service.StatementService; |
21 | |
import org.kuali.student.lum.lu.dto.CluInfo; |
22 | |
import org.kuali.student.lum.lu.service.LuService; |
23 | |
import org.kuali.student.lum.program.client.rpc.StatementRpcService; |
24 | |
import org.springframework.transaction.annotation.Transactional; |
25 | |
|
26 | |
@Transactional(readOnly=true,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
27 | 0 | public class StatementDataService implements StatementRpcService{ |
28 | 0 | final static Logger LOG = Logger.getLogger(StatementDataService.class); |
29 | |
|
30 | |
|
31 | |
private StatementService statementService; |
32 | |
private LuService luService; |
33 | |
|
34 | |
private static final long serialVersionUID = 822326113643828855L; |
35 | |
@Override |
36 | |
public List<StatementTypeInfo> getStatementTypesForStatementTypeForCourse(String statementTypeKey) throws Exception { |
37 | |
|
38 | 0 | List<StatementTypeInfo> allStatementTypes = new ArrayList<StatementTypeInfo>(); |
39 | |
|
40 | 0 | List<String> topStatementTypes = statementService.getStatementTypesForStatementType(statementTypeKey); |
41 | |
|
42 | |
|
43 | 0 | for (String topStatementType : topStatementTypes) { |
44 | 0 | allStatementTypes.add(statementService.getStatementType(topStatementType)); |
45 | 0 | List<String> subStatementTypeNames = statementService.getStatementTypesForStatementType(topStatementType); |
46 | |
|
47 | |
|
48 | 0 | for (String subStatementTypeName : subStatementTypeNames) { |
49 | 0 | allStatementTypes.add(statementService.getStatementType(subStatementTypeName)); |
50 | |
} |
51 | 0 | } |
52 | |
|
53 | 0 | return allStatementTypes; |
54 | |
} |
55 | |
|
56 | |
@Override |
57 | |
public List<StatementTypeInfo> getStatementTypesForStatementType(String statementTypeKey) throws Exception { |
58 | 0 | List<String> statementTypeNames = statementService.getStatementTypesForStatementType(statementTypeKey); |
59 | 0 | List<StatementTypeInfo> statementTypes = new ArrayList<StatementTypeInfo>(); |
60 | 0 | for (String statementTypeName : statementTypeNames) { |
61 | 0 | statementTypes.add(statementService.getStatementType(statementTypeName)); |
62 | |
} |
63 | 0 | return statementTypes; |
64 | |
} |
65 | |
@Override |
66 | |
public List<ReqComponentTypeInfo> getReqComponentTypesForStatementType(String luStatementTypeKey) throws Exception { |
67 | |
|
68 | |
List<ReqComponentTypeInfo> reqComponentTypeInfoList; |
69 | |
try { |
70 | 0 | reqComponentTypeInfoList = statementService.getReqComponentTypesForStatementType(luStatementTypeKey); |
71 | 0 | } catch (Exception ex) { |
72 | 0 | LOG.error(ex); |
73 | 0 | throw new Exception("Unable to find Requirement Component Types based on LU Statement Type Key:" + luStatementTypeKey, ex); |
74 | 0 | } |
75 | |
|
76 | 0 | return reqComponentTypeInfoList; |
77 | |
} |
78 | |
|
79 | |
@Override |
80 | |
public String translateStatementTreeViewToNL(StatementTreeViewInfo statementTreeViewInfo, String nlUsageTypeKey, String language) throws Exception { |
81 | 0 | return statementService.translateStatementTreeViewToNL(statementTreeViewInfo, nlUsageTypeKey, language); |
82 | |
} |
83 | |
|
84 | |
@Override |
85 | |
public String translateReqComponentToNL(ReqComponentInfo reqComponentInfo, String nlUsageTypeKey, String language) throws Exception { |
86 | 0 | return statementService.translateReqComponentToNL(reqComponentInfo, nlUsageTypeKey, language); |
87 | |
} |
88 | |
|
89 | |
@Override |
90 | |
public List<String> translateReqComponentToNLs(ReqComponentInfoUi reqComponentInfo, String[] nlUsageTypeKeys, String language) throws Exception { |
91 | 0 | List<String> nls = new ArrayList<String>(nlUsageTypeKeys.length); |
92 | 0 | for (String typeKey : nlUsageTypeKeys) { |
93 | 0 | nls.add(statementService.translateReqComponentToNL(reqComponentInfo, typeKey, language)); |
94 | |
} |
95 | 0 | return nls; |
96 | |
} |
97 | |
|
98 | |
@Override |
99 | |
public CluInfo getClu(String cluId) throws Exception { |
100 | 0 | return luService.getClu(cluId); |
101 | |
} |
102 | |
|
103 | |
@Override |
104 | |
public VersionDisplayInfo getCurrentVersion(String refObjectTypeURI, String refObjectId) throws Exception { |
105 | 0 | return luService.getCurrentVersion(refObjectTypeURI, refObjectId); |
106 | |
} |
107 | |
|
108 | |
public void setStatementService(StatementService statementService) { |
109 | 0 | this.statementService = statementService; |
110 | 0 | } |
111 | |
|
112 | |
public void setLuService(LuService luService) { |
113 | 0 | this.luService = luService; |
114 | 0 | } |
115 | |
|
116 | |
@Override |
117 | |
public List<String> getObjectTypes() { |
118 | 0 | throw new UnsupportedOperationException(); |
119 | |
} |
120 | |
|
121 | |
@Override |
122 | |
public ObjectStructure getObjectStructure(String objectTypeKey) { |
123 | 0 | throw new UnsupportedOperationException(); |
124 | |
} |
125 | |
|
126 | |
@Override |
127 | |
public List<SearchTypeInfo> getSearchTypes() { |
128 | 0 | throw new UnsupportedOperationException(); |
129 | |
} |
130 | |
|
131 | |
@Override |
132 | |
public SearchTypeInfo getSearchType(String searchTypeKey) { |
133 | 0 | throw new UnsupportedOperationException(); |
134 | |
} |
135 | |
|
136 | |
@Override |
137 | |
public List<SearchTypeInfo> getSearchTypesByResult( |
138 | |
String searchResultTypeKey) { |
139 | 0 | throw new UnsupportedOperationException(); |
140 | |
} |
141 | |
|
142 | |
@Override |
143 | |
public List<SearchTypeInfo> getSearchTypesByCriteria( |
144 | |
String searchCriteriaTypeKey) { |
145 | 0 | throw new UnsupportedOperationException(); |
146 | |
} |
147 | |
|
148 | |
@Override |
149 | |
public List<SearchResultTypeInfo> getSearchResultTypes() { |
150 | 0 | throw new UnsupportedOperationException(); |
151 | |
} |
152 | |
|
153 | |
@Override |
154 | |
public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey) { |
155 | 0 | throw new UnsupportedOperationException(); |
156 | |
} |
157 | |
|
158 | |
@Override |
159 | |
public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes() { |
160 | 0 | throw new UnsupportedOperationException(); |
161 | |
} |
162 | |
|
163 | |
@Override |
164 | |
public SearchCriteriaTypeInfo getSearchCriteriaType( |
165 | |
String searchCriteriaTypeKey) { |
166 | 0 | throw new UnsupportedOperationException(); |
167 | |
} |
168 | |
|
169 | |
@Override |
170 | |
public SearchResult search(SearchRequest searchRequest) { |
171 | 0 | throw new UnsupportedOperationException(); |
172 | |
} |
173 | |
} |