@Override public StatusBean delete(String projectID) { StatusBean statusBean = new StatusBean(); try { projectDao .updateBuilder() .updateColumnValue("isDisabled", true) .where() .idEq(Integer.parseInt(projectID)); List<MachineConfigurationBean> machineConfigList = MachineConfigDAOManager.getInstance().retireveBoxesForProject(projectID); for (MachineConfigurationBean machineConfig : machineConfigList) { MachineConfigDAOManager.getInstance().delete(machineConfig.getMachineID().toString()); } } catch (SQLException e) { logger.error("Error deleting a project : " + e.getMessage()); statusBean.setStatusCode(1); statusBean.setStatusMessage("Error deleting a project : " + e.getMessage()); e.printStackTrace(); } statusBean.setStatusCode(0); statusBean.setStatusMessage("Project deleted successfully"); return statusBean; }
public StatusBean delete(JsonNode projectData) { StatusBean statusBean = new StatusBean(); Integer userID = Integer.parseInt(projectData.get("userID").getTextValue()); Integer projectID = Integer.parseInt(projectData.get("projectID").getTextValue()); String location = Utilities.getInstance().fetchActiveProjectDirectory(userID); try { ProjectBean project = projectDao.queryForId(projectID); project.setIsDisabled(true); projectDao.update(project); List<MachineConfigurationBean> machineConfigList = MachineConfigDAOManager.getInstance().retireveBoxesForProject(projectID.toString()); for (MachineConfigurationBean machineConfig : machineConfigList) { MachineConfigDAOManager.getInstance().delete(machineConfig.getMachineID().toString()); String vagrantCommand = "vagrant destroy " + machineConfig.getVagrantID(); VagrantCommandProcessor shellProcessor = new VagrantCommandProcessor(); try { shellProcessor.executeVagrantFile( location, vagrantCommand, userID, new VagrantOutputStream()); } catch (IOException e) { statusBean.setStatusCode(1); statusBean.setStatusMessage("error in destroting box" + e.getMessage()); } catch (InterruptedException e) { statusBean.setStatusCode(1); statusBean.setStatusMessage("error in destroting box" + e.getMessage()); } } } catch (SQLException e) { logger.error("Error deleting a project : " + e.getMessage()); statusBean.setStatusCode(1); statusBean.setStatusMessage("Error deleting a project : " + e.getMessage()); e.printStackTrace(); } statusBean.setStatusCode(0); statusBean.setStatusMessage("Project deleted successfully"); return statusBean; }