public void initFrom(ConsumerGroupSPI group) { setName(group.getName()); setStatus(group.getStatus()); try { for (Consumer consumer : group.getConsumers()) { String id = consumer.getPersistentKey(); ConsumerMapping cm = findConsumerById(id); ParameterValidation.throwIllegalArgExceptionIfNull( cm, "ConsumerMapping (no such mapping with id: " + id + ")"); getConsumers().add(cm); cm.initFrom((ConsumerSPI) consumer); } } catch (RegistrationException e) { throw new RuntimeException(e); } }
@Override protected ConsumerSPI internalSaveChangesTo(Consumer consumer) throws RegistrationException { ConsumerSPI consumerSPI = super.internalSaveChangesTo(consumer); ChromatticSession session = persister.getSession(); try { ConsumerMapping cm = session.findById(ConsumerMapping.class, consumer.getPersistentKey()); cm.initFrom(consumer); persister.closeSession(true); } catch (Exception e) { persister.closeSession(false); throw new RegistrationException(e); } return consumerSPI; }