syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1440358 - in /syncope/trunk: common/src/main/java/org/apache/syncope/common/to/ console/src/main/java/org/apache/syncope/console/pages/ core/src/main/java/org/apache/syncope/core/rest/data/ core/src/test/java/org/apache/syncope/core/rest/
Date Wed, 30 Jan 2013 11:59:08 GMT
Author: cschneider
Date: Wed Jan 30 11:59:07 2013
New Revision: 1440358

URL: http://svn.apache.org/viewvc?rev=1440358&view=rev
Log:
SYNCOPE-231 Switching ReportTO to use AbstractReportletConf to enable JAXB serialization

Modified:
    syncope/trunk/common/src/main/java/org/apache/syncope/common/to/ReportTO.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportModalPage.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportletConfModalPage.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ReportDataBinder.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java

Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/to/ReportTO.java
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/to/ReportTO.java?rev=1440358&r1=1440357&r2=1440358&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/to/ReportTO.java (original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/to/ReportTO.java Wed Jan
30 11:59:07 2013
@@ -25,14 +25,17 @@ import java.util.List;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.XmlType;
 
 import org.apache.syncope.common.AbstractBaseBean;
 import org.apache.syncope.common.report.AbstractReportletConf;
-import org.apache.syncope.common.report.ReportletConf;
+import org.apache.syncope.common.report.StaticReportletConf;
+import org.apache.syncope.common.report.UserReportletConf;
 
 @XmlRootElement(name = "report")
 @XmlType
+@XmlSeeAlso({UserReportletConf.class, StaticReportletConf.class})
 public class ReportTO extends AbstractBaseBean {
 
     private static final long serialVersionUID = 5274568072084814410L;
@@ -41,7 +44,7 @@ public class ReportTO extends AbstractBa
 
     private String name;
 
-    private List<ReportletConf> reportletConfs;
+    private List<AbstractReportletConf> reportletConfs;
 
     private String cronExpression;
 
@@ -60,7 +63,7 @@ public class ReportTO extends AbstractBa
     public ReportTO() {
         super();
 
-        reportletConfs = new ArrayList<ReportletConf>();
+        reportletConfs = new ArrayList<AbstractReportletConf>();
         executions = new ArrayList<ReportExecTO>();
     }
 
@@ -80,21 +83,21 @@ public class ReportTO extends AbstractBa
         this.name = name;
     }
 
-    public boolean addReportletConf(ReportletConf reportlet) {
+    public boolean addReportletConf(AbstractReportletConf reportlet) {
         return this.reportletConfs.add(reportlet);
     }
 
-    public boolean removeReportletConf(ReportletConf reportlet) {
+    public boolean removeReportletConf(AbstractReportletConf reportlet) {
         return this.reportletConfs.remove(reportlet);
     }
 
     @XmlElementWrapper(name = "reportletConfigurations")
-    @XmlElement(name = "configuration", type=AbstractReportletConf.class)
-    public List<ReportletConf> getReportletConfs() {
+    @XmlElement(name="reportletconf")
+    public List<AbstractReportletConf> getReportletConfs() {
         return reportletConfs;
     }
 
-    public void setReportletConfs(List<ReportletConf> reportlets) {
+    public void setReportletConfs(List<AbstractReportletConf> reportlets) {
         this.reportletConfs = reportlets;
     }
 

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportModalPage.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportModalPage.java?rev=1440358&r1=1440357&r2=1440358&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportModalPage.java
(original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportModalPage.java
Wed Jan 30 11:59:07 2013
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.syncope.common.report.AbstractReportletConf;
 import org.apache.syncope.common.report.ReportletConf;
 import org.apache.syncope.common.to.ReportExecTO;
 import org.apache.syncope.common.to.ReportTO;
@@ -109,11 +110,11 @@ public class ReportModalPage extends Bas
 
     private long exportExecId;
 
-    private ReportletConf modalReportletConf;
+    private AbstractReportletConf modalReportletConf;
 
     private String modalReportletConfOldName;
 
-    private ListChoice<ReportletConf> reportlets;
+    private ListChoice<AbstractReportletConf> reportlets;
 
     public ReportModalPage(final ModalWindow window, final ReportTO reportTO, final PageReference
callerPageRef) {
         this.reportTO = reportTO;
@@ -250,7 +251,7 @@ public class ReportModalPage extends Bas
         nextExec.setEnabled(false);
         profile.add(nextExec);
 
-        reportlets = new ListChoice<ReportletConf>("reportletConfs", new Model(), reportTO.getReportletConfs(),
+        reportlets = new ListChoice<AbstractReportletConf>("reportletConfs", new Model(),
reportTO.getReportletConfs(),
                 new IChoiceRenderer<ReportletConf>() {
                     private static final long serialVersionUID = 1048000918946220007L;
 
@@ -383,8 +384,8 @@ public class ReportModalPage extends Bas
         });
     }
 
-    private void moveUp(final ReportletConf item) {
-        final List<ReportletConf> list = reportTO.getReportletConfs();
+    private void moveUp(final AbstractReportletConf item) {
+        final List<AbstractReportletConf> list = reportTO.getReportletConfs();
         int newPosition = list.indexOf(item) - 1;
         if (newPosition > -1) {
             list.remove(item);
@@ -392,8 +393,8 @@ public class ReportModalPage extends Bas
         }
     }
 
-    private void moveDown(final ReportletConf item) {
-        final List<ReportletConf> list = reportTO.getReportletConfs();
+    private void moveDown(final AbstractReportletConf item) {
+        final List<AbstractReportletConf> list = reportTO.getReportletConfs();
         int newPosition = list.indexOf(item) + 1;
         if (newPosition < list.size()) {
             list.remove(item);
@@ -542,7 +543,7 @@ public class ReportModalPage extends Bas
         this.exportFormat = exportFormat;
     }
 
-    public void setModalReportletConf(final ReportletConf modalReportletConf) {
+    public void setModalReportletConf(final AbstractReportletConf modalReportletConf) {
         this.modalReportletConf = modalReportletConf;
     }
 

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportletConfModalPage.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportletConfModalPage.java?rev=1440358&r1=1440357&r2=1440358&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportletConfModalPage.java
(original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ReportletConfModalPage.java
Wed Jan 30 11:59:07 2013
@@ -30,6 +30,7 @@ import java.util.List;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.annotation.FormAttributeField;
+import org.apache.syncope.common.report.AbstractReportletConf;
 import org.apache.syncope.common.report.ReportletConf;
 import org.apache.syncope.common.search.NodeCond;
 import org.apache.syncope.common.types.AttributableType;
@@ -83,7 +84,7 @@ public class ReportletConfModalPage exte
     @SpringBean
     private SchemaRestClient schemaRestClient;
 
-    private ReportletConf reportletConf;
+    private AbstractReportletConf reportletConf;
 
     final AjaxTextFieldPanel name;
 
@@ -91,7 +92,7 @@ public class ReportletConfModalPage exte
 
     private ListView<String> propView;
 
-    public ReportletConfModalPage(final ReportletConf reportletConf, final ModalWindow window,
+    public ReportletConfModalPage(final AbstractReportletConf reportletConf, final ModalWindow
window,
             final PageReference callerPageRef) {
 
         this.reportletConf = reportletConf;
@@ -126,7 +127,7 @@ public class ReportletConfModalPage exte
             public void setObject(final String object) {
                 try {
                     Class<?> reportletClass = Class.forName(object);
-                    ReportletConfModalPage.this.reportletConf = (ReportletConf) reportletClass.newInstance();
+                    ReportletConfModalPage.this.reportletConf = (AbstractReportletConf) reportletClass.newInstance();
                     propertiesContainer.replace(buildPropView());
                 } catch (Exception e) {
                     LOG.error("Cannot find or initialize {}", object, e);

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ReportDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ReportDataBinder.java?rev=1440358&r1=1440357&r2=1440358&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ReportDataBinder.java
(original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/ReportDataBinder.java
Wed Jan 30 11:59:07 2013
@@ -19,7 +19,10 @@
 package org.apache.syncope.core.rest.data;
 
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
+
+import org.apache.syncope.common.report.AbstractReportletConf;
 import org.apache.syncope.common.report.ReportletConf;
 import org.apache.syncope.common.to.ReportExecTO;
 import org.apache.syncope.common.to.ReportTO;
@@ -116,7 +119,7 @@ public class ReportDataBinder {
         reportTO.setId(report.getId());
         BeanUtils.copyProperties(report, reportTO, IGNORE_REPORT_PROPERTIES);
 
-        reportTO.setReportletConfs(report.getReportletConfs());
+        copyReportletConfs(report, reportTO);
 
         ReportExec latestExec = reportExecDAO.findLatestStarted(report);
         reportTO.setLatestExecStatus(latestExec == null
@@ -153,6 +156,13 @@ public class ReportDataBinder {
         return reportTO;
     }
 
+    private void copyReportletConfs(Report report, ReportTO reportTO) {
+        reportTO.getReportletConfs().clear();
+        for (ReportletConf reportletConf : report.getReportletConfs()) {
+            reportTO.getReportletConfs().add((AbstractReportletConf) reportletConf);
+        }
+    }
+
     public ReportExecTO getReportExecTO(final ReportExec execution) {
         ReportExecTO executionTO = new ReportExecTO();
         executionTO.setId(execution.getId());

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java?rev=1440358&r1=1440357&r2=1440358&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java Wed
Jan 30 11:59:07 2013
@@ -30,6 +30,7 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.List;
 import java.util.Set;
+import java.util.UUID;
 
 import javax.ws.rs.core.Response;
 
@@ -49,6 +50,7 @@ public class ReportTestITCase extends Ab
 
     public ReportTO createReport(final ReportTO report) {
         Response response = reportService.create(report);
+        assertCreated(response);
         return getObject(response, ReportTO.class, reportService);
     }
 
@@ -139,7 +141,7 @@ public class ReportTestITCase extends Ab
     @Test
     public void delete() {
         ReportTO report = new ReportTO();
-        report.setName("testReportForDelete");
+        report.setName("testReportForDelete" + getUUIDString());
         report.addReportletConf(new UserReportletConf("first"));
         report.addReportletConf(new UserReportletConf("second"));
 



Mime
View raw message