View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.uif.lifecycle;
17  
18  import java.util.Queue;
19  
20  import org.kuali.rice.krad.uif.UifConstants;
21  import org.kuali.rice.krad.uif.component.Component;
22  import org.kuali.rice.krad.uif.lifecycle.ViewLifecycle.LifecycleEvent;
23  import org.kuali.rice.krad.uif.lifecycle.initialize.AssignIdsTask;
24  import org.kuali.rice.krad.uif.lifecycle.initialize.PopulatePathTask;
25  import org.kuali.rice.krad.uif.lifecycle.initialize.PrepareForCacheTask;
26  import org.kuali.rice.krad.uif.lifecycle.initialize.SortContainerTask;
27  import org.kuali.rice.krad.uif.util.LifecycleElement;
28  
29  /**
30   * Lifecycle phase implementation representing the pre-process phase.
31   *
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class PreProcessElementPhase extends ViewLifecyclePhaseBase {
35  
36      /**
37       * {@inheritDoc}
38       */
39      @Override
40      public LifecycleEvent getEventToNotify() {
41          return null;
42      }
43  
44      /**
45       * {@inheritDoc}
46       */
47      @Override
48      public String getStartViewStatus() {
49          return UifConstants.ViewStatus.CREATED;
50      }
51  
52      /**
53       * {@inheritDoc}
54       */
55      @Override
56      public String getEndViewStatus() {
57          return UifConstants.ViewStatus.CACHED;
58      }
59  
60      /**
61       * {@inheritDoc}
62       */
63      @Override
64      public String getViewPhase() {
65          return UifConstants.ViewPhases.PRE_PROCESS;
66      }
67  
68      /**
69       * {@inheritDoc}
70       */
71      @Override
72      protected void initializePendingTasks(Queue<ViewLifecycleTask<?>> tasks) {
73          tasks.offer(LifecycleTaskFactory.getTask(AssignIdsTask.class, this));
74          tasks.offer(LifecycleTaskFactory.getTask(PopulatePathTask.class, this));
75          tasks.offer(LifecycleTaskFactory.getTask(SortContainerTask.class, this));
76          tasks.offer(LifecycleTaskFactory.getTask(PrepareForCacheTask.class, this));
77      }
78  
79      /**
80       * {@inheritDoc}
81       */
82      @Override
83      protected ViewLifecyclePhase initializeSuccessor(LifecycleElement nestedElement, String nestedPath,
84              Component nestedParent) {
85          if (nestedElement != null && !UifConstants.ViewStatus.CACHED.equals(nestedElement.getViewStatus())) {
86              return LifecyclePhaseFactory.preProcess(nestedElement, nestedPath, nestedParent);
87          }
88  
89          return null;
90      }
91  
92  }