Session.renderReport() implemented
authorAlex Kirhenshtein <alk@netxms.org>
Thu, 27 Jun 2013 10:36:58 +0000 (10:36 +0000)
committerAlex Kirhenshtein <alk@netxms.org>
Thu, 27 Jun 2013 10:36:58 +0000 (10:36 +0000)
.gitattributes
src/java/netxms-base/src/main/java/org/netxms/base/NXCPCodes.java
src/java/netxms-client-api/src/main/java/org/netxms/api/client/reporting/ReportRenderFormat.java [moved from src/java/netxms-client/src/main/java/org/netxms/client/reports/ReportRenderFormat.java with 91% similarity]
src/java/netxms-client-api/src/main/java/org/netxms/api/client/reporting/ReportingServerManager.java
src/java/netxms-client/src/main/java/org/netxms/client/NXCSession.java

index 6b823d3..90819fd 100644 (file)
@@ -829,6 +829,7 @@ src/java/netxms-client-api/src/main/java/org/netxms/api/client/SessionNotificati
 src/java/netxms-client-api/src/main/java/org/netxms/api/client/constants/UserAccessRights.java -text
 src/java/netxms-client-api/src/main/java/org/netxms/api/client/images/ImageLibraryManager.java -text
 src/java/netxms-client-api/src/main/java/org/netxms/api/client/images/LibraryImage.java -text
+src/java/netxms-client-api/src/main/java/org/netxms/api/client/reporting/ReportRenderFormat.java -text svneol=native#unset
 src/java/netxms-client-api/src/main/java/org/netxms/api/client/scripts/Script.java -text
 src/java/netxms-client-api/src/main/java/org/netxms/api/client/scripts/ScriptLibraryManager.java -text
 src/java/netxms-client-api/src/main/java/org/netxms/api/client/servermanager/ServerManager.java -text
@@ -957,7 +958,6 @@ src/java/netxms-client/src/main/java/org/netxms/client/objecttools/ObjectToolDet
 src/java/netxms-client/src/main/java/org/netxms/client/objecttools/ObjectToolTableColumn.java -text
 src/java/netxms-client/src/main/java/org/netxms/client/packages/PackageDeploymentListener.java -text
 src/java/netxms-client/src/main/java/org/netxms/client/packages/PackageInfo.java -text
-src/java/netxms-client/src/main/java/org/netxms/client/reports/ReportRenderFormat.java -text
 src/java/netxms-client/src/main/java/org/netxms/client/situations/Situation.java -text
 src/java/netxms-client/src/main/java/org/netxms/client/situations/SituationInstance.java -text
 src/java/netxms-client/src/main/java/org/netxms/client/snmp/MibObject.java -text
index 40b082a..4689286 100644 (file)
@@ -308,10 +308,10 @@ public class NXCPCodes
 \r
        // CMD_RS_ - Reporting Server related codes\r
        public static final int CMD_RS_LIST_REPORTS = 0x1100;\r
-       public static final int CMD_RS_GET_REPORT = 0x1101;\r
+       public static final int CMD_RS_GET_REPORT_DEFINITION = 0x1101;\r
        public static final int CMD_RS_SCHEDULE_EXECUTION = 0x1102;\r
        public static final int CMD_RS_LIST_RESULTS = 0x1103;\r
-       public static final int CMD_RS_GET_RESULT = 0x1104;\r
+       public static final int CMD_RS_RENDER_RESULT = 0x1104;\r
        public static final int CMD_RS_DELETE_RESULT = 0x1105;\r
 \r
        // Variable codes\r
