Author: sebawagner
Date: Sat Sep 22 09:28:16 2012
New Revision: 1388759

URL: http://svn.apache.org/viewvc?rev=1388759&view=rev
Log:
OPENMEETINGS-434 save/update/delete operations for configuration table, 
Some issues remain:
 - "New Record" label is not hidden after save, 
 - If you press delete the yellow "Loading" in the top right is shown, if you 
press cancel, the yellow "Loading" stays (but there is nothing loading at this 
moment)

Modified:
    
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/basic/Configurationmanagement.java
    
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/basic/Configuration.java
    
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/configurations/ConfigForm.java
    
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/configurations/ConfigsPanel.java

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/basic/Configurationmanagement.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/basic/Configurationmanagement.java?rev=1388759&r1=1388758&r2=1388759&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/basic/Configurationmanagement.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/basic/Configurationmanagement.java
 Sat Sep 22 09:28:16 2012
@@ -309,7 +309,7 @@ public class Configurationmanagement imp
 
        public Long updateConfig(Configuration conf) {
                try {
-                       if (conf.getConfiguration_id() == null) {
+                       if (conf.getConfiguration_id() == null || 
conf.getConfiguration_id() == 0) {
                                em.persist(conf);
                        } else {
                                if (!em.contains(conf)) {
@@ -375,8 +375,9 @@ public class Configurationmanagement imp
        }
 
        public Configuration get(long id) {
-               // TODO Auto-generated method stub
-               return null;
+               return em.createNamedQuery("getConfigurationById", 
Configuration.class)
+                                       .setParameter("configuration_id", id)
+                                       .getSingleResult();
        }
 
        public List<Configuration> get(int start, int count) {
@@ -388,12 +389,22 @@ public class Configurationmanagement imp
        }
 
        public void update(Configuration entity, long userId) {
-               // TODO Auto-generated method stub
-               
+               if (entity.getConfiguration_id() == null || 
entity.getConfiguration_id() == 0) {
+                       entity.setStarttime(new Date());
+                       entity.setDeleted(false);
+                       this.updateConfig(entity);
+               } else {
+                       entity.setUser_id(userId);
+                       entity.setDeleted(false);
+                       entity.setUpdatetime(new Date());
+                       this.updateConfig(entity);
+               }
        }
 
        public void delete(Configuration entity, long userId) {
-               // TODO Auto-generated method stub
-               
+               entity.setUser_id(userId);
+               entity.setDeleted(true);
+               entity.setUpdatetime(new Date());
+               this.updateConfig(entity);
        }
 }

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/basic/Configuration.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/basic/Configuration.java?rev=1388759&r1=1388758&r2=1388759&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/basic/Configuration.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/basic/Configuration.java
 Sat Sep 22 09:28:16 2012
@@ -39,9 +39,10 @@ import org.simpleframework.xml.Root;
 
 @Entity
 @NamedQueries({
-       @NamedQuery(name = "getConfigurationByKey", query = "SELECT c FROM 
Configuration c WHERE c.conf_key = :conf_key and c.deleted = false")
+       @NamedQuery(name = "getConfigurationByKey", query = "SELECT c FROM 
Configuration c WHERE c.conf_key LIKE :conf_key and c.deleted = false")
        , @NamedQuery(name = "getConfigurationsByKeys", query = "SELECT c FROM 
Configuration c WHERE c.conf_key IN :conf_keys and c.deleted = false")
        , @NamedQuery(name="getNondeletedConfiguration", query="SELECT u FROM 
Configuration u WHERE u.deleted = false")
+       , @NamedQuery(name = "getConfigurationById", query = "SELECT c FROM 
Configuration c WHERE c.configuration_id = :configuration_id and c.deleted = 
false")
 })
 @Table(name = "configuration")
 @Root(name="config")

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/configurations/ConfigForm.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/configurations/ConfigForm.java?rev=1388759&r1=1388758&r2=1388759&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/configurations/ConfigForm.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/configurations/ConfigForm.java
 Sat Sep 22 09:28:16 2012
@@ -18,9 +18,16 @@
  */
 package org.apache.openmeetings.web.components.admin.configurations;
 
+import org.apache.openmeetings.data.basic.Configurationmanagement;
 import org.apache.openmeetings.persistence.beans.basic.Configuration;
+import org.apache.openmeetings.web.app.Application;
+import org.apache.openmeetings.web.app.WebSession;
 import org.apache.openmeetings.web.components.admin.AdminBaseForm;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.datetime.markup.html.basic.DateLabel;
+import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.form.TextArea;
 import org.apache.wicket.markup.html.form.TextField;
 import org.apache.wicket.model.CompoundPropertyModel;
@@ -28,16 +35,57 @@ import org.apache.wicket.model.CompoundP
 public class ConfigForm extends AdminBaseForm<Configuration> {
 
        private static final long serialVersionUID = 1L;
+       private final WebMarkupContainer listContainer;
 
-       public ConfigForm(String id, final Configuration configuration) {
+       public ConfigForm(String id, WebMarkupContainer listContainer, final 
Configuration configuration) {
                super(id, new 
CompoundPropertyModel<Configuration>(configuration));
                setOutputMarkupId(true);
-               
+               this.listContainer = listContainer;
                add(new TextField<String>("conf_key"));
                add(new TextField<String>("conf_value"));
-               add(new Label("updatetime"));
+               add(DateLabel.forDatePattern("updatetime", "dd.MM.yyyy hh:mm"));
                add(new Label("users.login"));
                add(new TextArea<String>("comment"));
                
        }
+       
+       void updateView(AjaxRequestTarget target) {
+               target.add(this);
+       }
+       
+       @Override
+       protected void onSaveSubmit(AjaxRequestTarget target, Form<?> form) {
+               
Application.getBean(Configurationmanagement.class).update(getModelObject(), 
WebSession.getUserId());
+               Configuration conf = 
Application.getBean(Configurationmanagement.class).get(getModelObject().getConfiguration_id());
+               this.setModelObject(conf);
+               target.add(this);
+               target.add(listContainer);
+       }
+
+       @Override
+       protected void onNewSubmit(AjaxRequestTarget target, Form<?> form) {
+               this.setModelObject(new Configuration());
+               target.add(this);
+       }
+       
+       @Override
+       protected void onRefreshSubmit(AjaxRequestTarget target, Form<?> form) {
+               Configuration conf = this.getModelObject();
+               if (conf.getConfiguration_id() != null) {
+                       conf = 
Application.getBean(Configurationmanagement.class).get(conf.getConfiguration_id());
+               } else {
+                       conf = new Configuration();
+               }
+               this.setModelObject(conf);
+               target.add(this);
+       }
+       
+       @Override
+       protected void onDeleteSubmit(AjaxRequestTarget target, Form<?> form) {
+               
Application.getBean(Configurationmanagement.class).delete(this.getModelObject(),
 WebSession.getUserId());
+               this.setModelObject(new Configuration());
+               target.add(listContainer);
+               target.add(this);
+       }
+       
 }

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/configurations/ConfigsPanel.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/configurations/ConfigsPanel.java?rev=1388759&r1=1388758&r2=1388759&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/configurations/ConfigsPanel.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/admin/configurations/ConfigsPanel.java
 Sat Sep 22 09:28:16 2012
@@ -72,7 +72,7 @@ public class ConfigsPanel extends AdminP
                });
                
                Configuration configuration = new Configuration();
-               form = new ConfigForm("form", configuration);
+               form = new ConfigForm("form", listContainer, configuration);
         add(form);
                
        }


Reply via email to