1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
package org.kuali.student.r2.core.class1.organization.service.impl; |
10 | |
|
11 | |
import java.util.ArrayList; |
12 | |
import java.util.HashSet; |
13 | |
import java.util.List; |
14 | |
import java.util.Set; |
15 | |
|
16 | |
import javax.jws.WebService; |
17 | |
|
18 | |
import org.apache.log4j.Logger; |
19 | |
import org.kuali.rice.core.api.criteria.GenericQueryResults; |
20 | |
import org.kuali.rice.core.api.criteria.QueryByCriteria; |
21 | |
import org.kuali.student.common.dictionary.old.dto.ObjectStructure; |
22 | |
import org.kuali.student.common.dictionary.service.old.DictionaryService; |
23 | |
import org.kuali.student.common.validator.old.Validator; |
24 | |
import org.kuali.student.core.organization.dao.OrganizationDao; |
25 | |
import org.kuali.student.core.organization.entity.Org; |
26 | |
import org.kuali.student.core.organization.entity.OrgHierarchy; |
27 | |
import org.kuali.student.core.organization.entity.OrgOrgRelation; |
28 | |
import org.kuali.student.core.organization.entity.OrgOrgRelationType; |
29 | |
import org.kuali.student.core.organization.entity.OrgPersonRelation; |
30 | |
import org.kuali.student.core.organization.entity.OrgPersonRelationType; |
31 | |
import org.kuali.student.core.organization.entity.OrgPositionRestriction; |
32 | |
import org.kuali.student.core.organization.entity.OrgType; |
33 | |
import org.kuali.student.r2.common.criteria.CriteriaLookupService; |
34 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
35 | |
import org.kuali.student.r2.common.dto.StatusInfo; |
36 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
37 | |
import org.kuali.student.r2.common.exceptions.DataValidationErrorException; |
38 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
39 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
40 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
41 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
42 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
43 | |
import org.kuali.student.r2.common.exceptions.ReadOnlyException; |
44 | |
import org.kuali.student.r2.common.exceptions.VersionMismatchException; |
45 | |
import org.kuali.student.r2.core.class1.organization.dao.ExtendedOrgDao; |
46 | |
import org.kuali.student.r2.core.organization.dto.OrgHierarchyInfo; |
47 | |
import org.kuali.student.r2.core.organization.dto.OrgInfo; |
48 | |
import org.kuali.student.r2.core.organization.dto.OrgOrgRelationInfo; |
49 | |
import org.kuali.student.r2.core.organization.dto.OrgPersonRelationInfo; |
50 | |
import org.kuali.student.r2.core.organization.dto.OrgPositionRestrictionInfo; |
51 | |
import org.kuali.student.r2.core.organization.dto.OrgTreeInfo; |
52 | |
import org.kuali.student.r2.core.organization.service.OrganizationService; |
53 | |
import org.kuali.student.r2.core.type.dto.TypeInfo; |
54 | |
import org.springframework.transaction.annotation.Transactional; |
55 | |
|
56 | |
@WebService(endpointInterface = "org.kuali.student.core.organization.service.OrganizationService", serviceName = "OrganizationService", portName = "OrganizationService", targetNamespace = "http://student.kuali.org/wsdl/organization") |
57 | |
@Transactional(readOnly = true, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
58 | 0 | public class OrganizationServiceImpl implements OrganizationService { |
59 | |
|
60 | 0 | final Logger logger = Logger.getLogger(OrganizationServiceImpl.class); |
61 | |
|
62 | |
private OrganizationDao organizationDao; |
63 | |
private ExtendedOrgDao extendedOrgDao; |
64 | |
private DictionaryService dictionaryServiceDelegate; |
65 | |
private Validator validator; |
66 | |
private CriteriaLookupService criteriaLookupService; |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
private void checkForMissingParameter(Object param, String paramName) throws MissingParameterException { |
77 | 0 | if (param == null) { |
78 | 0 | throw new MissingParameterException(paramName + " can not be null"); |
79 | |
} |
80 | 0 | } |
81 | |
|
82 | |
public DictionaryService getDictionaryServiceDelegate() { |
83 | 0 | return dictionaryServiceDelegate; |
84 | |
} |
85 | |
|
86 | |
public void setDictionaryServiceDelegate(DictionaryService dictionaryServiceDelegate) { |
87 | 0 | this.dictionaryServiceDelegate = dictionaryServiceDelegate; |
88 | 0 | } |
89 | |
|
90 | |
public Validator getValidator() { |
91 | 0 | return validator; |
92 | |
} |
93 | |
|
94 | |
public void setValidator(Validator validator) { |
95 | 0 | this.validator = validator; |
96 | 0 | } |
97 | |
|
98 | |
public OrganizationDao getOrganizationDao() { |
99 | 0 | return organizationDao; |
100 | |
} |
101 | |
|
102 | |
public void setOrganizationDao(OrganizationDao organizationDao) { |
103 | 0 | this.organizationDao = organizationDao; |
104 | 0 | } |
105 | |
|
106 | |
public ExtendedOrgDao getExtendedOrgDao() { |
107 | 0 | return extendedOrgDao; |
108 | |
} |
109 | |
|
110 | |
public void setExtendedOrgDao(ExtendedOrgDao extendedOrgDao) { |
111 | 0 | this.extendedOrgDao = extendedOrgDao; |
112 | 0 | } |
113 | |
|
114 | |
public void setCriteriaLookupService(CriteriaLookupService criteriaLookupService) { |
115 | 0 | this.criteriaLookupService = criteriaLookupService; |
116 | 0 | } |
117 | |
|
118 | |
public CriteriaLookupService getCriteriaLookupService() { |
119 | 0 | return criteriaLookupService; |
120 | |
} |
121 | |
|
122 | |
@Override |
123 | |
public OrgHierarchyInfo getOrgHierarchy(String orgHierarchyId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
124 | 0 | checkForMissingParameter(orgHierarchyId, "orgHierarchyId"); |
125 | |
|
126 | |
try { |
127 | 0 | return OrganizationAssembler.toOrgHierarchyInfo(organizationDao.fetch(OrgHierarchy.class, orgHierarchyId)); |
128 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
129 | 0 | throw new DoesNotExistException(); |
130 | |
} |
131 | |
} |
132 | |
|
133 | |
@Override |
134 | |
public List<OrgHierarchyInfo> getOrgHierarchiesByIds(List<String> orgHierarchyIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
135 | 0 | checkForMissingParameter(orgHierarchyIds, "orgHierarchyIds"); |
136 | |
|
137 | 0 | List<OrgHierarchy> orgHierarchies = extendedOrgDao.getOrgHierarchiesByIds(orgHierarchyIds); |
138 | 0 | return OrganizationAssembler.toOrgHierarchyInfos(orgHierarchies); |
139 | |
} |
140 | |
|
141 | |
@Override |
142 | |
public List<String> getOrgHierarchyIdsByType(String orgHierarchyTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
143 | 0 | checkForMissingParameter(orgHierarchyTypeKey, "orgHierarchyTypeKey"); |
144 | |
|
145 | 0 | List<String> orgHierarchyIds = new ArrayList<String>(); |
146 | 0 | List<OrgHierarchy> orgHierarchies = extendedOrgDao.getOrgHierarchiesByType(orgHierarchyTypeKey); |
147 | |
|
148 | 0 | if (orgHierarchies != null){ |
149 | 0 | for (OrgHierarchy orgHierarchy : orgHierarchies){ |
150 | 0 | orgHierarchyIds.add(orgHierarchy.getId()); |
151 | |
} |
152 | |
} |
153 | |
|
154 | 0 | return orgHierarchyIds; |
155 | |
} |
156 | |
|
157 | |
@Override |
158 | |
public List<OrgHierarchyInfo> getOrgHierarchies(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
159 | 0 | return OrganizationAssembler.toOrgHierarchyInfos(organizationDao.find(OrgHierarchy.class)); |
160 | |
} |
161 | |
|
162 | |
@Override |
163 | |
public List<TypeInfo> getOrgTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
164 | 0 | return OrganizationAssembler.toOrgTypeInfos(organizationDao.find(OrgType.class)); |
165 | |
} |
166 | |
|
167 | |
@Override |
168 | |
public OrgInfo getOrg(String orgId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
169 | 0 | checkForMissingParameter(orgId, "orgId"); |
170 | |
|
171 | |
try { |
172 | 0 | return OrganizationAssembler.toOrgInfo(organizationDao.fetch(Org.class, orgId)); |
173 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
174 | 0 | throw new DoesNotExistException(); |
175 | |
} |
176 | |
} |
177 | |
|
178 | |
@Override |
179 | |
public List<OrgInfo> getOrgsByIds(List<String> orgIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
180 | 0 | checkForMissingParameter(orgIds, "orgIds"); |
181 | |
|
182 | 0 | List<Org> orgs = this.organizationDao.getOrganizationsByIdList(orgIds); |
183 | 0 | return OrganizationAssembler.toOrgInfos(orgs); |
184 | |
} |
185 | |
|
186 | |
@Override |
187 | |
public List<String> getOrgIdsByType(String orgTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
188 | 0 | checkForMissingParameter(orgTypeKey, "orgTypeKey"); |
189 | |
|
190 | 0 | List<String> orgIds = new ArrayList<String>(); |
191 | 0 | List<Org> orgs = extendedOrgDao.getOrgsByType(orgTypeKey); |
192 | |
|
193 | 0 | if (orgs != null){ |
194 | 0 | for (Org org : orgs){ |
195 | 0 | orgIds.add(org.getId()); |
196 | |
} |
197 | |
} |
198 | |
|
199 | 0 | return orgIds; |
200 | |
} |
201 | |
|
202 | |
@Override |
203 | |
public List<String> searchForOrgIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
204 | 0 | List<String> orgIds = new ArrayList<String>(); |
205 | 0 | List<OrgInfo> orgs = this.searchForOrgs(criteria, contextInfo); |
206 | |
|
207 | 0 | if (orgs != null) { |
208 | 0 | for (OrgInfo org : orgs) { |
209 | 0 | orgIds.add(org.getId()); |
210 | |
} |
211 | |
} |
212 | |
|
213 | 0 | return orgIds; |
214 | |
} |
215 | |
|
216 | |
@Override |
217 | |
public List<OrgInfo> searchForOrgs(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
218 | 0 | List<OrgInfo> orgInfos = new ArrayList<OrgInfo>(); |
219 | 0 | GenericQueryResults<Org> results = criteriaLookupService.lookup(Org.class, criteria); |
220 | |
|
221 | 0 | if (null != results && results.getResults().size() > 0) { |
222 | 0 | for (Org org : results.getResults()) { |
223 | 0 | orgInfos.add(OrganizationAssembler.toOrgInfo(org)); |
224 | |
} |
225 | |
} |
226 | |
|
227 | 0 | return orgInfos; |
228 | |
} |
229 | |
|
230 | |
@Override |
231 | |
public List<ValidationResultInfo> validateOrg(String validationTypeKey, String orgTypeKey, OrgInfo orgInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
232 | 0 | checkForMissingParameter(validationTypeKey, "validationTypeKey"); |
233 | 0 | checkForMissingParameter(orgInfo, "orgInfo"); |
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | 0 | return new ArrayList<ValidationResultInfo>(0); |
239 | |
} |
240 | |
|
241 | |
@Override |
242 | |
public OrgInfo createOrg(String orgTypeKey, OrgInfo orgInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
243 | |
|
244 | 0 | checkForMissingParameter(orgTypeKey, "orgTypeKey"); |
245 | 0 | checkForMissingParameter(orgInfo, "orgInfo"); |
246 | |
|
247 | |
|
248 | 0 | orgInfo.setTypeKey(orgTypeKey); |
249 | |
|
250 | |
try { |
251 | 0 | List<ValidationResultInfo> validations = validateOrg("", "", orgInfo, contextInfo); |
252 | 0 | for (ValidationResultInfo validationResult : validations) { |
253 | 0 | if (validationResult.isError()) |
254 | 0 | throw new DataValidationErrorException(validationResult.toString()); |
255 | |
} |
256 | 0 | } catch (DoesNotExistException e1) { |
257 | 0 | logger.error("Exception occured: ", e1); |
258 | 0 | } |
259 | |
|
260 | 0 | Org org = null; |
261 | |
|
262 | |
|
263 | |
try { |
264 | 0 | org = OrganizationAssembler.toOrg(false, orgInfo, organizationDao); |
265 | 0 | } catch (DoesNotExistException e) { |
266 | |
|
267 | 0 | logger.info(e.getMessage(), e); |
268 | 0 | throw new OperationFailedException(e.getMessage(), e); |
269 | 0 | } catch (VersionMismatchException e) { |
270 | |
|
271 | 0 | logger.info(e.getMessage(), e); |
272 | 0 | throw new OperationFailedException(e.getMessage(), e); |
273 | 0 | } |
274 | |
|
275 | |
|
276 | 0 | organizationDao.create(org); |
277 | |
|
278 | |
|
279 | 0 | OrgInfo createdOrgInfo = OrganizationAssembler.toOrgInfo(org); |
280 | 0 | return createdOrgInfo; |
281 | |
} |
282 | |
|
283 | |
@Override |
284 | |
public OrgInfo updateOrg(String orgId, OrgInfo orgInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
285 | |
|
286 | 0 | checkForMissingParameter(orgId, "orgId"); |
287 | 0 | checkForMissingParameter(orgInfo, "orgInfo"); |
288 | |
|
289 | |
|
290 | 0 | orgInfo.setId(orgId); |
291 | |
|
292 | 0 | Org org = null; |
293 | |
|
294 | |
|
295 | 0 | org = OrganizationAssembler.toOrg(true, orgInfo, organizationDao); |
296 | |
|
297 | |
|
298 | 0 | Org updatedOrg = organizationDao.update(org); |
299 | |
|
300 | |
|
301 | 0 | OrgInfo updatedOrgInfo = OrganizationAssembler.toOrgInfo(updatedOrg); |
302 | 0 | return updatedOrgInfo; |
303 | |
} |
304 | |
|
305 | |
@Override |
306 | |
public StatusInfo deleteOrg(String orgId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
307 | 0 | checkForMissingParameter(orgId, "orgId"); |
308 | |
|
309 | 0 | Org org = null; |
310 | |
try { |
311 | 0 | org = organizationDao.fetch(Org.class, orgId); |
312 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
313 | 0 | throw new DoesNotExistException(e.getMessage()); |
314 | 0 | } |
315 | |
|
316 | 0 | if (org == null) { |
317 | 0 | throw new DoesNotExistException("Org does not exist for id: " + orgId); |
318 | |
} |
319 | |
|
320 | 0 | organizationDao.delete(org); |
321 | |
|
322 | 0 | StatusInfo statusInfo = new StatusInfo(); |
323 | 0 | statusInfo.setSuccess(true); |
324 | 0 | return statusInfo; |
325 | |
} |
326 | |
|
327 | |
@Override |
328 | |
public List<TypeInfo> getOrgOrgRelationTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
329 | 0 | List<OrgOrgRelationType> orgOrgRelationTypes = organizationDao.find(OrgOrgRelationType.class); |
330 | 0 | return OrganizationAssembler.toOrgOrgRelationTypeInfos(orgOrgRelationTypes); |
331 | |
} |
332 | |
|
333 | |
@Override |
334 | |
public List<TypeInfo> getOrgOrgRelationTypesForOrgType(String orgTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
335 | 0 | checkForMissingParameter(orgTypeKey, "orgTypeKey"); |
336 | |
|
337 | 0 | List<OrgOrgRelationType> orgOrgRelationTypes = organizationDao.getOrgOrgRelationTypesForOrgType(orgTypeKey); |
338 | 0 | return OrganizationAssembler.toOrgOrgRelationTypeInfos(orgOrgRelationTypes); |
339 | |
} |
340 | |
|
341 | |
@Override |
342 | |
public List<TypeInfo> getOrgOrgRelationTypesForOrgHierarchy(String orgHierarchyId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
343 | 0 | checkForMissingParameter(orgHierarchyId, "orgHierarchyId"); |
344 | |
|
345 | 0 | List<OrgOrgRelationType> orgOrgRelationTypes = organizationDao.getOrgOrgRelationTypesForOrgHierarchy(orgHierarchyId); |
346 | 0 | return OrganizationAssembler.toOrgOrgRelationTypeInfos(orgOrgRelationTypes); |
347 | |
} |
348 | |
|
349 | |
@Override |
350 | |
public Boolean hasOrgOrgRelation(String orgId, String comparisonOrgId, String orgOrgRelationTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
351 | |
|
352 | 0 | checkForMissingParameter(orgId, "orgId"); |
353 | 0 | checkForMissingParameter(comparisonOrgId, "comparisonOrgId"); |
354 | 0 | checkForMissingParameter(orgOrgRelationTypeKey, "orgOrgRelationTypeKey"); |
355 | |
|
356 | 0 | boolean result = organizationDao.hasOrgOrgRelation(orgId, comparisonOrgId, orgOrgRelationTypeKey); |
357 | 0 | return Boolean.valueOf(result); |
358 | |
} |
359 | |
|
360 | |
@Override |
361 | |
public OrgOrgRelationInfo getOrgOrgRelation(String orgOrgRelationId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
362 | 0 | checkForMissingParameter(orgOrgRelationId, "orgOrgRelationId"); |
363 | |
|
364 | 0 | OrgOrgRelationInfo orgOrgRelationInfo = null; |
365 | |
try { |
366 | 0 | orgOrgRelationInfo = OrganizationAssembler.toOrgOrgRelationInfo(organizationDao.fetch(OrgOrgRelation.class, orgOrgRelationId)); |
367 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
368 | 0 | throw new DoesNotExistException(e.getMessage()); |
369 | 0 | } |
370 | 0 | return orgOrgRelationInfo; |
371 | |
} |
372 | |
|
373 | |
@Override |
374 | |
public List<OrgOrgRelationInfo> getOrgOrgRelationsByIds(List<String> orgOrgRelationIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
375 | 0 | checkForMissingParameter(orgOrgRelationIds, "orgOrgRelationIds"); |
376 | |
|
377 | 0 | List<OrgOrgRelation> orgOrgRelations = organizationDao.getOrgOrgRelationsByIdList(orgOrgRelationIds); |
378 | 0 | return OrganizationAssembler.toOrgOrgRelationInfos(orgOrgRelations); |
379 | |
} |
380 | |
|
381 | |
@Override |
382 | |
public List<String> getOrgOrgRelationIdsByType(String orgOrgRelationTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
383 | 0 | checkForMissingParameter(orgOrgRelationTypeKey, "orgOrgRelationTypeKey"); |
384 | |
|
385 | 0 | List<String> orgOrgRelationIds = new ArrayList<String>(); |
386 | 0 | List<OrgOrgRelation> orgOrgRelations = extendedOrgDao.getOrgOrgRelationsByType(orgOrgRelationTypeKey); |
387 | |
|
388 | 0 | if (orgOrgRelations != null){ |
389 | 0 | for(OrgOrgRelation orgOrgRelation : orgOrgRelations){ |
390 | 0 | orgOrgRelationIds.add(orgOrgRelation.getId()); |
391 | |
} |
392 | |
} |
393 | |
|
394 | 0 | return orgOrgRelationIds; |
395 | |
} |
396 | |
|
397 | |
@Override |
398 | |
public List<OrgOrgRelationInfo> getOrgOrgRelationsByOrg(String orgId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
399 | 0 | checkForMissingParameter(orgId, "orgId"); |
400 | |
|
401 | 0 | List<OrgOrgRelation> orgOrgRelations = organizationDao.getOrgOrgRelationsByOrg(orgId); |
402 | 0 | return OrganizationAssembler.toOrgOrgRelationInfos(orgOrgRelations); |
403 | |
} |
404 | |
|
405 | |
@Override |
406 | |
public List<OrgOrgRelationInfo> getOrgOrgRelationsByOrgs(String orgId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
407 | 0 | return this.getOrgOrgRelationsByOrg(orgId, contextInfo); |
408 | |
} |
409 | |
|
410 | |
@Override |
411 | |
public List<OrgOrgRelationInfo> getOrgOrgRelationsByTypeAndOrg(String orgId, String orgOrgRelationTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
412 | 0 | checkForMissingParameter(orgId, "orgId"); |
413 | 0 | checkForMissingParameter(orgOrgRelationTypeKey, "orgOrgRelationTypeKey"); |
414 | |
|
415 | 0 | List<OrgOrgRelation> orgOrgRelations = extendedOrgDao.getOrgOrgRelationsByTypeAndOrg(orgId, orgOrgRelationTypeKey); |
416 | 0 | return OrganizationAssembler.toOrgOrgRelationInfos(orgOrgRelations); |
417 | |
} |
418 | |
|
419 | |
@Override |
420 | |
public List<String> searchForOrgOrgRelationIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
421 | 0 | List<String> orgOrgRelationIds = new ArrayList<String>(); |
422 | 0 | List<OrgOrgRelationInfo> orgOrgRelations = this.searchForOrgOrgRelations(criteria, contextInfo); |
423 | |
|
424 | 0 | if (orgOrgRelations != null) { |
425 | 0 | for (OrgOrgRelationInfo orgOrgRelation : orgOrgRelations) { |
426 | 0 | orgOrgRelationIds.add(orgOrgRelation.getId()); |
427 | |
} |
428 | |
} |
429 | |
|
430 | 0 | return orgOrgRelationIds; |
431 | |
} |
432 | |
|
433 | |
@Override |
434 | |
public List<OrgOrgRelationInfo> searchForOrgOrgRelations(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
435 | 0 | List<OrgOrgRelationInfo> OrgOrgRelationInfos = new ArrayList<OrgOrgRelationInfo>(); |
436 | 0 | GenericQueryResults<OrgOrgRelation> results = criteriaLookupService.lookup(OrgOrgRelation.class, criteria); |
437 | |
|
438 | 0 | if (null != results && results.getResults().size() > 0) { |
439 | 0 | for (OrgOrgRelation orgOrgRelation : results.getResults()) { |
440 | 0 | OrgOrgRelationInfos.add(OrganizationAssembler.toOrgOrgRelationInfo(orgOrgRelation)); |
441 | |
} |
442 | |
} |
443 | |
|
444 | 0 | return OrgOrgRelationInfos; |
445 | |
} |
446 | |
|
447 | |
@Override |
448 | |
public List<ValidationResultInfo> validateOrgOrgRelation(String validationTypeKey, String orgId, String orgPeerId, String orgOrgRelationTypeKey, OrgOrgRelationInfo orgOrgRelationInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
449 | 0 | checkForMissingParameter(validationTypeKey, "validationTypeKey"); |
450 | 0 | checkForMissingParameter(orgOrgRelationInfo, "orgOrgRelationInfo"); |
451 | |
|
452 | |
|
453 | |
|
454 | |
|
455 | 0 | return null; |
456 | |
} |
457 | |
|
458 | |
@Override |
459 | |
public OrgOrgRelationInfo createOrgOrgRelation(String orgId, String orgPeerId, String orgOrgRelationTypeKey, OrgOrgRelationInfo orgOrgRelationInfo, ContextInfo contextInfo) throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
460 | |
|
461 | 0 | checkForMissingParameter(orgId, "orgId"); |
462 | 0 | checkForMissingParameter(orgPeerId, "orgPeerId"); |
463 | 0 | checkForMissingParameter(orgOrgRelationTypeKey, "orgOrgRelationTypeKey"); |
464 | 0 | checkForMissingParameter(orgOrgRelationInfo, "orgOrgRelationInfo"); |
465 | |
|
466 | |
|
467 | 0 | orgOrgRelationInfo.setOrgId(orgId); |
468 | 0 | orgOrgRelationInfo.setRelatedOrgId(orgPeerId); |
469 | 0 | orgOrgRelationInfo.setTypeKey(orgOrgRelationTypeKey); |
470 | |
|
471 | 0 | OrgOrgRelation orgOrgRelation = null; |
472 | |
|
473 | |
|
474 | |
try { |
475 | 0 | orgOrgRelation = OrganizationAssembler.toOrgOrgRelation(false, orgOrgRelationInfo, organizationDao); |
476 | 0 | } catch (VersionMismatchException e) {} |
477 | |
|
478 | |
|
479 | 0 | organizationDao.create(orgOrgRelation); |
480 | |
|
481 | |
|
482 | 0 | OrgOrgRelationInfo createdOrgOrgRelationInfo = OrganizationAssembler.toOrgOrgRelationInfo(orgOrgRelation); |
483 | 0 | return createdOrgOrgRelationInfo; |
484 | |
} |
485 | |
|
486 | |
@Override |
487 | |
public OrgOrgRelationInfo updateOrgOrgRelation(String orgOrgRelationId, OrgOrgRelationInfo orgOrgRelationInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
488 | |
|
489 | 0 | checkForMissingParameter(orgOrgRelationId, "orgOrgRelationId"); |
490 | 0 | checkForMissingParameter(orgOrgRelationId, "orgOrgRelationId"); |
491 | |
|
492 | |
|
493 | 0 | orgOrgRelationInfo.setId(orgOrgRelationId); |
494 | |
|
495 | 0 | OrgOrgRelation orgOrgRelation = null; |
496 | |
|
497 | |
|
498 | 0 | orgOrgRelation = OrganizationAssembler.toOrgOrgRelation(true, orgOrgRelationInfo, organizationDao); |
499 | |
|
500 | |
|
501 | 0 | OrgOrgRelation updatedOrgOrgRelation = organizationDao.update(orgOrgRelation); |
502 | |
|
503 | |
|
504 | 0 | OrgOrgRelationInfo updatedOrgOrgRelationInfo = OrganizationAssembler.toOrgOrgRelationInfo(updatedOrgOrgRelation); |
505 | 0 | return updatedOrgOrgRelationInfo; |
506 | |
} |
507 | |
|
508 | |
@Override |
509 | |
public StatusInfo deleteOrgOrgRelation(String orgOrgRelationId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
510 | 0 | checkForMissingParameter(orgOrgRelationId, "orgOrgRelationId"); |
511 | |
|
512 | |
try { |
513 | 0 | organizationDao.delete(OrgOrgRelation.class, orgOrgRelationId); |
514 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
515 | 0 | throw new DoesNotExistException(e.getMessage()); |
516 | 0 | } |
517 | 0 | return new StatusInfo(); |
518 | |
} |
519 | |
|
520 | |
@Override |
521 | |
public List<TypeInfo> getOrgPersonRelationTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
522 | 0 | List<OrgPersonRelationType> oprts = organizationDao.find(OrgPersonRelationType.class); |
523 | 0 | return OrganizationAssembler.toOrgPersonRelationTypeInfos(oprts); |
524 | |
} |
525 | |
|
526 | |
@Override |
527 | |
public List<TypeInfo> getOrgPersonRelationTypesForOrgType(String orgTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
528 | 0 | checkForMissingParameter(orgTypeKey, "orgTypeKey"); |
529 | |
|
530 | 0 | List<OrgPersonRelationType> oprts = organizationDao.getOrgPersonRelationTypesForOrgType(orgTypeKey); |
531 | 0 | return OrganizationAssembler.toOrgPersonRelationTypeInfos(oprts); |
532 | |
} |
533 | |
|
534 | |
@Override |
535 | |
public Boolean hasOrgPersonRelation(String orgId, String personId, String orgPersonRelationTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
536 | 0 | checkForMissingParameter(orgId, "orgId"); |
537 | 0 | checkForMissingParameter(personId, "personId"); |
538 | 0 | checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey"); |
539 | |
|
540 | 0 | return organizationDao.hasOrgPersonRelation(orgId, personId, orgPersonRelationTypeKey); |
541 | |
} |
542 | |
|
543 | |
@Override |
544 | |
public OrgPersonRelationInfo getOrgPersonRelation(String orgPersonRelationId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
545 | 0 | checkForMissingParameter(orgPersonRelationId, "orgPersonRelationId"); |
546 | |
|
547 | 0 | OrgPersonRelation opr = null; |
548 | |
try { |
549 | 0 | opr = organizationDao.fetch(OrgPersonRelation.class, orgPersonRelationId); |
550 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
551 | 0 | throw new DoesNotExistException(e.getMessage()); |
552 | 0 | } |
553 | 0 | return OrganizationAssembler.toOrgPersonRelationInfo(opr); |
554 | |
} |
555 | |
|
556 | |
@Override |
557 | |
public List<OrgPersonRelationInfo> getOrgPersonRelationsByIds(List<String> orgPersonRelationIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
558 | 0 | checkForMissingParameter(orgPersonRelationIds, "orgPersonRelationIds"); |
559 | |
|
560 | 0 | List<OrgPersonRelation> oprts = organizationDao.getOrgPersonRelationsByIdList(orgPersonRelationIds); |
561 | 0 | return OrganizationAssembler.toOrgPersonRelationInfos(oprts); |
562 | |
} |
563 | |
|
564 | |
@Override |
565 | |
public List<String> getOrgPersonRelationIdsByType(String orgPersonRelationTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
566 | 0 | checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey"); |
567 | |
|
568 | 0 | List<String> orgPersonRelationIds = new ArrayList<String>(); |
569 | 0 | List<OrgPersonRelation> orgPersonRelations = extendedOrgDao.getOrgPersonRelationsByType(orgPersonRelationTypeKey); |
570 | 0 | if (orgPersonRelations != null) { |
571 | 0 | for (OrgPersonRelation orgPersonRelation : orgPersonRelations) { |
572 | 0 | orgPersonRelationIds.add(orgPersonRelation.getId()); |
573 | |
} |
574 | |
} |
575 | |
|
576 | 0 | return orgPersonRelationIds; |
577 | |
} |
578 | |
|
579 | |
@Override |
580 | |
public List<OrgPersonRelationInfo> getOrgPersonRelationsByOrg(String orgId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
581 | 0 | checkForMissingParameter(orgId, "orgId"); |
582 | |
|
583 | 0 | List<OrgPersonRelation> relations = organizationDao.getAllOrgPersonRelationsByOrg(orgId); |
584 | 0 | return OrganizationAssembler.toOrgPersonRelationInfos(relations); |
585 | |
} |
586 | |
|
587 | |
@Override |
588 | |
public List<OrgPersonRelationInfo> getOrgPersonRelationsByTypeAndOrg(String orgPersonRelationTypeKey, String orgId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
589 | 0 | checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey"); |
590 | 0 | checkForMissingParameter(orgId, "orgId"); |
591 | |
|
592 | 0 | List<OrgPersonRelation> orgPersonRelations = extendedOrgDao.getOrgPersonRelationsByTypeAndOrg(orgPersonRelationTypeKey, orgId); |
593 | 0 | return OrganizationAssembler.toOrgPersonRelationInfos(orgPersonRelations); |
594 | |
} |
595 | |
|
596 | |
@Override |
597 | |
public List<OrgPersonRelationInfo> getOrgPersonRelationsByPerson(String personId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
598 | 0 | checkForMissingParameter(personId, "personId"); |
599 | |
|
600 | 0 | List<OrgPersonRelation> orgPersonRelations = extendedOrgDao.getOrgPersonRelationsByPerson(personId); |
601 | 0 | return OrganizationAssembler.toOrgPersonRelationInfos(orgPersonRelations); |
602 | |
} |
603 | |
|
604 | |
@Override |
605 | |
public List<OrgPersonRelationInfo> getOrgPersonRelationsByTypeAndPerson(String orgPersonRelationTypeKey, String personId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
606 | 0 | checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey"); |
607 | 0 | checkForMissingParameter(personId, "personId"); |
608 | |
|
609 | 0 | List<OrgPersonRelation> orgPersonRelations = extendedOrgDao.getOrgPersonRelationsByTypeAndPerson(orgPersonRelationTypeKey, personId); |
610 | 0 | return OrganizationAssembler.toOrgPersonRelationInfos(orgPersonRelations); |
611 | |
} |
612 | |
|
613 | |
@Override |
614 | |
public List<OrgPersonRelationInfo> getOrgPersonRelationsByOrgAndPerson(String orgId, String personId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
615 | 0 | checkForMissingParameter(orgId, "orgId"); |
616 | 0 | checkForMissingParameter(personId, "personId"); |
617 | |
|
618 | 0 | List<OrgPersonRelation> orgPersonRelations = extendedOrgDao.getOrgPersonRelationsByOrgAndPerson(orgId, personId); |
619 | 0 | return OrganizationAssembler.toOrgPersonRelationInfos(orgPersonRelations); |
620 | |
} |
621 | |
|
622 | |
@Override |
623 | |
public List<OrgPersonRelationInfo> getOrgPersonRelationsByTypeAndOrgAndPerson(String orgPersonRelationTypeKey, String orgId, String personId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
624 | 0 | checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey"); |
625 | 0 | checkForMissingParameter(orgId, "orgId"); |
626 | 0 | checkForMissingParameter(personId, "personId"); |
627 | |
|
628 | 0 | List<OrgPersonRelation> orgPersonRelations = extendedOrgDao.getOrgPersonRelationsByTypeAndOrgAndPerson(orgPersonRelationTypeKey, orgId, personId); |
629 | 0 | return OrganizationAssembler.toOrgPersonRelationInfos(orgPersonRelations); |
630 | |
} |
631 | |
|
632 | |
@Override |
633 | |
public List<String> searchForOrgPersonRelationIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
634 | 0 | List<String> orgPersonRelationIds = new ArrayList<String>(); |
635 | 0 | List<OrgPersonRelationInfo> orgPersonRelations = this.searchForOrgPersonRelations(criteria, contextInfo); |
636 | |
|
637 | 0 | if (orgPersonRelations != null) { |
638 | 0 | for (OrgPersonRelationInfo orgPersonRelation : orgPersonRelations) { |
639 | 0 | orgPersonRelationIds.add(orgPersonRelation.getId()); |
640 | |
} |
641 | |
} |
642 | |
|
643 | 0 | return orgPersonRelationIds; |
644 | |
} |
645 | |
|
646 | |
@Override |
647 | |
public List<OrgPersonRelationInfo> searchForOrgPersonRelations(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
648 | 0 | List<OrgPersonRelationInfo> orgPersonRelationInfos = new ArrayList<OrgPersonRelationInfo>(); |
649 | 0 | GenericQueryResults<OrgPersonRelation> results = criteriaLookupService.lookup(OrgPersonRelation.class, criteria); |
650 | |
|
651 | 0 | if (null != results && results.getResults().size() > 0) { |
652 | 0 | for (OrgPersonRelation orgPersonRelation : results.getResults()) { |
653 | 0 | orgPersonRelationInfos.add(OrganizationAssembler.toOrgPersonRelationInfo(orgPersonRelation)); |
654 | |
} |
655 | |
} |
656 | |
|
657 | 0 | return orgPersonRelationInfos; |
658 | |
} |
659 | |
|
660 | |
@Override |
661 | |
public List<ValidationResultInfo> validateOrgPersonRelation(String validationTypeKey, String orgId, String personId, String orgPersonRelationTypeKey, OrgPersonRelationInfo orgPersonRelationInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
662 | 0 | checkForMissingParameter(validationTypeKey, "validationTypeKey"); |
663 | |
|
664 | |
|
665 | |
|
666 | |
|
667 | 0 | return null; |
668 | |
} |
669 | |
|
670 | |
@Override |
671 | |
public OrgPersonRelationInfo createOrgPersonRelation(String orgId, String personId, String orgPersonRelationTypeKey, OrgPersonRelationInfo orgPersonRelationInfo, ContextInfo contextInfo) throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
672 | |
|
673 | 0 | checkForMissingParameter(orgId, "orgId"); |
674 | 0 | checkForMissingParameter(personId, "personId"); |
675 | 0 | checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey"); |
676 | 0 | checkForMissingParameter(orgPersonRelationTypeKey, "orgPersonRelationTypeKey"); |
677 | |
|
678 | |
|
679 | 0 | if (!organizationDao.validatePositionRestriction(orgId, orgPersonRelationTypeKey)) { |
680 | 0 | throw new InvalidParameterException("There is no Position for this relationship"); |
681 | |
} |
682 | |
|
683 | |
|
684 | 0 | orgPersonRelationInfo.setOrgId(orgId); |
685 | 0 | orgPersonRelationInfo.setPersonId(personId); |
686 | 0 | orgPersonRelationInfo.setTypeKey(orgPersonRelationTypeKey); |
687 | |
|
688 | 0 | OrgPersonRelation orgPersonRelation = null; |
689 | |
|
690 | |
|
691 | |
try { |
692 | 0 | orgPersonRelation = OrganizationAssembler.toOrgPersonRelation(false, orgPersonRelationInfo, organizationDao); |
693 | 0 | } catch (VersionMismatchException e) {} |
694 | |
|
695 | |
|
696 | 0 | organizationDao.create(orgPersonRelation); |
697 | |
|
698 | |
|
699 | 0 | OrgPersonRelationInfo createdOrgPersonRelationInfo = OrganizationAssembler.toOrgPersonRelationInfo(orgPersonRelation); |
700 | 0 | return createdOrgPersonRelationInfo; |
701 | |
} |
702 | |
|
703 | |
@Override |
704 | |
public OrgPersonRelationInfo updateOrgPersonRelation(String orgPersonRelationId, OrgPersonRelationInfo orgPersonRelationInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
705 | |
|
706 | 0 | checkForMissingParameter(orgPersonRelationId, "orgPersonRelationId"); |
707 | 0 | checkForMissingParameter(orgPersonRelationInfo, "orgPersonRelationInfo"); |
708 | |
|
709 | |
|
710 | 0 | if (!organizationDao.validatePositionRestriction(orgPersonRelationInfo.getOrgId(), orgPersonRelationInfo.getTypeKey())) { |
711 | 0 | throw new InvalidParameterException("There is no Position for this relationship"); |
712 | |
} |
713 | |
|
714 | |
|
715 | 0 | orgPersonRelationInfo.setId(orgPersonRelationId); |
716 | |
|
717 | 0 | OrgPersonRelation orgPersonRelation = null; |
718 | |
|
719 | |
|
720 | 0 | orgPersonRelation = OrganizationAssembler.toOrgPersonRelation(true, orgPersonRelationInfo, organizationDao); |
721 | |
|
722 | |
|
723 | 0 | orgPersonRelation = organizationDao.update(orgPersonRelation); |
724 | |
|
725 | |
|
726 | 0 | OrgPersonRelationInfo createdOrgPersonRelationInfo = OrganizationAssembler.toOrgPersonRelationInfo(orgPersonRelation); |
727 | 0 | return createdOrgPersonRelationInfo; |
728 | |
} |
729 | |
|
730 | |
@Override |
731 | |
public StatusInfo deleteOrgPersonRelation(String orgPersonRelationId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
732 | 0 | checkForMissingParameter(orgPersonRelationId, "orgPersonRelationId"); |
733 | |
|
734 | |
try { |
735 | 0 | organizationDao.delete(OrgPersonRelation.class, orgPersonRelationId); |
736 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
737 | 0 | throw new DoesNotExistException(e.getMessage()); |
738 | 0 | } |
739 | 0 | return new StatusInfo(); |
740 | |
} |
741 | |
|
742 | |
@Override |
743 | |
public OrgPositionRestrictionInfo getOrgPositionRestriction(String orgPositionRestrictionId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
744 | 0 | checkForMissingParameter(orgPositionRestrictionId, "orgPositionRestrictionId"); |
745 | |
|
746 | |
OrgPositionRestriction orgPositionRestriction; |
747 | |
try { |
748 | 0 | orgPositionRestriction = organizationDao.fetch(OrgPositionRestriction.class, orgPositionRestrictionId); |
749 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
750 | 0 | throw new DoesNotExistException(e.getMessage()); |
751 | 0 | } |
752 | 0 | return OrganizationAssembler.toOrgPositionRestrictionInfo(orgPositionRestriction); |
753 | |
} |
754 | |
|
755 | |
@Override |
756 | |
public List<OrgPositionRestrictionInfo> getOrgPositionRestrictionsByIds(List<String> orgPositionRestrictionIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
757 | 0 | checkForMissingParameter(orgPositionRestrictionIds, "orgPositionRestrictionIds"); |
758 | |
|
759 | 0 | List<OrgPositionRestriction> orgPositionRestrictions = extendedOrgDao.getOrgPositionRestrictionsByIds(orgPositionRestrictionIds); |
760 | 0 | return OrganizationAssembler.toOrgPositionRestrictionInfos(orgPositionRestrictions); |
761 | |
} |
762 | |
|
763 | |
@Override |
764 | |
public List<String> getOrgPositionRestrictionIdsByType(String orgPositionRestrictionTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
765 | 0 | checkForMissingParameter(orgPositionRestrictionTypeKey, "orgPositionRestrictionTypeKey"); |
766 | |
|
767 | 0 | List<String> orgPositionRestrictionIds = new ArrayList<String>(); |
768 | 0 | List<OrgPositionRestriction> orgPositionRestrictions = extendedOrgDao.getOrgPositionRestrictionsByType(orgPositionRestrictionTypeKey); |
769 | |
|
770 | 0 | if (orgPositionRestrictions != null){ |
771 | 0 | for (OrgPositionRestriction orgPositionRestriction : orgPositionRestrictions){ |
772 | 0 | orgPositionRestrictionIds.add(orgPositionRestriction.getId()); |
773 | |
} |
774 | |
} |
775 | |
|
776 | 0 | return orgPositionRestrictionIds; |
777 | |
} |
778 | |
|
779 | |
@Override |
780 | |
public List<String> getOrgPositionRestrictionIdsByOrg(String orgId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
781 | 0 | checkForMissingParameter(orgId, "orgId"); |
782 | |
|
783 | 0 | List<OrgPositionRestriction> restrictions = organizationDao.getPositionRestrictionsByOrg(orgId); |
784 | |
|
785 | 0 | List<String> restrictionIds = new ArrayList<String>(restrictions.size()); |
786 | 0 | for (OrgPositionRestriction restriction : restrictions) { |
787 | 0 | restrictionIds.add(restriction.getId()); |
788 | |
} |
789 | 0 | return restrictionIds; |
790 | |
} |
791 | |
|
792 | |
@Override |
793 | |
public List<String> searchForOrgPositionRestrictionIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
794 | 0 | List<String> orgPositionRestrictionIds = new ArrayList<String>(); |
795 | 0 | List<OrgPositionRestrictionInfo> orgPositionRestrictionInfos = this.searchForOrgPositionRestrictions(criteria, contextInfo); |
796 | |
|
797 | 0 | if (orgPositionRestrictionInfos != null) { |
798 | 0 | for (OrgPositionRestrictionInfo orgPositionRestrictionInfo : orgPositionRestrictionInfos) { |
799 | 0 | orgPositionRestrictionIds.add(orgPositionRestrictionInfo.getId()); |
800 | |
} |
801 | |
} |
802 | 0 | return orgPositionRestrictionIds; |
803 | |
} |
804 | |
|
805 | |
@Override |
806 | |
public List<OrgPositionRestrictionInfo> searchForOrgPositionRestrictions(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
807 | 0 | List<OrgPositionRestrictionInfo> orgPositionRestrictionInfos = new ArrayList<OrgPositionRestrictionInfo>(); |
808 | 0 | GenericQueryResults<OrgPositionRestriction> results = criteriaLookupService.lookup(OrgPositionRestriction.class, criteria); |
809 | |
|
810 | 0 | if (null != results && results.getResults().size() > 0) { |
811 | 0 | for (OrgPositionRestriction orgPositionRestriction : results.getResults()) { |
812 | 0 | orgPositionRestrictionInfos.add(OrganizationAssembler.toOrgPositionRestrictionInfo(orgPositionRestriction)); |
813 | |
} |
814 | |
} |
815 | |
|
816 | 0 | return orgPositionRestrictionInfos; |
817 | |
} |
818 | |
|
819 | |
@Override |
820 | |
public List<ValidationResultInfo> validateOrgPositionRestriction(String validationTypeKey, String orgId, String orgPositionRestrictionTypeKey, OrgPositionRestrictionInfo orgPositionRestrictionInfo, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
821 | 0 | checkForMissingParameter(validationTypeKey, "validationTypeKey"); |
822 | 0 | checkForMissingParameter(orgPositionRestrictionInfo, "orgPositionRestrictionInfo"); |
823 | |
|
824 | 0 | return null; |
825 | |
} |
826 | |
|
827 | |
@Override |
828 | |
public OrgPositionRestrictionInfo createOrgPositionRestriction(String orgId, String orgPositionRestrictionTypeKey, OrgPositionRestrictionInfo orgPositionRestrictionInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
829 | |
|
830 | 0 | checkForMissingParameter(orgId, "orgId"); |
831 | 0 | checkForMissingParameter(orgPositionRestrictionTypeKey, "orgPositionRestrictionTypeKey"); |
832 | 0 | checkForMissingParameter(orgPositionRestrictionInfo, "orgPositionRestrictionInfo"); |
833 | |
|
834 | |
|
835 | 0 | orgPositionRestrictionInfo.setOrgId(orgId); |
836 | 0 | orgPositionRestrictionInfo.setOrgPersonRelationTypeKey(orgPositionRestrictionTypeKey); |
837 | |
|
838 | 0 | OrgPositionRestriction orgPositionRestriction = null; |
839 | |
|
840 | |
|
841 | |
try { |
842 | 0 | orgPositionRestriction = OrganizationAssembler.toOrgPositionRestriction(false, orgPositionRestrictionInfo, organizationDao); |
843 | 0 | } catch (VersionMismatchException e) {} |
844 | |
|
845 | |
|
846 | 0 | organizationDao.create(orgPositionRestriction); |
847 | |
|
848 | |
|
849 | 0 | OrgPositionRestrictionInfo createdOrgPositionRestrictionInfo = OrganizationAssembler.toOrgPositionRestrictionInfo(orgPositionRestriction); |
850 | 0 | return createdOrgPositionRestrictionInfo; |
851 | |
} |
852 | |
|
853 | |
@Override |
854 | |
public OrgPositionRestrictionInfo updateOrgPositionRestriction(String orgPositionRestrictionId, OrgPositionRestrictionInfo orgPositionRestrictionInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
855 | |
|
856 | 0 | checkForMissingParameter(orgPositionRestrictionId, "orgPositionRestrictionId"); |
857 | 0 | checkForMissingParameter(orgPositionRestrictionInfo, "orgPositionRestrictionInfo"); |
858 | |
|
859 | |
|
860 | |
|
861 | |
|
862 | |
|
863 | 0 | OrgPositionRestriction orgPositionRestriction = null; |
864 | |
|
865 | |
|
866 | |
try { |
867 | 0 | orgPositionRestriction = OrganizationAssembler.toOrgPositionRestriction(true, orgPositionRestrictionInfo, organizationDao); |
868 | 0 | } catch (VersionMismatchException e) {} |
869 | |
|
870 | |
|
871 | 0 | OrgPositionRestriction updated = organizationDao.update(orgPositionRestriction); |
872 | |
|
873 | |
|
874 | 0 | OrgPositionRestrictionInfo updatedOrgPositionRestrictionInfo = OrganizationAssembler.toOrgPositionRestrictionInfo(updated); |
875 | 0 | return updatedOrgPositionRestrictionInfo; |
876 | |
} |
877 | |
|
878 | |
@Override |
879 | |
public StatusInfo deleteOrgPositionRestriction(String orgPositionRestrictionId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
880 | 0 | checkForMissingParameter(orgPositionRestrictionId, "orgPositionRestrictionId"); |
881 | |
|
882 | |
try { |
883 | 0 | organizationDao.delete(OrgPositionRestriction.class, orgPositionRestrictionId); |
884 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
885 | 0 | throw new DoesNotExistException(e.getMessage()); |
886 | 0 | } |
887 | 0 | return new StatusInfo(); |
888 | |
} |
889 | |
|
890 | |
@Override |
891 | |
public Boolean isDescendant(String orgId, String descendantOrgId, String orgHierarchyId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
892 | 0 | checkForMissingParameter(orgId, "orgId"); |
893 | 0 | checkForMissingParameter(descendantOrgId, "descendantOrgId"); |
894 | 0 | checkForMissingParameter(orgHierarchyId, "orgHierarchyId"); |
895 | |
|
896 | |
|
897 | 0 | List<String> ancestors = organizationDao.getAllAncestors(descendantOrgId, orgHierarchyId); |
898 | 0 | boolean result = ancestors.contains(orgId); |
899 | 0 | return Boolean.valueOf(result); |
900 | |
} |
901 | |
|
902 | |
@Override |
903 | |
public List<String> getAllDescendants(String orgId, String orgHierarchyId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
904 | 0 | checkForMissingParameter(orgId, "orgId"); |
905 | 0 | checkForMissingParameter(orgHierarchyId, "orgHierarchyId"); |
906 | |
|
907 | 0 | List<String> descendants = this.organizationDao.getAllDescendants(orgId, orgHierarchyId); |
908 | 0 | return descendants; |
909 | |
} |
910 | |
|
911 | |
@Override |
912 | |
public List<String> getAllAncestors(String orgId, String orgHierarchyId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
913 | 0 | checkForMissingParameter(orgId, "orgId"); |
914 | 0 | checkForMissingParameter(orgHierarchyId, "orgHierarchyId"); |
915 | |
|
916 | 0 | List<String> ancestors = this.organizationDao.getAllAncestors(orgId, orgHierarchyId); |
917 | 0 | return ancestors; |
918 | |
} |
919 | |
|
920 | |
@Override |
921 | |
public List<OrgTreeInfo> getOrgTree(String rootOrgId, String orgHierarchyId, int maxLevels, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
922 | 0 | checkForMissingParameter(rootOrgId, "rootOrgId"); |
923 | 0 | checkForMissingParameter(orgHierarchyId, "orgHierarchyId"); |
924 | |
|
925 | 0 | Set<OrgTreeInfo> results = new HashSet<OrgTreeInfo>(); |
926 | |
try { |
927 | 0 | Org rootOrg = organizationDao.fetch(Org.class, rootOrgId); |
928 | |
|
929 | 0 | OrgTreeInfo root = new OrgTreeInfo(); |
930 | 0 | root.setOrgId(rootOrgId); |
931 | 0 | root.setParentId(null); |
932 | 0 | root.setDisplayName(rootOrg.getLongName()); |
933 | 0 | root.setPositions(this.organizationDao.getOrgMemebershipCount(root.getOrgId())); |
934 | 0 | root.setOrgHierarchyId(orgHierarchyId); |
935 | 0 | results.add(root); |
936 | 0 | if (maxLevels >= 0) { |
937 | 0 | results.addAll(parseOrgTree(rootOrgId, orgHierarchyId, maxLevels, 0)); |
938 | |
} |
939 | |
|
940 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException e) { |
941 | 0 | throw new DoesNotExistException(); |
942 | 0 | } |
943 | |
|
944 | 0 | return new ArrayList<OrgTreeInfo>(results); |
945 | |
} |
946 | |
|
947 | |
private List<OrgTreeInfo> parseOrgTree(String rootOrgId, String orgHierarchyId, int maxLevels, int currentLevel) { |
948 | 0 | List<OrgTreeInfo> results = new ArrayList<OrgTreeInfo>(); |
949 | |
|
950 | 0 | if (maxLevels == 0 || currentLevel < maxLevels) { |
951 | 0 | List<org.kuali.student.core.organization.dto.OrgTreeInfo> orgTreeInfos = this.organizationDao.getOrgTreeInfo(rootOrgId, orgHierarchyId); |
952 | 0 | for (org.kuali.student.core.organization.dto.OrgTreeInfo orgTreeInfo : orgTreeInfos) { |
953 | |
|
954 | 0 | OrgTreeInfo treeInfo = new OrgTreeInfo(); |
955 | 0 | treeInfo.setOrgId(orgTreeInfo.getOrgId()); |
956 | 0 | treeInfo.setDisplayName(orgTreeInfo.getDisplayName()); |
957 | 0 | treeInfo.setOrgHierarchyId(orgTreeInfo.getOrgHierarchyId()); |
958 | 0 | treeInfo.setParentId(orgTreeInfo.getParentId()); |
959 | 0 | treeInfo.setPersonId(orgTreeInfo.getPersonId()); |
960 | 0 | treeInfo.setPositionId(orgTreeInfo.getPositionId()); |
961 | 0 | treeInfo.setRelationTypeKey(orgTreeInfo.getRelationType()); |
962 | 0 | treeInfo.setPositions(this.organizationDao.getOrgMemebershipCount(orgTreeInfo.getOrgId())); |
963 | |
|
964 | 0 | results.add(treeInfo); |
965 | |
|
966 | 0 | results.addAll(parseOrgTree(orgTreeInfo.getOrgId(), orgHierarchyId, maxLevels, currentLevel + 1)); |
967 | 0 | } |
968 | |
} |
969 | |
|
970 | 0 | return results; |
971 | |
} |
972 | |
|
973 | |
public ObjectStructure getObjectStructure(String objectTypeKey) { |
974 | 0 | return dictionaryServiceDelegate.getObjectStructure(objectTypeKey); |
975 | |
} |
976 | |
} |