001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.kew.impl.peopleflow;
017
018 import org.apache.commons.lang.StringUtils;
019 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
020 import org.kuali.rice.core.api.uif.RemotableAttributeField;
021 import org.kuali.rice.kew.api.KewApiServiceLocator;
022 import org.kuali.rice.kew.api.repository.type.KewTypeDefinition;
023 import org.kuali.rice.kew.framework.peopleflow.PeopleFlowTypeService;
024 import org.kuali.rice.krad.inquiry.InquirableImpl;
025 import org.kuali.rice.krad.uif.container.Container;
026 import org.kuali.rice.krad.uif.view.View;
027 import org.kuali.rice.krad.web.form.InquiryForm;
028
029 import javax.xml.namespace.QName;
030 import java.util.ArrayList;
031 import java.util.List;
032
033 /**
034 * Custom view helper for the people flow inquiry view to retrieve the type attribute remotable fields
035 *
036 * @author Kuali Rice Team (rice.collab@kuali.org)
037 */
038 public class PeopleFlowInquirableImpl extends InquirableImpl {
039 private static final long serialVersionUID = -8392423307944257532L;
040
041 /**
042 * Invokes the {@link org.kuali.rice.kew.api.repository.type.KewTypeRepositoryService} to retrieve the remotable
043 * field definitions for the attributes associated with the selected type
044 *
045 * @param view - view instance
046 * @param model - object containing the form data, from which the selected type will be pulled
047 * @param container - container that holds the remotable fields
048 * @return List<RemotableAttributeField> instances for the type attributes, or empty list if not attributes exist
049 */
050 public List<RemotableAttributeField> retrieveTypeAttributes(View view, Object model, Container container) {
051 List<RemotableAttributeField> remoteFields = new ArrayList<RemotableAttributeField>();
052
053 PeopleFlowBo peopleFlow = (PeopleFlowBo) ((InquiryForm) model).getDataObject();
054
055 // retrieve the type service and invoke to get the remotable field definitions
056 if (peopleFlow != null && StringUtils.isNotBlank(peopleFlow.getTypeId())) {
057 String typeId = peopleFlow.getTypeId();
058 KewTypeDefinition typeDefinition = KewApiServiceLocator.getKewTypeRepositoryService().getTypeById(typeId);
059 PeopleFlowTypeService peopleFlowTypeService = GlobalResourceLoader.<PeopleFlowTypeService>getService(
060 QName.valueOf(typeDefinition.getServiceName()));
061 remoteFields = peopleFlowTypeService.getAttributeFields(typeId);
062 }
063
064 return remoteFields;
065 }
066 }