View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  /**
17   * 
18   */
19  package org.kuali.student.lum.workflow.qualifierresolver;
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  import org.kuali.rice.kew.engine.RouteContext;
25  import org.kuali.rice.kim.bo.types.dto.AttributeSet;
26  import org.kuali.rice.student.bo.KualiStudentKimAttributes;
27  import org.kuali.student.core.organization.dto.OrgInfo;
28  
29  /**
30   * This class finds the admin organization on the KS document and returns the id
31   * and short name of that organization for routing directly to the org on the
32   * document
33   * 
34   */
35  public class AdminOrganizationQualifierResolver extends AbstractCocOrgQualifierResolver {
36  	protected static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AdminOrganizationQualifierResolver.class);
37  
38  	@Override
39  	public List<AttributeSet> resolve(RouteContext routeContext) {
40  		List<AttributeSet> attributeSets = super.resolve(routeContext);
41  		String orgId = null;
42  		if (attributeSets.size() > 0 && attributeSets.get(0).size() > 0) {
43  			orgId = getAttribute(attributeSets, KualiStudentKimAttributes.QUALIFICATION_ORG_ID);
44  		}
45  		List<AttributeSet> returnList = new ArrayList<AttributeSet>();
46  		if ( (orgId != null) && (!"".equals(orgId.trim())) ) {
47  			try {
48  				OrgInfo orgInfo = getOrganizationService().getOrganization(orgId);
49  				if (orgInfo == null) {
50  					LOG.error("Cannot find valid Org with id: " + orgId);
51  				}
52  				else {
53  					AttributeSet attributeSet = new AttributeSet();
54  					attributeSet.put(KualiStudentKimAttributes.QUALIFICATION_ORG, orgInfo.getShortName());
55  					attributeSet.put(KualiStudentKimAttributes.QUALIFICATION_ORG_ID, orgInfo.getId());
56  					returnList.add(attributeSet);
57  				}
58  			} catch (Exception e) {
59  				LOG.error("Error calling org service to retrieve org id: " + orgId);
60  				throw new RuntimeException(e);
61  			}
62  		}
63  		return returnList;
64  	}
65  
66  }