/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.camunda.bpm.engine.rest.dto.history;

import java.util.ArrayList;
import java.util.List;

import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReport;
import org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReportResult;

public class CleanableHistoricProcessInstanceReportResultDto {

  protected String processDefinitionId;
  protected String processDefinitionKey;
  protected String processDefinitionName;
  protected int processDefinitionVersion;
  protected Integer historyTimeToLive;
  protected long finishedProcessInstancesCount;
  protected long cleanableProcessInstancesCount;

  public CleanableHistoricProcessInstanceReportResultDto() {
  }

  public void setProcessDefinitionId(String processDefinitionId) {
    this.processDefinitionId = processDefinitionId;
  }

  public void setProcessDefinitionKey(String processDefinitionKey) {
    this.processDefinitionKey = processDefinitionKey;
  }

  public void setProcessDefinitionName(String processDefinitionName) {
    this.processDefinitionName = processDefinitionName;
  }

  public void setProcessDefinitionVersion(int processDefinitionVersion) {
    this.processDefinitionVersion = processDefinitionVersion;
  }

  public void setHistoryTimeToLive(Integer historyTimeToLive) {
    this.historyTimeToLive = historyTimeToLive;
  }

  public void setFinishedProcessInstancesCount(Long finishedProcessInstancesCount) {
    this.finishedProcessInstancesCount = finishedProcessInstancesCount;
  }

  public void setCleanableProcessInstancesCount(Long cleanableProcessInstancesCount) {
    this.cleanableProcessInstancesCount = cleanableProcessInstancesCount;
  }

  public String getProcessDefinitionId() {
    return processDefinitionId;
  }

  public String getProcessDefinitionKey() {
    return processDefinitionKey;
  }

  public String getProcessDefinitionName() {
    return processDefinitionName;
  }

  public int getProcessDefinitionVersion() {
    return processDefinitionVersion;
  }

  public Integer getHistoryTimeToLive() {
    return historyTimeToLive;
  }

  public Long getFinishedProcessInstancesCount() {
    return finishedProcessInstancesCount;
  }

  public Long getCleanableProcessInstancesCount() {
    return cleanableProcessInstancesCount;
  }

  protected CleanableHistoricProcessInstanceReport createNewReportQuery(ProcessEngine engine) {
    return engine.getHistoryService().createCleanableHistoricProcessInstanceReport();
  }

  public static List<CleanableHistoricProcessInstanceReportResultDto> convert(List<CleanableHistoricProcessInstanceReportResult> reportResult) {
    List<CleanableHistoricProcessInstanceReportResultDto> dtos = new ArrayList<CleanableHistoricProcessInstanceReportResultDto>();
    for (CleanableHistoricProcessInstanceReportResult current : reportResult) {
      CleanableHistoricProcessInstanceReportResultDto dto = new CleanableHistoricProcessInstanceReportResultDto();
      dto.setProcessDefinitionId(current.getProcessDefinitionId());
      dto.setProcessDefinitionKey(current.getProcessDefinitionKey());
      dto.setProcessDefinitionName(current.getProcessDefinitionName());
      dto.setProcessDefinitionVersion(current.getProcessDefinitionVersion());
      dto.setHistoryTimeToLive(current.getHistoryTimeToLive());
      dto.setFinishedProcessInstancesCount(current.getFinishedProcessInstanceCount());
      dto.setCleanableProcessInstancesCount(current.getCleanableProcessInstanceCount());
      dtos.add(dto);
    }
    return dtos;
  }

}

@@ -1193,33 +1193,32 @@
 dProcessInstance
-s
 Count;%0D%0A  protec
@@ -1242,33 +1242,32 @@
 eProcessInstance
-s
 Count;%0D%0A%0D%0A  publ
@@ -2023,33 +2023,32 @@
 dProcessInstance
-s
 Count(Long finis
@@ -2057,33 +2057,32 @@
 dProcessInstance
-s
 Count) %7B%0D%0A    th
@@ -2099,33 +2099,32 @@
 dProcessInstance
-s
 Count = finished
@@ -2130,33 +2130,32 @@
 dProcessInstance
-s
 Count;%0D%0A  %7D%0D%0A%0D%0A 
@@ -2190,25 +2190,24 @@
 cessInstance
-s
 Count(Long c
@@ -2225,25 +2225,24 @@
 cessInstance
-s
 Count) %7B%0D%0A  
@@ -2268,25 +2268,24 @@
 cessInstance
-s
 Count = clea
@@ -2296,33 +2296,32 @@
 eProcessInstance
-s
 Count;%0D%0A  %7D%0D%0A%0D%0A 
@@ -2781,33 +2781,32 @@
 dProcessInstance
-s
 Count() %7B%0D%0A    r
@@ -2826,33 +2826,32 @@
 dProcessInstance
-s
 Count;%0D%0A  %7D%0D%0A%0D%0A 
@@ -2933,25 +2933,24 @@
 cessInstance
-s
 Count;%0D%0A  %7D%0D
@@ -4003,33 +4003,32 @@
 dProcessInstance
-s
 Count(current.ge
@@ -4095,25 +4095,24 @@
 cessInstance
-s
 Count(curren

rename *instancesCount to *instanceCount