Search in sources :

Example 1 with BatchSummaries

use of org.jumpmind.symmetric.web.rest.model.BatchSummaries in project symmetric-ds by JumpMind.

the class RestService method getOutgoingBatchSummary.

@ApiOperation(value = "Outgoing summary of batches and data counts waiting for a node")
@RequestMapping(value = "/engine/{engine}/outgoingBatchSummary", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public final BatchSummaries getOutgoingBatchSummary(@PathVariable("engine") String engineName, @RequestParam(value = WebConstants.NODE_ID) String nodeId, @ApiParam(value = "This the password for the nodeId being passed in.  The password is stored in the node_security table.") @RequestParam(value = WebConstants.SECURITY_TOKEN) String securityToken) {
    ISymmetricEngine engine = getSymmetricEngine(engineName);
    if (securityVerified(nodeId, engine, securityToken)) {
        BatchSummaries summaries = new BatchSummaries();
        summaries.setNodeId(nodeId);
        IOutgoingBatchService outgoingBatchService = engine.getOutgoingBatchService();
        List<OutgoingBatchSummary> list = outgoingBatchService.findOutgoingBatchSummary(OutgoingBatch.Status.RQ, OutgoingBatch.Status.QY, OutgoingBatch.Status.NE, OutgoingBatch.Status.SE, OutgoingBatch.Status.LD, OutgoingBatch.Status.ER);
        for (OutgoingBatchSummary sum : list) {
            if (sum.getNodeId().equals(nodeId)) {
                BatchSummary summary = new BatchSummary();
                summary.setBatchCount(sum.getBatchCount());
                summary.setDataCount(sum.getDataCount());
                summary.setOldestBatchCreateTime(sum.getOldestBatchCreateTime());
                summary.setStatus(sum.getStatus().name());
                summaries.getBatchSummaries().add(summary);
            }
        }
        return summaries;
    } else {
        throw new NotAllowedException();
    }
}
Also used : BatchSummary(org.jumpmind.symmetric.web.rest.model.BatchSummary) OutgoingBatchSummary(org.jumpmind.symmetric.model.OutgoingBatchSummary) OutgoingBatchSummary(org.jumpmind.symmetric.model.OutgoingBatchSummary) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) IOutgoingBatchService(org.jumpmind.symmetric.service.IOutgoingBatchService) BatchSummaries(org.jumpmind.symmetric.web.rest.model.BatchSummaries) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 ISymmetricEngine (org.jumpmind.symmetric.ISymmetricEngine)1 OutgoingBatchSummary (org.jumpmind.symmetric.model.OutgoingBatchSummary)1 IOutgoingBatchService (org.jumpmind.symmetric.service.IOutgoingBatchService)1 BatchSummaries (org.jumpmind.symmetric.web.rest.model.BatchSummaries)1 BatchSummary (org.jumpmind.symmetric.web.rest.model.BatchSummary)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1