private DrawingGraphicFindingQuestionVo getInactiveRecord(QuestionInformationShortVo voQInfoShort) { DrawingGraphicFindingQuestionVoCollection voColl = form.getLocalContext().getInactiveFindingQuestions(); for (int i = 0; voColl != null && i < voColl.size(); i++) { if (voColl.get(i).getQuestionIsNotNull() && voColl.get(i).getQuestion().equals(voQInfoShort)) { DrawingGraphicFindingQuestionVo voDrawingGraphicFindingQuestion = voColl.get(i); voColl.remove(voDrawingGraphicFindingQuestion); form.getLocalContext().setInactiveFindingQuestions(voColl); return voDrawingGraphicFindingQuestion; } } return null; }
public DrawingGraphicFindingQuestionVoCollection saveDrawingGraphicFindings(DrawingGraphicFindingQuestionVoCollection voColl) throws StaleObjectException { if(voColl == null) throw new RuntimeException("Cannot save null values for DrawingGraphicFindingQuestionVoCollection"); if(voColl.isValidated() == false) throw new CodingRuntimeException("DrawingGraphicFindingQuestionVoCollection has not been validated"); DomainFactory factory = getDomainFactory(); ArrayList doList = new ArrayList(); for(int i=0; i<voColl.size(); i++) { DrawingGraphicFindingQuestion doDrawingGraphicFindingQuestion = DrawingGraphicFindingQuestionVoAssembler.extractDrawingGraphicFindingQuestion(factory, voColl.get(i)); factory.save(doDrawingGraphicFindingQuestion); doList.add(doDrawingGraphicFindingQuestion); } return DrawingGraphicFindingQuestionVoAssembler.createDrawingGraphicFindingQuestionVoCollectionFromDrawingGraphicFindingQuestion(doList); }
/** * List active finding questions */ public DrawingGraphicFindingQuestionVoCollection listDrawingGraphicFindings(Integer findingId) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer("select dgfq from DrawingGraphicFindingQuestion as dgfq left join dgfq.question as dgql where (dgfq.drawingGraphicFinding.id = :findID and dgql.status.id != :statusID) order by dgfq.order asc "); //wdev-10987 ArrayList names = new ArrayList(); ArrayList values = new ArrayList(); names.add("findID"); values.add(findingId); names.add("statusID"); values.add(getDomLookup(PreActiveActiveInactiveStatus.INACTIVE).getId()); List findingsList = factory.find(hql.toString(), names, values); return DrawingGraphicFindingQuestionVoAssembler.createDrawingGraphicFindingQuestionVoCollectionFromDrawingGraphicFindingQuestion(findingsList); }
private boolean save() { DrawingGraphicFindingVo voDGFsaved = saveDrawingGraphicFinding(); if (voDGFsaved == null) return false; //DrawingGraphicFindingQuestionVo voDrawingGraphicFinding = form.getLocalContext().getVoDrawingGraphicFindingQuestion(); //Save the finding to the rest of Drawing Grapgic Finding Question //-------------------------------------------------------------------------------------------- form.getLocalContext().setInactiveFindingQuestions( refreshInactiveFindingQuestions(voDGFsaved)); //---------------------------------------------------------------------------------------------- DrawingGraphicFindingQuestionVoCollection voColl = getDrawingGraphicFindingFromGrid(voDGFsaved); String[] activeErrors = validateActiveErrors(voColl); String[] errors = voColl.validate(activeErrors); if (errors != null) { engine.showErrors(errors); return false; } try { domain.saveDrawingGraphicFindings(voColl); } catch (StaleObjectException e) { engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); return false; } return true; }
private DrawingGraphicFindingQuestionVoCollection refreshInactiveFindingQuestions(DrawingGraphicFindingVo voDrawGraphicFinding) { DrawingGraphicFindingQuestionVoCollection voColl = form.getLocalContext().getInactiveFindingQuestions(); if (voColl == null) return null; for(DrawingGraphicFindingQuestionVo temp: voColl) { temp.setDrawingGraphicFinding(voDrawGraphicFinding); } return voColl; }
private String[] validateActiveErrors(DrawingGraphicFindingQuestionVoCollection voColl) { if(voColl == null) return null; ArrayList errors = new ArrayList(); for(int i = 0; i < voColl.size(); i++) { DrawingGraphicFindingQuestionVo voDGFQ = voColl.get(i); DrawingGraphicFindingVo voDGFinding = voDGFQ.getDrawingGraphicFinding(); QuestionInformationShortVo voQInforShort = voDGFQ.getQuestion(); //WDEV-1213 - Don't allow the inactive to be checked if(voDGFQ.getActiveIsNotNull() && voDGFQ.getActive().booleanValue() && voDGFinding != null) { if(voDGFinding.getActiveStatusIsNotNull() && voDGFinding.getActiveStatus().equals(PreActiveActiveInactiveStatus.ACTIVE)) { //Question if(voQInforShort != null && voQInforShort.getStatusIsNotNull() && !voQInforShort.getStatus().equals(PreActiveActiveInactiveStatus.ACTIVE)) { errors.add("'" + voQInforShort.getText() + "' question has to be active"); } } } } if (errors.size() == 0) return null; String[] findingErrors = new String[errors.size()]; errors.toArray(findingErrors); return findingErrors; }