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