class UpsertIntoCachedCollectionTask implements IDatabaseTask {

    @Override
    public void prepare(final IObject query) throws TaskPrepareException {

        try {
            if (startDateTimeField.in(query) == null) {
                startDateTimeField.out(query, LocalDateTime.now().format(formatter));
            }
            upsertTask = IOC.resolve(
                Keys.getOrAdd("db.collection.upsert"),
                connection,
                collectionNameField.in(query),
                documentField.in(query)
            );
        } catch (InvalidArgumentException | ReadValueException | ChangeValueException | ResolutionException e) {
            throw new TaskPrepareException("Can't prepare query for upsert into cached collection", e);
        }
    }

    public  UpsertIntoCachedCollectionTask(final IStorageConnection connection);

}