View Javadoc

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.versionmanagement.dto.VersionDisplayInfo;
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.statement.ui.client.widgets.rules.ReqComponentInfoUi;
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  public class StatementDataService implements StatementRpcService{
27  	final static Logger LOG = Logger.getLogger(StatementDataService.class);
28      
29      
30      private StatementService statementService;
31      private LuService luService;
32      
33      private static final long serialVersionUID = 822326113643828855L;
34      @Override
35      @Transactional(readOnly=true)
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          // loop through top statement types like enrollment eligibility and credit constraints
43          for (String topStatementType : topStatementTypes) {           
44              allStatementTypes.add(statementService.getStatementType(topStatementType));
45              List<String> subStatementTypeNames = statementService.getStatementTypesForStatementType(topStatementType);
46  
47              // loop through statement types belonging to the top statement types
48              for (String subStatementTypeName : subStatementTypeNames) {
49                  allStatementTypes.add(statementService.getStatementType(subStatementTypeName));
50              }
51          }
52          
53          return allStatementTypes;
54      }
55      
56      @Override
57      @Transactional(readOnly=true)
58      public List<StatementTypeInfo> getStatementTypesForStatementType(String statementTypeKey) throws Exception {
59          List<String> statementTypeNames = statementService.getStatementTypesForStatementType(statementTypeKey);
60          List<StatementTypeInfo> statementTypes = new ArrayList<StatementTypeInfo>();
61          for (String statementTypeName : statementTypeNames) {
62              statementTypes.add(statementService.getStatementType(statementTypeName));
63          }
64          return statementTypes;
65      }
66      @Override
67      @Transactional(readOnly=true)
68      public List<ReqComponentTypeInfo> getReqComponentTypesForStatementType(String luStatementTypeKey) throws Exception {
69  
70          List<ReqComponentTypeInfo> reqComponentTypeInfoList;
71          try { 
72              reqComponentTypeInfoList = statementService.getReqComponentTypesForStatementType(luStatementTypeKey);
73          } catch (Exception ex) {
74              LOG.error(ex);
75              throw new Exception("Unable to find Requirement Component Types based on LU Statement Type Key:" + luStatementTypeKey, ex);
76          }
77          
78          return reqComponentTypeInfoList;
79      }
80  
81      @Override
82      @Transactional(readOnly=true)
83      public String translateStatementTreeViewToNL(StatementTreeViewInfo statementTreeViewInfo, String nlUsageTypeKey, String language) throws Exception {
84          return statementService.translateStatementTreeViewToNL(statementTreeViewInfo, nlUsageTypeKey, language);
85      }
86  
87      @Override
88      @Transactional(readOnly=true)
89      public String translateReqComponentToNL(ReqComponentInfo reqComponentInfo, String nlUsageTypeKey, String language) throws Exception {
90          return statementService.translateReqComponentToNL(reqComponentInfo, nlUsageTypeKey, language);
91      }
92  
93      @Override
94      @Transactional(readOnly=true)
95      public List<String> translateReqComponentToNLs(ReqComponentInfoUi reqComponentInfo, String[] nlUsageTypeKeys, String language) throws Exception {
96      	List<String> nls = new ArrayList<String>(nlUsageTypeKeys.length);
97      	for (String typeKey : nlUsageTypeKeys) {
98      		nls.add(statementService.translateReqComponentToNL(reqComponentInfo, typeKey, language));
99      	}
100     	return nls;
101     }
102 
103     @Override
104     @Transactional(readOnly=true)
105     public CluInfo getClu(String cluId) throws Exception {
106         return luService.getClu(cluId);
107     }
108 
109     @Override
110     @Transactional(readOnly=true)
111     public VersionDisplayInfo getCurrentVersion(String refObjectTypeURI, String refObjectId) throws Exception {
112         return luService.getCurrentVersion(refObjectTypeURI, refObjectId);
113     }
114 
115     public void setStatementService(StatementService statementService) {
116         this.statementService = statementService;
117     }
118 
119     public void setLuService(LuService luService) {
120         this.luService = luService;
121     }
122 
123 	@Override
124 	public List<String> getObjectTypes() {
125 		throw new UnsupportedOperationException();
126 	}
127 
128 	@Override
129 	public ObjectStructure getObjectStructure(String objectTypeKey) {
130 		throw new UnsupportedOperationException();
131 	}
132 
133 	@Override
134 	public List<SearchTypeInfo> getSearchTypes() {
135 		throw new UnsupportedOperationException();
136 	}
137 
138 	@Override
139 	public SearchTypeInfo getSearchType(String searchTypeKey) {
140 		throw new UnsupportedOperationException();
141 	}
142 
143 	@Override
144 	public List<SearchTypeInfo> getSearchTypesByResult(
145 			String searchResultTypeKey) {
146 		throw new UnsupportedOperationException();
147 	}
148 
149 	@Override
150 	public List<SearchTypeInfo> getSearchTypesByCriteria(
151 			String searchCriteriaTypeKey) {
152 		throw new UnsupportedOperationException();
153 	}
154 
155 	@Override
156 	public List<SearchResultTypeInfo> getSearchResultTypes() {
157 		throw new UnsupportedOperationException();
158 	}
159 
160 	@Override
161 	public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey) {
162 		throw new UnsupportedOperationException();
163 	}
164 
165 	@Override
166 	public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes() {
167 		throw new UnsupportedOperationException();
168 	}
169 
170 	@Override
171 	public SearchCriteriaTypeInfo getSearchCriteriaType(
172 			String searchCriteriaTypeKey) {
173 		throw new UnsupportedOperationException();
174 	}
175 
176 	@Override
177 	public SearchResult search(SearchRequest searchRequest) {
178 		throw new UnsupportedOperationException();
179 	}
180 }