private DynamicGridRow getCurrentQuestionRow(QuestionInformationShortVo voQInfoShort) { DynamicGridRow row = null; for (int i = 0; i < form.lyrFindings().tabView().dyngrdAssocQuestions().getRows().size(); i++) { DrawingGraphicFindingQuestionVo voDGFinding = getRowValue(form.lyrFindings().tabView().dyngrdAssocQuestions().getRows().get(i)); if (voDGFinding != null && voDGFinding.getQuestionIsNotNull() && voDGFinding.getQuestion().equals(voQInfoShort)) return form.lyrFindings().tabView().dyngrdAssocQuestions().getRows().get(i); } if (row == null) { row = form.lyrFindings().tabView().dyngrdAssocQuestions().getRows().newRow(); //Check to see if we have the same question in an inactive DrawingGraphicFindingQuestionVo DrawingGraphicFindingQuestionVo voDGFindingQuestion = getInactiveRecord(voQInfoShort); if (voDGFindingQuestion != null) row.setValue(voDGFindingQuestion); } return row; }
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 DrawingGraphicFindingQuestionVo saveDrawingGraphicFinding(DrawingGraphicFindingQuestionVo voDrawingGraphicFindingQuestion) throws StaleObjectException { if(voDrawingGraphicFindingQuestion == null) throw new RuntimeException("Cannot save null value for DrawingGraphicFindingQuestionVo"); if(voDrawingGraphicFindingQuestion.isValidated() == false) throw new CodingRuntimeException("DrawingGraphicFindingQuestion Value Object has not been validated"); DomainFactory factory = getDomainFactory(); DrawingGraphicFindingQuestion doDrawingGraphicFindingQuestion = DrawingGraphicFindingQuestionVoAssembler.extractDrawingGraphicFindingQuestion(factory, voDrawingGraphicFindingQuestion); DrawingGraphicFinding doDrawingGraphicFinding = DrawingGraphicFindingVoAssembler.extractDrawingGraphicFinding(factory, voDrawingGraphicFindingQuestion.getDrawingGraphicFinding()); factory.save(doDrawingGraphicFinding); doDrawingGraphicFindingQuestion.setDrawingGraphicFinding(doDrawingGraphicFinding); factory.save(doDrawingGraphicFinding); return DrawingGraphicFindingQuestionVoAssembler.create(doDrawingGraphicFindingQuestion); }
private DrawingGraphicFindingQuestionVo getRowValue(DynamicGridRow row) { if (row != null) { Object value = row.getValue(); return value instanceof DrawingGraphicFindingQuestionVo ? (DrawingGraphicFindingQuestionVo) value : null; } return null; }
protected void onBtnSaveClick() throws PresentationLogicException { if (isDialog()) { //Select the questions QuestionInformationShortVoCollection voColl = new QuestionInformationShortVoCollection(); for (int i = 0; i < form.lyrFindings().tabView().dyngrdAssocQuestions().getRows().size(); i++) { DynamicGridCell cellSelect = form.lyrFindings().tabView().dyngrdAssocQuestions().getRows().get(i).getCells().get(getQuestionDynColumn(COLQUESTIONSELECT)); if (cellSelect != null) { Object objValue = cellSelect.getValue(); if (objValue instanceof Boolean && ((Boolean) (objValue)).booleanValue()) { Object value = form.lyrFindings().tabView().dyngrdAssocQuestions().getRows().get(i).getValue(); if (value != null && value instanceof DrawingGraphicFindingQuestionVo) { DrawingGraphicFindingQuestionVo voDGFindingQuestion = (DrawingGraphicFindingQuestionVo) value; if (voDGFindingQuestion.getQuestionIsNotNull()) voColl.add(voDGFindingQuestion.getQuestion()); } } } } form.getGlobalContext().Admin.setSelectedQuestions(voColl); engine.close(DialogResult.OK); } else { if (save() == false) return; refreshFindings(); } }
private QuestionInformationShortVo getQuestionFromGridRow(DynamicGridRow row) { if (row != null) { DrawingGraphicFindingQuestionVo voDGFindingQuestion = getRowValue(row); return (QuestionInformationShortVo) (voDGFindingQuestion != null ? voDGFindingQuestion.getQuestion().clone() : null); } return null; }
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; }
private void setAssociatedQuestion(DynamicGridRow row, DrawingGraphicFindingQuestionVo voDGFQ) { if (row != null) { QuestionInformationShortVo voQInfo = voDGFQ.getQuestion(); row.setValue(voDGFQ); row.setExpanded(true); DynamicGridCell cellIcon = row.getCells().get(getQuestionDynColumn(COLICONQUESTION)); if (cellIcon == null) cellIcon = row.getCells().newCell(getQuestionDynColumn(COLICONQUESTION), DynamicCellType.IMAGE); cellIcon.setValue(form.getImages().Core.QuestionSmall); DynamicGridCell cellQuestion = row.getCells().get(getQuestionDynColumn(COLQUESTION)); if (cellQuestion == null) cellQuestion = row.getCells().newCell(getQuestionDynColumn(COLQUESTION), DynamicCellType.STRING); cellQuestion.setReadOnly(true); DynamicGridCell cellShortText = row.getCells().get(getQuestionDynColumn(COLSHORTEXT)); if (cellShortText == null) cellShortText = row.getCells().newCell(getQuestionDynColumn(COLSHORTEXT), DynamicCellType.STRING); cellShortText.setReadOnly(true); DynamicGridCell cellStatus = row.getCells().get(getQuestionDynColumn(COLQUESTIONSTATUS)); if (cellStatus == null) cellStatus = row.getCells().newCell(getQuestionDynColumn(COLQUESTIONSTATUS), DynamicCellType.STRING); cellStatus.setReadOnly(true); if (voQInfo != null) { cellQuestion.setValue(voQInfo.getShortText()); cellQuestion.setTooltip(voQInfo.getTooltip()); cellShortText.setValue(voQInfo.getText()); cellStatus.setValue(voQInfo.getStatusIsNotNull()?voQInfo.getStatus().toString():""); cellShortText.setTooltip(voQInfo.getTooltip()); } if (isDialog()) { DynamicGridCell cellQuestionSelect = row.getCells().get(getQuestionDynColumn(COLQUESTIONSELECT)); if (cellQuestionSelect == null) cellQuestionSelect = row.getCells().newCell(getQuestionDynColumn(COLQUESTIONSELECT), DynamicCellType.BOOL); } } }