(String) properties.get(REQUEST_SCHEDULE_DESC_PROPERTY_ID),
(String) properties.get(REQUEST_SCHEDULE_STATUS_PROPERTY_ID),
null,
null);
Batch batch = new Batch();
BatchSettings batchSettings = new BatchSettings();
List<BatchRequest> batchRequests = new ArrayList<BatchRequest>();
Object batchObject = properties.get(REQUEST_SCHEDULE_BATCH_PROPERTY_ID);
if (batchObject != null && batchObject instanceof HashSet<?>) {
try {
HashSet<Map<String, Object>> batchMap = (HashSet<Map<String, Object>>) batchObject;
for (Map<String, Object> batchEntry : batchMap) {
if (batchEntry != null) {
for (Map.Entry<String, Object> batchMapEntry : batchEntry.entrySet()) {
if (batchMapEntry.getKey().equals
(REQUEST_SCHEDULE_BATCH_TOLERATION_PROPERTY_ID)) {
batchSettings.setTaskFailureToleranceLimit(Integer.valueOf
((String) batchMapEntry.getValue()));
} else if (batchMapEntry.getKey().equals
(REQUEST_SCHEDULE_BATCH_SEPARATION_PROPERTY_ID)) {
batchSettings.setBatchSeparationInSeconds(Integer.valueOf
((String) batchMapEntry.getValue()));
} else if (batchMapEntry.getKey().equals
(REQUEST_SCHEDULE_BATCH_REQUESTS_PROPERTY_ID)) {
HashSet<Map<String, Object>> requestSet =
(HashSet<Map<String, Object>>) batchMapEntry.getValue();
for (Map<String, Object> requestEntry : requestSet) {
if (requestEntry != null) {
BatchRequest batchRequest = new BatchRequest();
for (Map.Entry<String, Object> requestMapEntry :
requestEntry.entrySet()) {
if (requestMapEntry.getKey()
.equals(BATCH_REQUEST_TYPE_PROPERTY_ID)) {
batchRequest.setType(BatchRequest.Type.valueOf
((String) requestMapEntry.getValue()));
} else if (requestMapEntry.getKey()
.equals(BATCH_REQUEST_URI_PROPERTY_ID)) {
batchRequest.setUri(
(String) requestMapEntry.getValue());
} else if (requestMapEntry.getKey()
.equals(BATCH_REQUEST_ORDER_ID_PROPERTY_ID)) {
batchRequest.setOrderId(Long.parseLong(
(String) requestMapEntry.getValue()));
} else if (requestMapEntry.getKey()
.equals(BATCH_REQUEST_BODY_PROPERTY_ID)) {
batchRequest.setBody(
(String) requestMapEntry.getValue());
}
}
batchRequests.add(batchRequest);
}
}
}
}
}
}
batch.getBatchRequests().addAll(batchRequests);
batch.setBatchSettings(batchSettings);
} catch (Exception e) {
LOG.warn("Request Schedule batch json is unparseable. " +
batchObject, e);
}