@@ -15,7 +15,7 @@
  * You should have received a copy of the GNU General Public License\r
  * along with this program; if not, write to the Free Software\r
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
- */package org.netxms.client.reports;\r
+ */package org.netxms.api.client.reporting;\r
 \r
 /**\r
  * Formats for report rendering\r
@@ -23,7 +23,7 @@
 public enum ReportRenderFormat\r
 {\r
        PDF(1, "pdf"),\r
-       HTML(2, "html");\r
+       XLS(2, "xls");\r
        \r
        private final int code;\r
        private final String extension; \r
index 5dec029..938ef55 100644 (file)
@@ -1,5 +1,6 @@
 package org.netxms.api.client.reporting;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
@@ -17,4 +18,6 @@ public interface ReportingServerManager
        List<ReportResult> listReportResults(UUID reportId) throws NetXMSClientException, IOException;
 
        void deleteReportResult(UUID reportId, UUID jobId) throws NetXMSClientException, IOException;
+
+       File renderReport(UUID reportId, UUID jobId, ReportRenderFormat format) throws NetXMSClientException, IOException;
 }
index 4299222..47440cf 100644 (file)
@@ -59,6 +59,7 @@ import org.netxms.api.client.mt.MappingTable;
 import org.netxms.api.client.mt.MappingTableDescriptor;\r
 import org.netxms.api.client.reporting.ReportDefinition;\r
 import org.netxms.api.client.reporting.ReportParameter;\r
+import org.netxms.api.client.reporting.ReportRenderFormat;\r
 import org.netxms.api.client.reporting.ReportResult;\r
 import org.netxms.api.client.reporting.ReportingServerManager;\r
 import org.netxms.api.client.scripts.Script;\r
@@ -150,7 +151,6 @@ import org.netxms.client.objecttools.ObjectTool;
 import org.netxms.client.objecttools.ObjectToolDetails;\r
 import org.netxms.client.packages.PackageDeploymentListener;\r
 import org.netxms.client.packages.PackageInfo;\r
-import org.netxms.client.reports.ReportRenderFormat;\r
 import org.netxms.client.situations.Situation;\r
 import org.netxms.client.snmp.SnmpTrap;\r
 import org.netxms.client.snmp.SnmpTrapLogRecord;\r
@@ -6137,31 +6137,6 @@ public class NXCSession implements Session, ScriptLibraryManager, UserManager, S
                waitForRCC(msg.getMessageId());\r
        }\r
 \r
-       /**\r
-        * Render report into desired format\r
-        * \r
-        * @param jobId\r
-        * @return report's File object\r
-        * @throws IOException if socket or file I/O error occurs\r
-        * @throws NXCException if NetXMS server returns an error or operation was timed out\r
-        */\r
-       public File renderReport(final long jobId, ReportRenderFormat format) throws IOException, NXCException\r
-       {\r
-               final NXCPMessage msg = newMessage(NXCPCodes.CMD_RENDER_REPORT);\r
-               msg.setVariableInt32(NXCPCodes.VID_JOB_ID, (int)jobId);\r
-               msg.setVariableInt32(NXCPCodes.VID_RENDER_FORMAT, format.getCode());\r
-               sendMessage(msg);\r
-               waitForRCC(msg.getMessageId());\r
-\r
-               final File file = waitForFile(msg.getMessageId(), 600000);\r
-               if (file == null)\r
-               {\r
-                       throw new NXCException(RCC.IO_ERROR);\r
-               }\r
-\r
-               return file;\r
-       }\r
-\r
        /**\r
         * Get address list.\r
         * \r
@@ -6754,7 +6729,7 @@ public class NXCSession implements Session, ScriptLibraryManager, UserManager, S
        @Override\r
        public ReportDefinition getReportDefinition(UUID reportId) throws NetXMSClientException, IOException\r
        {\r
-               final NXCPMessage msg = newMessage(NXCPCodes.CMD_RS_GET_REPORT);\r
+               final NXCPMessage msg = newMessage(NXCPCodes.CMD_RS_GET_REPORT_DEFINITION);\r
                msg.setVariable(NXCPCodes.VID_REPORT_DEFINITION, reportId);\r
                msg.setVariable(NXCPCodes.VID_LOCALE, Locale.getDefault().getLanguage());\r
                sendMessage(msg);\r
@@ -6825,4 +6800,22 @@ public class NXCSession implements Session, ScriptLibraryManager, UserManager, S
                sendMessage(msg);\r
                waitForRCC(msg.getMessageId());\r
        }\r
+\r
+       @Override\r
+       public File renderReport(UUID reportId, UUID jobId, ReportRenderFormat format) throws NetXMSClientException, IOException\r
+       {\r
+               final NXCPMessage msg = newMessage(NXCPCodes.CMD_RS_RENDER_RESULT);\r
+               msg.setVariable(NXCPCodes.VID_REPORT_DEFINITION, reportId);\r
+               msg.setVariable(NXCPCodes.VID_JOB_ID, jobId);\r
+               msg.setVariableInt32(NXCPCodes.VID_RENDER_FORMAT, format.getCode());\r
+               sendMessage(msg);\r
+               final NXCPMessage response = waitForRCC(msg.getMessageId());\r
+               final File file = waitForFile(msg.getMessageId(), 600000);\r
+               if (file == null)\r
+               {\r
+                       throw new NXCException(RCC.IO_ERROR);\r
+               }\r
+               return file;\r
+       }\r
+\r
 }\r