diff --git a/appserver/admingui/full/src/main/java/fish/payara/full/admingui/handlers/BatchHandlers.java b/appserver/admingui/full/src/main/java/fish/payara/full/admingui/handlers/BatchHandlers.java
new file mode 100644
index 00000000000..c397974f7e7
--- /dev/null
+++ b/appserver/admingui/full/src/main/java/fish/payara/full/admingui/handlers/BatchHandlers.java
@@ -0,0 +1,163 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2018 Payara Foundation and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://github.com/payara/Payara/blob/master/LICENSE.txt
+ * See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * The Payara Foundation designates this particular file as subject to the "Classpath"
+ * exception as provided by the Payara Foundation in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package fish.payara.full.admingui.handlers;
+
+import com.sun.jsftemplating.annotation.Handler;
+import com.sun.jsftemplating.annotation.HandlerInput;
+import com.sun.jsftemplating.annotation.HandlerOutput;
+import com.sun.jsftemplating.layout.descriptors.handler.HandlerContext;
+import org.glassfish.admingui.common.util.GuiUtil;
+
+/**
+ *
+ * @author Susan Rai
+ */
+public class BatchHandlers {
+
+ private static final int DEFAULT_OFFSET_INCREMENT = 20;
+
+ @Handler(id = "py.addToOffSetValue",
+ input = {
+ @HandlerInput(name = "offset", type = String.class)},
+ output = {
+ @HandlerOutput(name = "result", type = String.class)})
+ public static void addToOffSetValue(HandlerContext handlerCtx) {
+
+ String offsetValue = (String) handlerCtx.getInputValue("offset");
+ int result = 0;
+
+ try {
+ result = Integer.parseInt(offsetValue) + DEFAULT_OFFSET_INCREMENT;
+ } catch (NumberFormatException ex) {
+ GuiUtil.getLogger().info("Value isn't a valid integer " + ex);
+ }
+
+ handlerCtx.setOutputValue("result", result);
+ }
+
+ @Handler(id = "py.subtractFromOffSetValue",
+ input = {
+ @HandlerInput(name = "offset", type = String.class)},
+ output = {
+ @HandlerOutput(name = "result", type = String.class)})
+ public static void subtractFromOffSetValue(HandlerContext handlerCtx) {
+
+ String offsetValue = (String) handlerCtx.getInputValue("offset");
+ int result = 0;
+
+ try {
+ result = Integer.parseInt(offsetValue);
+ if (result >= DEFAULT_OFFSET_INCREMENT) {
+ result = result - DEFAULT_OFFSET_INCREMENT;
+ } else {
+ result = 0;
+ }
+ } catch (NumberFormatException ex) {
+ GuiUtil.getLogger().info("Value isn't a valid integer " + ex);
+ }
+
+ handlerCtx.setOutputValue("result", result);
+ }
+
+ @Handler(id = "py.getPageNumber",
+ input = {
+ @HandlerInput(name = "offset", type = String.class)},
+ output = {
+ @HandlerOutput(name = "result", type = String.class)})
+ public static void getPageNumber(HandlerContext handlerCtx) {
+
+ String offsetValue = (String) handlerCtx.getInputValue("offset");
+ int result = 0;
+
+ try {
+ int offSet = Integer.parseInt(offsetValue);
+ result = (offSet + DEFAULT_OFFSET_INCREMENT) / DEFAULT_OFFSET_INCREMENT;
+ } catch (NumberFormatException ex) {
+ GuiUtil.getLogger().info("Value isn't a valid integer " + ex);
+ }
+
+ handlerCtx.setOutputValue("result", result);
+ }
+
+ @Handler(id = "py.getSpecifiedPageNumber",
+ input = {
+ @HandlerInput(name = "pageNumber", type = String.class)},
+ output = {
+ @HandlerOutput(name = "result", type = String.class)})
+ public static void getSpecifiedPageNumber(HandlerContext handlerCtx) {
+
+ String pageNumberValue = (String) handlerCtx.getInputValue("pageNumber");
+ int result = 0;
+
+ try {
+ int pageNumber = Integer.parseInt(pageNumberValue);
+ if (pageNumber > 0) {
+ result = (pageNumber * DEFAULT_OFFSET_INCREMENT) - DEFAULT_OFFSET_INCREMENT;
+ }
+ } catch (NumberFormatException ex) {
+ GuiUtil.getLogger().info("Value isn't a valid integer " + ex);
+ }
+
+ handlerCtx.setOutputValue("result", result);
+ }
+
+ @Handler(id = "py.getPageCount",
+ input = {
+ @HandlerInput(name = "jobCount", type = String.class)},
+ output = {
+ @HandlerOutput(name = "result", type = String.class)})
+ public static void getPageCount(HandlerContext handlerCtx) {
+
+ String jobCountValue = (String) handlerCtx.getInputValue("jobCount");
+ int result = 1;
+
+ try {
+ int jobCount = Integer.parseInt(jobCountValue);
+ if (jobCount > 0) {
+ result = (jobCount + DEFAULT_OFFSET_INCREMENT - 1) / DEFAULT_OFFSET_INCREMENT;
+ }
+ } catch (NumberFormatException ex) {
+ GuiUtil.getLogger().info("Value isn't a valid integer " + ex);
+ }
+
+ handlerCtx.setOutputValue("result", result);
+ }
+
+}
diff --git a/appserver/admingui/full/src/main/resources/batch/assets/js/batch.js b/appserver/admingui/full/src/main/resources/batch/assets/js/batch.js
new file mode 100644
index 00000000000..3792dc5819b
--- /dev/null
+++ b/appserver/admingui/full/src/main/resources/batch/assets/js/batch.js
@@ -0,0 +1,53 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2018 Payara Foundation and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://github.com/payara/Payara/blob/master/LICENSE.txt
+ * See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * The Payara Foundation designates this particular file as subject to the "Classpath"
+ * exception as provided by the Payara Foundation in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+
+
+
diff --git a/appserver/admingui/full/src/main/resources/batch/assets/skins/payara_theme/batch-styles.css b/appserver/admingui/full/src/main/resources/batch/assets/skins/payara_theme/batch-styles.css
new file mode 100644
index 00000000000..13773255efd
--- /dev/null
+++ b/appserver/admingui/full/src/main/resources/batch/assets/skins/payara_theme/batch-styles.css
@@ -0,0 +1,104 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2018 Payara Foundation and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://github.com/payara/Payara/blob/master/LICENSE.txt
+ * See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/legal/LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * The Payara Foundation designates this particular file as subject to the "Classpath"
+ * exception as provided by the Payara Foundation in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+/*
+ Created on : Jul 13, 2018, 5:51:48 PM
+ Author : Susan Rai
+*/
+
+input[id$="previousJobsButton"], input[id$="nextJobsButton"] {
+ width: 100px;
+ height: 30px;
+ padding: 0px;
+ color:#000000;
+ font-weight: bold;
+ background-color: transparent;
+}
+
+input:hover[id$="previousJobsButton"],
+input:hover[id$="nextJobsButton"],
+input:hover[id$="goButton"]{
+ background-color: #cbced0 !important;
+}
+
+span[id$=":paginationButtons"] {
+ background-color: #eeeeee;
+ border-radius: 5px;
+ padding: 10px;
+ display:block;
+ width : 350px;
+ margin: 0 0 20px 23%;
+}
+
+input[id$="nextJobsButton"] {
+ float: right;
+}
+
+input[id$="pageNumber"]{
+ float: left;
+ margin: -25px 0 0 135px;
+ width: 30px;
+ text-align: center;
+}
+
+label[id$="totalNumberOfPages_label"] {
+ color: #333333;
+ float: right;
+ width: 60px;
+ font-weight:100;
+ margin: -22px 110px 0 0;
+}
+label[for$="pageNumber"] {
+ color: #333333;
+ font-weight:100;
+ float: left;
+ width: 35px;
+ margin: -22px 0 0 100px;
+}
+
+input[id$="goButton"]{
+ width: 35px;
+ height: 25px;
+ padding: 0px;
+ color: #333333;
+ font-weight: bold;
+ background-color: transparent;
+ float: right;
+ margin: -27px 95px 0 0;
+}
\ No newline at end of file
diff --git a/appserver/admingui/full/src/main/resources/batch/batchJobs_1.inc b/appserver/admingui/full/src/main/resources/batch/batchJobs_1.inc
index 6c2404516b3..b8ddce240f1 100644
--- a/appserver/admingui/full/src/main/resources/batch/batchJobs_1.inc
+++ b/appserver/admingui/full/src/main/resources/batch/batchJobs_1.inc
@@ -55,12 +55,39 @@
#include "/full/batch/batchRequestParam.inc"
setSessionAttribute(key="#{pageSession.tabSetName}" value="batchJobs");
createMap(result="#{requestScope.attrsMap}");
- mapPut(map="#{requestScope.attrsMap}" key="target" value="#{pageSession.encodedTarget}");
+ py.getPageNumber(offset="#{pageSession.offsetValue}" result="#{pageSession.pageNumber}");
+ mapPut(map="#{requestScope.attrsMap}" key="target" value="#{pageSession.encodedTarget}");
mapPut(map="#{requestScope.attrsMap}" key="output" value="executionid,jobname,batchstatus,exitstatus,instanceid,starttime,endtime");
+ mapPut(map="#{requestScope.attrsMap}" key="offset" value="#{pageSession.offsetValue}");
+ mapPut(map="#{requestScope.attrsMap}" key="limit" value="$int{20}");
gf.restRequest(endpoint="#{sessionScope.REST_URL}/list-batch-jobs" attrs="#{requestScope.attrsMap}" method="GET" result="#{requestScope.resp}");
setAttribute(key="listOfRows", value="#{requestScope.resp.data.extraProperties.listBatchJobs}");
+ setPageSessionAttribute(key="size" value="#{requestScope.listOfRows.size()}");
+ setPageSessionAttribute(key="valueMap", value="#{requestScope.resp.data.extraProperties.listJobsCount}");
+ py.getPageCount(jobCount="#{pageSession.valueMap['allJobsCount']}" result="#{pageSession.pageCount}");
+ setPageSessionAttribute(key="showJobExecutions" value="#{true}");
+ setPageSessionAttribute(key="displayNoJobsMessage" value="#{false}");
+
+ if (#{pageSession.size}<$int{1}){
+ setPageSessionAttribute(key="showJobExecutions" value="#{false}");
+ setPageSessionAttribute(key="displayNoJobsMessage" value="#{true}");
+ }
+
+ if (#{pageSession.pageNumber}<$int{1}){
+ setPageSessionAttribute(key="pageNumber" value="$int{1}");
+ }
+
+ if(#{pageSession.pageNumber}=#{pageSession.pageCount}){
+ setPageSessionAttribute(key="disableNextButton" value="#{true}");
+ }
+
+ if(#{pageSession.pageNumber}=$int{1}){
+ setPageSessionAttribute(key="disablePreviousButton" value="#{true}");
+ }
+
setPageSessionAttribute(key="tableTitle" value="$resource{i18nf.batch.batchJobsTableTitle}");
setPageSessionAttribute(key="editLink" value="#{request.contextPath}/full/batch/batchJobExecution.jsf?target=#{pageSession.target}&isCluster=#{pageSession.isCluster}&tabSetName=#{pageSession.encodedTabSetName}");
/>
+#include"/batch/assets/js/batch.js"
diff --git a/appserver/admingui/full/src/main/resources/batch/batchJobs_2.inc b/appserver/admingui/full/src/main/resources/batch/batchJobs_2.inc
index 3660f050fe9..63d475e6fea 100644
--- a/appserver/admingui/full/src/main/resources/batch/batchJobs_2.inc
+++ b/appserver/admingui/full/src/main/resources/batch/batchJobs_2.inc
@@ -37,17 +37,19 @@
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-
+
+ Portions Copyright [2018] [Payara Foundation and/or its affiliates]
-->
#include "/common/shared/alertMsg_1.inc"
#include "/common/shared/nameSection.inc"
+ paginationControls="$boolean{false}"
+ paginateButton="$boolean{false}">
$page{tableId});
/>
@@ -95,7 +97,85 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/appserver/admingui/full/src/main/resources/batch/batchRequestParam.inc b/appserver/admingui/full/src/main/resources/batch/batchRequestParam.inc
index 2c1885e8137..662707df7ea 100644
--- a/appserver/admingui/full/src/main/resources/batch/batchRequestParam.inc
+++ b/appserver/admingui/full/src/main/resources/batch/batchRequestParam.inc
@@ -38,28 +38,30 @@
only if the new code is made subject to such option by the copyright
holder.
+ Portions Copyright [2018] [Payara Foundation and/or its affiliates]
-->
getRequestValue(key="target" value="#{pageSession.target}");
urlencode(value="#{pageSession.target}" encoding="UTF-8" result="#{pageSession.encodedTarget}");
getRequestValue(key="isCluster" value="#{pageSession.isCluster}" default="false");
getRequestValue(key="tabSetName" value="#{pageSession.tabSetName}");
+getRequestValue(key="offsetValue" value="#{pageSession.offsetValue}" default="$int{0}");
urlencode(value="#{pageSession.tabSetName}" encoding="UTF-8" result="#{pageSession.encodedTabSetName}");
if(#{pageSession.isCluster}=true){
setPageSessionAttribute(key="clusterName", value="#{pageSession.target}");
setPageSessionAttribute(key="encodedClusterName", value="#{pageSession.encodedTarget}");
- setPageSessionAttribute(key="listJobsLink" value="#{request.contextPath}/full/batch/batchJobsCluster.jsf?target=#{pageSession.encodedTarget}&isCluster=true&tabSetName=#{pageSession.encodedTabSetName}");
+ setPageSessionAttribute(key="listJobsLink" value="#{request.contextPath}/full/batch/batchJobsCluster.jsf?target=#{pageSession.encodedTarget}&offsetValue=#{pageSession.offsetValue}&isCluster=true&tabSetName=#{pageSession.encodedTabSetName}");
}
if(#{pageSession.isCluster}=false){
setPageSessionAttribute(key="isCluster", value="false");
setPageSessionAttribute(key="instanceName", value="#{pageSession.target}");
setPageSessionAttribute(key="encodedInstanceName", value="#{pageSession.encodedTarget}");
if(#{pageSession.target}=server){
- setPageSessionAttribute(key="listJobsLink" value="#{request.contextPath}/full/batch/batchJobsServer.jsf?target=server&isCluster=false&tabSetName=#{pageSession.encodedTabSetName}");
+ setPageSessionAttribute(key="listJobsLink" value="#{request.contextPath}/full/batch/batchJobsServer.jsf?target=server&offsetValue=#{pageSession.offsetValue}&isCluster=false&tabSetName=#{pageSession.encodedTabSetName}");
}
if("!(#{pageSession.target}=server)"){
- setPageSessionAttribute(key="listJobsLink" value="#{request.contextPath}/full/batch/batchJobsStandalone.jsf?target=#{pageSession.encodedTarget}&isCluster=false&tabSetName=#{pageSession.encodedTabSetName}");
+ setPageSessionAttribute(key="listJobsLink" value="#{request.contextPath}/full/batch/batchJobsStandalone.jsf?target=#{pageSession.encodedTarget}&offsetValue=#{pageSession.offsetValue}&isCluster=false&tabSetName=#{pageSession.encodedTabSetName}");
}
}
diff --git a/appserver/admingui/full/src/main/resources/org/glassfish/full/admingui/Strings.properties b/appserver/admingui/full/src/main/resources/org/glassfish/full/admingui/Strings.properties
index 4feaad7c0b8..fb465560933 100644
--- a/appserver/admingui/full/src/main/resources/org/glassfish/full/admingui/Strings.properties
+++ b/appserver/admingui/full/src/main/resources/org/glassfish/full/admingui/Strings.properties
@@ -167,6 +167,10 @@ batch.configuration.tablePrefix=Table Prefix
batch.configuration.tablePrefixHelp=Prefix to add to the table name (This may be ignored by non-rdbms based stores)
batch.configuration.tableSuffix=Table Suffix
batch.configuration.tableSuffixHelp=Suffix to add to the table name (This may be ignored by non-rdbms based stores)
+batch.pagination.perviousButton=<< Previous
+batch.pagination.nextButton=Next >>
+batch.pagination.goButton=Go
+batch.pagination.noJobsToDisplayMessage=There are no batch jobs to display
# End Payara Editions
tree.batch=Batch
diff --git a/appserver/batch/glassfish-batch-commands/src/main/java/org/glassfish/batch/AbstractListCommandProxy.java b/appserver/batch/glassfish-batch-commands/src/main/java/org/glassfish/batch/AbstractListCommandProxy.java
index 91b7223440f..59530e603ae 100644
--- a/appserver/batch/glassfish-batch-commands/src/main/java/org/glassfish/batch/AbstractListCommandProxy.java
+++ b/appserver/batch/glassfish-batch-commands/src/main/java/org/glassfish/batch/AbstractListCommandProxy.java
@@ -37,23 +37,17 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
-// Portions Copyright [2016] [Payara Foundation and/or its affiliates]
+// Portions Copyright [2016-2018] [Payara Foundation and/or its affiliates]
package org.glassfish.batch;
-import com.sun.enterprise.config.serverbeans.Domain;
import com.sun.enterprise.config.serverbeans.Server;
import com.sun.enterprise.util.SystemPropertyConstants;
import org.glassfish.api.ActionReport;
-import org.glassfish.api.I18n;
import org.glassfish.api.Param;
import org.glassfish.api.admin.*;
-import org.glassfish.config.support.CommandTarget;
-import org.glassfish.config.support.TargetType;
-import org.glassfish.hk2.api.PerLookup;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.internal.api.Target;
-import org.jvnet.hk2.annotations.Service;
import javax.inject.Inject;
import java.util.Properties;
diff --git a/appserver/batch/glassfish-batch-commands/src/main/java/org/glassfish/batch/ListBatchJobs.java b/appserver/batch/glassfish-batch-commands/src/main/java/org/glassfish/batch/ListBatchJobs.java
index baf11102553..83982694efd 100644
--- a/appserver/batch/glassfish-batch-commands/src/main/java/org/glassfish/batch/ListBatchJobs.java
+++ b/appserver/batch/glassfish-batch-commands/src/main/java/org/glassfish/batch/ListBatchJobs.java
@@ -44,6 +44,17 @@
import com.ibm.jbatch.spi.TaggedJobExecution;
import com.sun.enterprise.config.serverbeans.Domain;
import com.sun.enterprise.util.ColumnFormatter;
+import fish.payara.jbatch.persistence.rdbms.DB2PersistenceManager;
+import fish.payara.jbatch.persistence.rdbms.H2PersistenceManager;
+import fish.payara.jbatch.persistence.rdbms.JBatchJDBCPersistenceManager;
+import fish.payara.jbatch.persistence.rdbms.MySqlPersistenceManager;
+import fish.payara.jbatch.persistence.rdbms.OraclePersistenceManager;
+import fish.payara.jbatch.persistence.rdbms.PostgresPersistenceManager;
+import fish.payara.jbatch.persistence.rdbms.SQLServerPersistenceManager;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
import org.glassfish.api.I18n;
import org.glassfish.api.Param;
import org.glassfish.api.admin.*;
@@ -54,9 +65,16 @@
import javax.batch.operations.*;
import javax.batch.runtime.JobExecution;
-import javax.batch.runtime.JobInstance;
import java.util.*;
import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.inject.Inject;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+import javax.validation.constraints.Min;
+import org.glassfish.batch.spi.impl.BatchRuntimeConfiguration;
+import org.glassfish.batch.spi.impl.BatchRuntimeHelper;
/**
* Command to list batch jobs info
@@ -73,13 +91,13 @@
@ExecuteOn(value = {RuntimeType.INSTANCE})
@TargetType({CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG})
@RestEndpoints({
- @RestEndpoint(configBean = Domain.class,
- opType = RestEndpoint.OpType.GET,
- path = "_ListBatchJobs",
- description = "_List Batch Jobs")
+ @RestEndpoint(configBean = Domain.class,
+ opType = RestEndpoint.OpType.GET,
+ path = "_ListBatchJobs",
+ description = "_List Batch Jobs")
})
public class ListBatchJobs
- extends AbstractLongListCommand {
+ extends AbstractLongListCommand {
private static final String JOB_NAME = "jobName";
@@ -99,46 +117,282 @@ public class ListBatchJobs
private static final String START_TIME = "startTime";
private static final String END_TIME = "endTime";
+
+ private static final String GET_JOB_NAMES_QUERY = "SELECT DISTINCT name FROM JOBINSTANCEDATA";
@Param(primary = true, optional = true)
String jobName;
+
+ @Min(value = 0, message = "Offset value needs to be greter than 0")
+ @Param(name = "offset", optional = true, defaultValue = "0")
+ String offSetValue;
+ @Min(value = 0, message = "Limit value needs to be greter than 0")
+ @Param(name = "limit", optional = true, defaultValue = "2000")
+ String limitValue;
+
+ @Inject
+ BatchRuntimeHelper batchRuntimeHelper;
+
+ @Inject
+ BatchRuntimeConfiguration batchRuntimeConfiguration;
+
+ private DataSource dataSource;
+
@Override
protected void executeCommand(AdminCommandContext context, Properties extraProps)
- throws Exception {
-
- ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
- if (isSimpleMode()) {
- extraProps.put("simpleMode", true);
- extraProps.put("listBatchJobs", findSimpleJobInfo(columnFormatter));
- } else {
- extraProps.put("simpleMode", false);
- List