stageEntity.setCluster(clusterEntity);
clusterEntity.getStages().add(stageEntity);
for (HostRoleCommand hostRoleCommand : stage.getOrderedHostRoleCommands()) {
HostRoleCommandEntity hostRoleCommandEntity = hostRoleCommand.constructNewPersistenceEntity();
stageEntity.getHostRoleCommands().add(hostRoleCommandEntity);
hostRoleCommandEntity.setStage(stageEntity);
HostEntity hostEntity = hostDAO.findByName(hostRoleCommandEntity.getHostName());
if (hostEntity == null) {
LOG.error("Host {} doesn't exists in database" + hostRoleCommandEntity.getHostName());
throw new RuntimeException("Host '"+hostRoleCommandEntity.getHostName()+"' doesn't exists in database");
}
hostEntity.getHostRoleCommandEntities().add(hostRoleCommandEntity);
hostRoleCommandEntity.setHost(hostEntity);
hostRoleCommandDAO.create(hostRoleCommandEntity);
assert hostRoleCommandEntity.getTaskId() != null;
hostRoleCommand.setTaskId(hostRoleCommandEntity.getTaskId());
ExecutionCommandEntity executionCommandEntity = hostRoleCommand.constructExecutionCommandEntity();
executionCommandEntity.setHostRoleCommand(hostRoleCommandEntity);
hostRoleCommandEntity.setExecutionCommand(executionCommandEntity);
executionCommandDAO.create(hostRoleCommandEntity.getExecutionCommand());
hostRoleCommandDAO.merge(hostRoleCommandEntity);
hostDAO.merge(hostEntity);
}
for (RoleSuccessCriteriaEntity roleSuccessCriteriaEntity : stageEntity.getRoleSuccessCriterias()) {