public boolean updateWorkflowSummary()

in amazon-ecs-java-starter-kit-taskmonitor/src/main/java/software/aws/ecs/java/starterkit/util/DDBUtil.java [136:175]


	public boolean updateWorkflowSummary(DynamoDbClient dynamoDB, String tableName, String hashKey, String rangeKey,
			String workflowName, long workflowRunId, String status, String time, int completedTasks, int failedTasks,
			int runningTasks) {
		boolean operationSuccess = false;

		// populate Hash Key and Range Key
		Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
		key.put(hashKey, AttributeValue.builder().s(workflowName).build());
		key.put(rangeKey, AttributeValue.builder().n(Long.toString(workflowRunId)).build());

		AttributeAction action = AttributeAction.PUT;
		Map<String, AttributeValueUpdate> attributeUpdates = new HashMap<String, AttributeValueUpdate>();
		attributeUpdates.put("status", AttributeValueUpdate.builder().action(action)
				.value(AttributeValue.builder().s(status).build()).build());
		attributeUpdates.put("update_time",
				AttributeValueUpdate.builder().action(action).value(AttributeValue.builder().s(time).build()).build());
		attributeUpdates.put("completed_tasks",
				AttributeValueUpdate.builder().action(action).value(AttributeValue.builder().n(Integer.toString(completedTasks)).build()).build());
		attributeUpdates.put("failed_tasks",
				AttributeValueUpdate.builder().action(action).value(AttributeValue.builder().n(Integer.toString(failedTasks)).build()).build());
		attributeUpdates.put("running_tasks",
				AttributeValueUpdate.builder().action(action).value(AttributeValue.builder().n(Integer.toString(runningTasks)).build()).build());

		UpdateItemRequest updateItemRequest = UpdateItemRequest.builder().tableName(tableName).key(key)
				.attributeUpdates(attributeUpdates).build();
		try {
			UpdateItemResponse updateItemResponse = dynamoDB.updateItem(updateItemRequest);
			if (updateItemResponse.sdkHttpResponse().isSuccessful()) {
				operationSuccess = true;
				System.out.printf("Update item operation with hash_key: %s and range_key: %d was successful. \n",
						workflowName, workflowRunId);
			} else
				System.out.printf("Update item operation with hash_key: %s and range_key: %d was not successful. \n",
						workflowName, workflowRunId);
		} catch (ResourceNotFoundException e) {
			e.printStackTrace();
			System.out.println("Table not found");
		}
		return operationSuccess;
	}