continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcconn...@apache.org
Subject svn commit: r432753 - in /maven/continuum/trunk/continuum-webapp/src/main: java/org/apache/maven/continuum/web/action/ resources/ webapp/
Date Fri, 18 Aug 2006 22:29:48 GMT
Author: jmcconnell
Date: Fri Aug 18 15:29:48 2006
New Revision: 432753

URL: http://svn.apache.org/viewvc?rev=432753&view=rev
Log:
fixed up schedules, adding new schedules was broken so I consolidated the add and edit actions
into a singular save method on the scheduleAction

Removed:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddScheduleAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/EditScheduleAction.java
Modified:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ScheduleAction.java
    maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
    maven/continuum/trunk/continuum-webapp/src/main/webapp/editSchedule.jsp
    maven/continuum/trunk/continuum-webapp/src/main/webapp/schedules.jsp

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ScheduleAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ScheduleAction.java?rev=432753&r1=432752&r2=432753&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ScheduleAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ScheduleAction.java
Fri Aug 18 15:29:48 2006
@@ -17,23 +17,35 @@
  */
 
 import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.model.project.Schedule;
 
 import java.util.Collection;
 
 /**
  * @author Nik Gonzalez
- *
- * @plexus.component
- *   role="com.opensymphony.xwork.Action"
- *   role-hint="schedules"
+ * @plexus.component role="com.opensymphony.xwork.Action"
+ * role-hint="schedule"
  */
 public class ScheduleAction
     extends ContinuumActionSupport
 {
+    private int id;
+
+    private boolean active = true;
+
+    private String cronExpression;
+
+    private int delay;
+
+    private String description;
+
+    private String name;
 
     private Collection schedules;
 
-    public String execute()
+    private Schedule schedule;
+
+    public String summary()
         throws ContinuumException
     {
         schedules = continuum.getSchedules();
@@ -41,9 +53,148 @@
         return SUCCESS;
     }
 
+    public String input()
+    {
+        if ( id != 0 )
+        {
+            try
+            {
+                schedule = continuum.getSchedule( id );
+                active = schedule.isActive();
+                cronExpression= schedule.getCronExpression();
+                description = schedule.getDescription();
+                name = schedule.getName();
+                delay = schedule.getDelay();
+            }
+            catch ( ContinuumException e )
+            {
+                addActionError( "unable to retrieve schedule for editting" );
+                return ERROR;
+            }
+        }
+        return SUCCESS;
+    }
+
+    public String save()
+    {
+        if ( id == 0 )
+        {
+            try
+            {
+                Schedule schedule = new Schedule();
+                schedule.setActive( active );
+                schedule.setCronExpression( cronExpression );
+                schedule.setDelay( delay );
+                schedule.setDescription( description );
+                schedule.setName( name );
+
+                continuum.addSchedule( schedule );
+            }
+            catch ( ContinuumException e )
+            {
+                addActionError( "unable to add schedule" );
+                return ERROR;
+            }
+            return SUCCESS;
+        }
+        else
+        {
+
+            try
+            {
+                schedule = continuum.getSchedule( id );
+
+                schedule.setActive( active );
+                schedule.setCronExpression( cronExpression );
+                schedule.setDelay( delay );
+                schedule.setDescription( description );
+                schedule.setName( name );
+
+                continuum.updateSchedule( schedule );
+
+            }
+            catch ( ContinuumException e )
+            {
+                addActionError( "unable to edit schedule" );
+                return ERROR;
+            }
+
+            return SUCCESS;
+        }
+    }
+
     public Collection getSchedules()
     {
         return schedules;
     }
 
+    public int getId()
+    {
+        return id;
+    }
+
+    public void setId( int id )
+    {
+        this.id = id;
+    }
+
+    public boolean isActive()
+    {
+        return active;
+    }
+
+    public void setActive( boolean active )
+    {
+        this.active = active;
+    }
+
+    public String getCronExpression()
+    {
+        return cronExpression;
+    }
+
+    public void setCronExpression( String cronExpression )
+    {
+        this.cronExpression = cronExpression;
+    }
+
+    public int getDelay()
+    {
+        return delay;
+    }
+
+    public void setDelay( int delay )
+    {
+        this.delay = delay;
+    }
+
+    public String getDescription()
+    {
+        return description;
+    }
+
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public Schedule getSchedule()
+    {
+        return schedule;
+    }
+
+    public void setSchedule( Schedule schedule )
+    {
+        this.schedule = schedule;
+    }
 }

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml?rev=432753&r1=432752&r2=432753&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml Fri Aug 18 15:29:48
2006
@@ -227,11 +227,7 @@
       <result name="success">editSchedule.jsp</result>
     </action>
 
-    <action name="addSchedule" class="schedule" method="add">
-      <result name="success" type="chain">schedules</result>
-    </action>
-
-    <action name="editSchedule" class="schedule" method="edit">
+    <action name="saveSchedule" class="schedule" method="save">
       <result name="success" type="chain">schedules</result>
     </action>
 

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/editSchedule.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/editSchedule.jsp?rev=432753&r1=432752&r2=432753&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/editSchedule.jsp (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/editSchedule.jsp Fri Aug 18 15:29:48
2006
@@ -11,8 +11,8 @@
     <h3><ww:text name="editSchedule.page.title"/></h3>
 
     <div class="axial">
-      <ww:form action="editSchedule.action" method="post">
-        <input type="hidden" name="id" value="<ww:property value="id"/>"/>
+      <ww:form action="saveSchedule" method="post">
+        <input type="hidden" name="id" value="id"/>
         <table>
           <tbody>
             <ww:textfield label="%{getText('schedule.name.label')}" name="name" required="true">

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/schedules.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/schedules.jsp?rev=432753&r1=432752&r2=432753&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/schedules.jsp (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/schedules.jsp Fri Aug 18 15:29:48
2006
@@ -22,9 +22,10 @@
             <ec:column property="delay" title="schedules.table.delay"/>
             <ec:column property="cronExpression" title="schedules.table.cronExpression"/>
             <ec:column property="actions" title="&nbsp;">
-                <a href='<ww:url value="/editSchedule!edit.action">
-                  <ww:param name="id" value="${schedule.id}"/>
-                </ww:url>'><ww:text name="edit"/></a>
+                <ww:url id="editUrl" action="schedule">
+                  <ww:param name="id" value="${pageScope.schedule.id}"/>
+                </ww:url>
+                <ww:a href="%{editUrl}">Edit</ww:a>
                 &nbsp;
                 <ww:text name="delete"/>
             </ec:column>
@@ -32,7 +33,7 @@
         </ec:table>
       </div>
       <div class="functnbar3">
-        <ww:form action="addSchedule!default.action" method="post">
+        <ww:form action="schedule" method="post">
           <ww:submit value="%{getText('add')}"/>
         </ww:form>
     </div>



Mime
View raw message