@Transactional
@Override
public CommandProcessingResult updateMapping(final Long mappingId, final JsonCommand command) {
try {
MixTaxonomyMapping mapping = this.mappingRepository.findOne(mappingId);
if (mapping == null) {
mapping = MixTaxonomyMapping.fromJson(command);
} else {
mapping.update(command);
}
this.mappingRepository.saveAndFlush(mapping);
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(mapping.getId()).build();
} catch (final DataIntegrityViolationException dve) {
return CommandProcessingResult.empty();
}
}