001    /**
002     * Copyright 2005-2012 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    
017    package org.kuali.rice.krad.web.controller;
018    
019    import javax.servlet.http.HttpServletRequest;
020    import javax.servlet.http.HttpServletResponse;
021    
022    import org.apache.commons.lang.ArrayUtils;
023    import org.apache.log4j.Logger;
024    import org.kuali.rice.kew.api.KewApiConstants;
025    import org.kuali.rice.krad.bo.PersistableAttachment;
026    import org.kuali.rice.krad.bo.PersistableBusinessObject;
027    import org.kuali.rice.krad.datadictionary.DocumentEntry;
028    import org.kuali.rice.krad.document.Copyable;
029    import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
030    import org.kuali.rice.krad.util.KRADConstants;
031    import org.kuali.rice.krad.web.form.DocumentFormBase;
032    import org.kuali.rice.krad.web.form.TransactionForm;
033    import org.kuali.rice.krad.web.form.UifFormBase;
034    import org.springframework.stereotype.Controller;
035    import org.springframework.validation.BindingResult;
036    import org.springframework.web.bind.annotation.ModelAttribute;
037    import org.springframework.web.bind.annotation.RequestMapping;
038    import org.springframework.web.servlet.ModelAndView;
039    import org.kuali.rice.krad.document.Document;
040    
041    /**
042     * Controller for <code>TransactionalView</code> screens which operate on
043     * <code>TransactionalDocument</code> instances
044     *
045     * @author Kuali Rice Team (rice.collab@kuali.org)
046     */
047    @Controller
048    @RequestMapping(value = "/transactional")
049    public class TransactionalDocumentController extends DocumentControllerBase {
050        protected static final Logger LOG = Logger.getLogger(MaintenanceDocumentController.class);
051    
052        /**
053         * @see org.kuali.rice.krad.web.controller.UifControllerBase#createInitialForm(javax.servlet.http.HttpServletRequest)
054         */
055        @Override
056        protected TransactionForm createInitialForm(HttpServletRequest request) {
057            return new TransactionForm();
058        }
059    
060        /**
061         * Method that will take the current document and call its copy method if Copyable.
062         */
063        @RequestMapping(params = "methodToCall=" + KRADConstants.Maintenance.METHOD_TO_CALL_COPY)
064        public ModelAndView copy(@ModelAttribute("KualiForm") TransactionForm form, BindingResult result,
065                HttpServletRequest request, HttpServletResponse response) throws Exception {
066            ((Copyable) form.getDocument()).toCopy();
067            return getUIFModelAndView(form);
068        }
069    
070    }