use of org.camunda.bpm.engine.rest.dto.converter.DateConverter in project camunda-bpm-platform by camunda.
the class MetricsResourceImpl method applyQueryParams.
protected void applyQueryParams(MetricsQuery query, UriInfo uriInfo) {
MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
DateConverter dateConverter = new DateConverter();
dateConverter.setObjectMapper(objectMapper);
if (queryParameters.getFirst("startDate") != null) {
Date startDate = dateConverter.convertQueryParameterToType(queryParameters.getFirst("startDate"));
query.startDate(startDate);
}
if (queryParameters.getFirst("endDate") != null) {
Date endDate = dateConverter.convertQueryParameterToType(queryParameters.getFirst("endDate"));
query.endDate(endDate);
}
}
use of org.camunda.bpm.engine.rest.dto.converter.DateConverter in project camunda-bpm-platform by camunda.
the class MetricsRestServiceImpl method applyQueryParams.
protected void applyQueryParams(MetricsQuery query, MultivaluedMap<String, String> queryParameters) {
DateConverter dateConverter = new DateConverter();
dateConverter.setObjectMapper(objectMapper);
if (queryParameters.getFirst(QUERY_PARAM_START_DATE) != null) {
Date startDate = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_START_DATE));
query.startDate(startDate);
}
if (queryParameters.getFirst(QUERY_PARAM_END_DATE) != null) {
Date endDate = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_END_DATE));
query.endDate(endDate);
}
IntegerConverter intConverter = new IntegerConverter();
intConverter.setObjectMapper(objectMapper);
if (queryParameters.getFirst(QUERY_PARAM_FIRST_RESULT) != null) {
int firstResult = intConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_FIRST_RESULT));
query.offset(firstResult);
}
if (queryParameters.getFirst(QUERY_PARAM_MAX_RESULTS) != null) {
int maxResults = intConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_MAX_RESULTS));
query.limit(maxResults);
}
}
use of org.camunda.bpm.engine.rest.dto.converter.DateConverter in project camunda-bpm-platform by camunda.
the class HistoricProcessDefinitionRestServiceImpl method getHistoricActivityStatistics.
@Override
public List<HistoricActivityStatisticsDto> getHistoricActivityStatistics(UriInfo uriInfo, String processDefinitionId, Boolean includeCanceled, Boolean includeFinished, Boolean includeCompleteScope, String sortBy, String sortOrder) {
HistoryService historyService = processEngine.getHistoryService();
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId);
if (includeCanceled != null && includeCanceled) {
query.includeCanceled();
}
if (includeFinished != null && includeFinished) {
query.includeFinished();
}
if (includeCompleteScope != null && includeCompleteScope) {
query.includeCompleteScope();
}
final MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
DateConverter dateConverter = new DateConverter();
dateConverter.setObjectMapper(objectMapper);
if (queryParameters.getFirst(QUERY_PARAM_STARTED_AFTER) != null) {
Date startedAfter = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_STARTED_AFTER));
query.startedAfter(startedAfter);
}
if (queryParameters.getFirst(QUERY_PARAM_STARTED_BEFORE) != null) {
Date startedBefore = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_STARTED_BEFORE));
query.startedBefore(startedBefore);
}
if (queryParameters.getFirst(QUERY_PARAM_FINISHED_AFTER) != null) {
Date finishedAfter = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_FINISHED_AFTER));
query.finishedAfter(finishedAfter);
}
if (queryParameters.getFirst(QUERY_PARAM_FINISHED_BEFORE) != null) {
Date finishedBefore = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_FINISHED_BEFORE));
query.finishedBefore(finishedBefore);
}
setSortOptions(query, sortOrder, sortBy);
List<HistoricActivityStatisticsDto> result = new ArrayList<HistoricActivityStatisticsDto>();
List<HistoricActivityStatistics> statistics = query.list();
for (HistoricActivityStatistics currentStatistics : statistics) {
result.add(HistoricActivityStatisticsDto.fromHistoricActivityStatistics(currentStatistics));
}
return result;
}
use of org.camunda.bpm.engine.rest.dto.converter.DateConverter in project camunda-bpm-platform by camunda.
the class JobQueryDto method applyFilters.
@Override
protected void applyFilters(JobQuery query) {
if (activityId != null) {
query.activityId(activityId);
}
if (jobId != null) {
query.jobId(jobId);
}
if (executionId != null) {
query.executionId(executionId);
}
if (processInstanceId != null) {
query.processInstanceId(processInstanceId);
}
if (processDefinitionId != null) {
query.processDefinitionId(processDefinitionId);
}
if (processDefinitionKey != null) {
query.processDefinitionKey(processDefinitionKey);
}
if (TRUE.equals(withRetriesLeft)) {
query.withRetriesLeft();
}
if (TRUE.equals(executable)) {
query.executable();
}
if (TRUE.equals(timers)) {
if (messages != null && messages) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Parameter timers cannot be used together with parameter messages.");
}
query.timers();
}
if (TRUE.equals(messages)) {
if (timers != null && timers) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Parameter messages cannot be used together with parameter timers.");
}
query.messages();
}
if (TRUE.equals(withException)) {
query.withException();
}
if (exceptionMessage != null) {
query.exceptionMessage(exceptionMessage);
}
if (TRUE.equals(noRetriesLeft)) {
query.noRetriesLeft();
}
if (TRUE.equals(active)) {
query.active();
}
if (TRUE.equals(suspended)) {
query.suspended();
}
if (priorityHigherThanOrEquals != null) {
query.priorityHigherThanOrEquals(priorityHigherThanOrEquals);
}
if (priorityLowerThanOrEquals != null) {
query.priorityLowerThanOrEquals(priorityLowerThanOrEquals);
}
if (jobDefinitionId != null) {
query.jobDefinitionId(jobDefinitionId);
}
if (dueDates != null) {
DateConverter dateConverter = new DateConverter();
dateConverter.setObjectMapper(objectMapper);
for (ConditionQueryParameterDto conditionQueryParam : dueDates) {
String op = conditionQueryParam.getOperator();
Date dueDate = null;
try {
dueDate = dateConverter.convertQueryParameterToType((String) conditionQueryParam.getValue());
} catch (RestException e) {
throw new InvalidRequestException(e.getStatus(), e, "Invalid due date format: " + e.getMessage());
}
if (op.equals(ConditionQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
query.duedateHigherThan(dueDate);
} else if (op.equals(ConditionQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
query.duedateLowerThan(dueDate);
} else {
throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid due date comparator specified: " + op);
}
}
}
if (tenantIds != null && !tenantIds.isEmpty()) {
query.tenantIdIn(tenantIds.toArray(new String[tenantIds.size()]));
}
if (TRUE.equals(withoutTenantId)) {
query.withoutTenantId();
}
if (TRUE.equals(includeJobsWithoutTenantId)) {
query.includeJobsWithoutTenantId();
}
}
Aggregations