001/**
002 * Copyright 2005-2018 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 */
016package org.kuali.rice.krad.uif.lifecycle;
017
018import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
019import org.kuali.rice.krad.uif.UifConstants;
020import org.kuali.rice.krad.uif.component.Component;
021import org.kuali.rice.krad.uif.lifecycle.ViewLifecycle.LifecycleEvent;
022import org.kuali.rice.krad.uif.util.LifecycleElement;
023
024/**
025 * Lifecycle phase implementation representing the pre-process phase.
026 *
027 * @author Kuali Rice Team (rice.collab@kuali.org)
028 */
029public class PreProcessElementPhase extends ViewLifecyclePhaseBase {
030
031    /**
032     * {@inheritDoc}
033     */
034    @Override
035    public LifecycleEvent getEventToNotify() {
036        return null;
037    }
038
039    /**
040     * {@inheritDoc}
041     */
042    @Override
043    public String getStartViewStatus() {
044        return UifConstants.ViewStatus.CREATED;
045    }
046
047    /**
048     * {@inheritDoc}
049     */
050    @Override
051    public String getEndViewStatus() {
052        return UifConstants.ViewStatus.CACHED;
053    }
054
055    /**
056     * {@inheritDoc}
057     */
058    @Override
059    public String getViewPhase() {
060        return UifConstants.ViewPhases.PRE_PROCESS;
061    }
062
063    /**
064     * {@inheritDoc}
065     */
066    @Override
067    protected ViewLifecyclePhase initializeSuccessor(LifecycleElement nestedElement, String nestedPath,
068            Component nestedParent) {
069        if (nestedElement != null && !UifConstants.ViewStatus.CACHED.equals(nestedElement.getViewStatus())) {
070            ViewLifecyclePhase preProcessPhase = KRADServiceLocatorWeb.getViewLifecyclePhaseBuilder().buildPhase(
071                    UifConstants.ViewPhases.PRE_PROCESS, nestedElement, nestedParent, nestedPath, getRefreshPaths());
072            return preProcessPhase;
073        }
074
075        return null;
076    }
077
078}