@Override public boolean delete(ProgramStageSection object) { List<ProgramIndicatorToProgramStageSectionRelation$Flow> programIndicatorToProgramStageSectionRelationFlows = new Select() .from(ProgramIndicatorToProgramStageSectionRelation$Flow.class) .where( Condition.column( ProgramIndicatorToProgramStageSectionRelation$Flow$Table .PROGRAMSTAGESECTION_PROGRAMSTAGESECTION) .is(object.getUId())) .queryList(); for (ProgramIndicatorToProgramStageSectionRelation$Flow programIndicatorToProgramStageSectionRelationFlow : programIndicatorToProgramStageSectionRelationFlows) { programIndicatorToProgramStageSectionRelationFlow.delete(); } getMapper().mapToDatabaseEntity(object).delete(); return true; }
@Override public boolean save(ProgramStageSection object) { ProgramStageSection$Flow programStageSectionFlow = getMapper().mapToDatabaseEntity(object); programStageSectionFlow.save(); object.setId(programStageSectionFlow.getId()); // saving programindicator programstagesection relationship List<ProgramIndicator$Flow> programIndicatorFlows = programStageSectionFlow.getProgramIndicators(); if (programIndicatorFlows != null) { for (ProgramIndicator$Flow programIndicatorFlow : programIndicatorFlows) { ProgramIndicatorToProgramStageSectionRelation$Flow relationFlow = new ProgramIndicatorToProgramStageSectionRelation$Flow(); relationFlow.setProgramIndicator(programIndicatorFlow); relationFlow.setProgramStageSection(programStageSectionFlow); relationFlow.save(); } } return true; }