/** * Deletes the given object from its DynamoDB table. * @param object The object to delete. * @see com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper#delete */ public final void delete(final T object) { mapper.delete(object); }
/** * Deletes the given object from its DynamoDB table using the specified * deleteExpression. * @param object The object to delete. * @param deleteExpression The delete expression. * @see com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper#delete */ public final void delete(final T object, final DynamoDBDeleteExpression deleteExpression) { mapper.delete(object, deleteExpression); }
@Override public void deleteEnvironment(@NonNull final EnvironmentId environmentId) throws InternalServiceException { try { dynamoDBMapper.delete( EnvironmentDDBRecord.withKeys( environmentId.generateAccountIdCluster(), environmentId.getEnvironmentName()), SaveBehavior.CLOBBER.config()); } catch (final AmazonServiceException e) { throw new InternalServiceException( String.format( "Fail to delete environment with accountIdCluster %s and environment name %s", environmentId.generateAccountIdCluster(), environmentId.getEnvironmentName()), e); } } }
@Test public void testDeleteEnvironmentSuccess() throws Exception { doNothing() .when(dynamoDBMapper) .delete(any(EnvironmentDDBRecord.class), eq(SaveBehavior.CLOBBER.config())); environmentRepositoryDDB.deleteEnvironment(environmentId); verify(dynamoDBMapper, times(1)) .delete(environmentDDBRecordArgumentCaptor.capture(), eq(SaveBehavior.CLOBBER.config())); assertEquals( environmentId.generateAccountIdCluster(), environmentDDBRecordArgumentCaptor.getValue().getAccountIdCluster()); assertEquals( environmentId.getEnvironmentName(), environmentDDBRecordArgumentCaptor.getValue().getEnvironmentName()); }
@Override public void deleteEnvironmentRevision(@NonNull final EnvironmentRevision environmentRevision) throws InternalServiceException { try { dynamoDBMapper.delete( EnvironmentRevisionDDBRecord.withKeys( environmentRevision.getEnvironmentId().generateAccountIdClusterEnvironmentName(), environmentRevision.getEnvironmentRevisionId()), SaveBehavior.CLOBBER.config()); } catch (final AmazonServiceException e) { throw new InternalServiceException( String.format( "Could not delete environment revision with accountIdClusterEnvironmentName %s and environment revision %s", environmentRevision.getEnvironmentId().toString(), environmentRevision.getEnvironmentRevisionId()), e); } }
@Test public void testDeleteEnvironmentInternalError() throws Exception { doThrow(AmazonServiceException.class) .when(dynamoDBMapper) .delete(any(EnvironmentDDBRecord.class), eq(SaveBehavior.CLOBBER.config())); thrown.expect(InternalServiceException.class); thrown.expectMessage( "Fail to delete environment with accountIdCluster 123456789012/mycluster and environment name myenv"); environmentRepositoryDDB.deleteEnvironment(environmentId); } }
/** * Deletes the given object from its DynamoDB table with the condition that * the hash and, if applicable, the range key, already exist. * @param object The object to delete. * @throws ConditionalCheckFailedException If the object does not exist. * @see com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper#delete * @see com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBDeleteExpression * @see com.amazonaws.services.dynamodbv2.model.ExpectedAttributeValue */ public void deleteIfExists(T object) throws ConditionalCheckFailedException { final DynamoDBDeleteExpression deleteExpression = new DynamoDBDeleteExpression(); for (final DynamoDBMapperFieldModel<T,Object> key : model.keys()) { deleteExpression.withExpectedEntry(key.name(), new ExpectedAttributeValue() .withExists(true).withValue(key.convert(key.get(object)))); } mapper.delete(object, deleteExpression); }
/** * Deletes the given object from its DynamoDB table. * @param object The object to delete. * @see com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper#delete */ public final void delete(final T object) { mapper.delete(object); }
/** * Deletes the given object from its DynamoDB table using the specified * deleteExpression. * @param object The object to delete. * @param deleteExpression The delete expression. * @see com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper#delete */ public final void delete(final T object, final DynamoDBDeleteExpression deleteExpression) { mapper.delete(object, deleteExpression); }
@Override public Void call() throws Exception { txManager.getClientMapper().delete(item); return null; } });
@Override public void deleteEvent(String team, Long eventDate) { Optional<Event> oEvent = findEventByTeamAndDate(team, eventDate); if (oEvent.isPresent()) { mapper.delete(oEvent.get()); } else { log.error("Could not delete event, no such team and date combination"); throw new IllegalArgumentException("Delete failed for nonexistent event"); } } }
public void deleteSession(String sessionId) { mapper.delete(new DynamoSessionItem(sessionId)); }
@Override public void delete(String username) { final User user = new User(); user.setUsername(username); this.dynamoDBMapper.delete(user); }
@Override public <T> T delete(T entity) { maybeEmitEvent(entity, BeforeDeleteEvent::new); dynamoDBMapper.delete(entity); maybeEmitEvent(entity, AfterDeleteEvent::new); return entity; }
mapper.delete(object); return true; } catch (Exception e) {
@Override public void delete(Object entity) { maybeEmitEvent(new BeforeDeleteEvent<Object>(entity)); dynamoDBMapper.delete(entity); maybeEmitEvent(new AfterDeleteEvent<Object>(entity)); }
mapper.delete(updatedItem);
/** * Deletes the given object from its DynamoDB table with the condition that * the hash and, if applicable, the range key, already exist. * @param object The object to delete. * @throws ConditionalCheckFailedException If the object does not exist. * @see com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper#delete * @see com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBDeleteExpression * @see com.amazonaws.services.dynamodbv2.model.ExpectedAttributeValue */ public void deleteIfExists(T object) throws ConditionalCheckFailedException { final DynamoDBDeleteExpression deleteExpression = new DynamoDBDeleteExpression(); for (final DynamoDBMapperFieldModel<T,Object> key : model.keys()) { deleteExpression.withExpectedEntry(key.name(), new ExpectedAttributeValue() .withExists(true).withValue(key.convert(key.get(object)))); } mapper.delete(object, deleteExpression); }