persistComponentEntities(stateEntity, desiredStateEntity, serviceComponentDesiredStateEntity);
}
}
private void persistComponentEntities(HostComponentStateEntity stateEntity, HostComponentDesiredStateEntity desiredStateEntity, ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity) {
ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO = injector.getInstance(ServiceComponentDesiredStateDAO.class);
HostComponentStateDAO hostComponentStateDAO = injector.getInstance(HostComponentStateDAO.class);
HostComponentDesiredStateDAO hostComponentDesiredStateDAO = injector.getInstance(HostComponentDesiredStateDAO.class);
HostDAO hostDAO = injector.getInstance(HostDAO.class);
HostEntity hostEntity = hostDAO.findByName(stateEntity.getHostName());
hostEntity.getHostComponentStateEntities().add(stateEntity);
hostEntity.getHostComponentDesiredStateEntities().add(desiredStateEntity);
serviceComponentDesiredStateEntity.getHostComponentDesiredStateEntities().add(desiredStateEntity);
desiredStateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
desiredStateEntity.setHostEntity(hostEntity);
stateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
stateEntity.setHostEntity(hostEntity);
hostComponentStateDAO.create(stateEntity);
hostComponentDesiredStateDAO.create(desiredStateEntity);
serviceComponentDesiredStateDAO.create(serviceComponentDesiredStateEntity);
hostDAO.merge(hostEntity);
}