private boolean isDuplicateQuestionSet() { List<Integer> tempQustCheckMaps = new ArrayList<Integer>(); List<Integer> temp = new ArrayList<Integer>(); for (AuditDataQustCheckMap qcM : getSelCheckList().getAuditDataQustCheckMaps()) { tempQustCheckMaps.add(qcM.getPkQcMapId()); } List<AuditDataQuestion> tempQues = checklistService.getChklistQuestions(getCurrentVersion(), tempQustCheckMaps); tempQustCheckMaps.clear(); for (AuditDataQuestion adq : tempQues) { tempQustCheckMaps.add(adq.getPkQuestionId()); } for (AuditDataQuestion adq : getQlist()) { temp.add(adq.getPkQuestionId()); } for (Integer in : temp) { if (tempQustCheckMaps.contains(in.intValue())) { tempQustCheckMaps.remove(in); } } if (tempQustCheckMaps.size() < 1) { return true; } else { return false; } }
/** * This method will remove the selected row from the datatable * * @param questiondetails * @throws IOException */ public void deleteRow(AuditDataQuestion questiondetails) throws IOException { qlist.remove(questiondetails); Object[] arr = new Object[5]; arr[0] = questiondetails.getPkQuestionId(); arr[1] = questiondetails.getQuestionText(); arr[2] = questiondetails.getLookFor(); arr[3] = getSelCheckList().getAuditDataStandardArtefact().getName(); arr[4] = getSelCheckList().getAuditMasterType().getAuditTypeName(); if (isDisplayAddQuestions()) { getAddList().add(arr); } if (qlist.size() < 1) { reset(); FacesContext.getCurrentInstance().getExternalContext().redirect("createVersion.xhtml"); } }
public String getDisplayColValue(AuditDataQuestion question, String value) { String retValue = null; for (AuditDataQuestionMap qm : question.getAuditDataQuestionMaps()) { if (qm.getAuditDataArtefactProcessMap().getProcessName().equals(value)) { retValue = qm.getAuditDataArtefactProcessResult().getSectionNumber(); } } return retValue; }
public void addQuestions() { getAddList().clear(); setDisplayAddQuestions(true); List<Integer> artifactList = new ArrayList<Integer>(); artifactList.add(getSelCheckList().getAuditDataStandardArtefact().getSartId()); try { // setQuestList(checklistService.searchQuestions(auditStdId, // auditTypeId, artifactList)); List<Object[]> data = getChecklistService() .searchQuestionsforVersion( getSelCheckList().getAuditMasterStandard().getPkAuditStdId(), getSelCheckList().getAuditMasterType().getPkAuditTypeId(), artifactList); setQuestList(data); for (Object[] arr : data) { System.out.println("questionid: " + arr[0]); System.out.println("text: " + arr[1]); System.out.println("lookfor: " + arr[2]); System.out.println("name: " + arr[3]); System.out.println("auditType: " + arr[4]); } } catch (AuditGeneralException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<Integer> currQues = new ArrayList<Integer>(); for (AuditDataQuestion ques : getQlist()) { currQues.add(ques.getPkQuestionId()); } if (getQuestList().size() > 1) { for (Object[] objArr : getQuestList()) { if (currQues.contains(objArr[0]) == false) { getAddList().add(objArr); } } } System.out.println("Size of addlist ::" + getAddList().size()); }
public void reSubmitVersion() { if (isEditDataValid()) { Float newVers = Float.parseFloat(getCurrentVersion()); for (PaceMasterUser user : getLeadAuditorlist()) { if (getSelectedleadAuditorID().equals(user.getFirstName())) { getSelCheckList().setApproverId(user); } } getSelCheckList().setModifiedBy(userMB.getUserObject().getPkUserId()); PaceMasterCode pacecode = new PaceMasterCode(); pacecode.setPkCodId(PaceStandardDefs.CHECKLIST_STATUS_SUBMITTED); getSelCheckList().setPaceMasterCode(pacecode); List<Integer> qcMap = new ArrayList<Integer>(); List<AuditDataChecklistVersionMap> versMap = new ArrayList<AuditDataChecklistVersionMap>(); // create a list with Integers to check for (AuditDataQustCheckMap qcm : getSelCheckList().getAuditDataQustCheckMaps()) { qcMap.add(qcm.getFkAqMapId().getPkAqMapId()); } // Check if Question is mapped already else create a new // checklist-question Mapping for (AuditDataQuestion ques : getQlist()) { for (AuditDataQuestionMap qm : ques.getAuditDataQuestionMaps()) { if (!qcMap.contains(qm.getPkAqMapId())) { AuditDataQustCheckMap tempqcMap = new AuditDataQustCheckMap(); tempqcMap.setCreatedDate(new Date()); tempqcMap.setFkCheckId(getSelCheckList()); tempqcMap.setFkAqMapId(qm); tempqcMap.setCreatedBy(userMB.getUserObject().getPkUserId()); getSelCheckList().getAuditDataQustCheckMaps().add(tempqcMap); } else { } } } // Check if the checklist-question Mapping is present in the version // else add it List<Integer> tempqcMs = new ArrayList<Integer>(); for (AuditDataQustCheckMap qcs : getSelCheckList().getAuditDataQustCheckMaps()) { tempqcMs.add(qcs.getFkAqMapId().getPkAqMapId()); } for (AuditDataQuestion ques : getQlist()) { for (AuditDataQuestionMap qmap : ques.getAuditDataQuestionMaps()) { if (tempqcMs.contains(qmap.getPkAqMapId())) { tempqcMs.remove(qmap.getPkAqMapId()); } } } List<AuditDataQustCheckMap> tempToRemove = new ArrayList<AuditDataQustCheckMap>(); for (Integer in : tempqcMs) { for (AuditDataQustCheckMap qcs : getSelCheckList().getAuditDataQustCheckMaps()) { if (qcs.getFkAqMapId().getPkAqMapId().intValue() == in.intValue()) { tempToRemove.add(qcs); } } } checklistService.removeVersionMapping(getSelCheckList()); for (AuditDataQustCheckMap tqcs : tempToRemove) { getSelCheckList().getAuditDataQustCheckMaps().remove(tqcs); } for (AuditDataQustCheckMap qcmap : getSelCheckList().getAuditDataQustCheckMaps()) { AuditDataChecklistVersionMap tempVerMap = new AuditDataChecklistVersionMap(); tempVerMap.setAuditDataQustCheckMap(qcmap); tempVerMap.setCreatedDate(new Date()); tempVerMap.setPaceMasterUsersByCreatedBy(userMB.getUserObject()); tempVerMap.setVersion(newVers.toString().substring(0, 3)); versMap.add(tempVerMap); } checklistService.saveNewVersion(getSelCheckList(), versMap); FacesMessageUtil.showInfoMessage( ResourceBundleBean.getString("message_checklist_version_checklist_version_re-submitted")); reset(); } }
public void submitVersion() { if (isDataValid()) { Float newVers = new Float(0); if (getVersionIncrement().equals("0.1")) { Float current = Float.parseFloat(getCurrentVersion()); Float incr = Float.parseFloat(getVersionIncrement()); newVers = current + incr; } else { Float current = Float.parseFloat(getCurrentVersion()); if ((current - current) == 0) { current = (float) (current + 0.1); } newVers = (float) Math.ceil(current); } for (PaceMasterUser user : getLeadAuditorlist()) { if (getSelectedleadAuditorID().equals(user.getFirstName())) { getSelCheckList().setApproverId(user); } } getSelCheckList().setModifiedBy(userMB.getUserObject().getPkUserId()); PaceMasterCode pacecode = new PaceMasterCode(); pacecode.setPkCodId(PaceStandardDefs.CHECKLIST_STATUS_SUBMITTED); getSelCheckList().setPaceMasterCode(pacecode); List<Integer> qcMap = new ArrayList<Integer>(); List<AuditDataChecklistVersionMap> versMap = new ArrayList<AuditDataChecklistVersionMap>(); // create a list with Integers to check for (AuditDataQustCheckMap qcm : getSelCheckList().getAuditDataQustCheckMaps()) { qcMap.add(qcm.getFkAqMapId().getPkAqMapId()); } // Check if Question is mapped already else create a new // checklist-question Mapping for (AuditDataQuestion ques : getQlist()) { for (AuditDataQuestionMap qm : ques.getAuditDataQuestionMaps()) { if (!qcMap.contains(qm.getPkAqMapId())) { AuditDataQustCheckMap tempqcMap = new AuditDataQustCheckMap(); tempqcMap.setCreatedDate(new Date()); tempqcMap.setFkCheckId(getSelCheckList()); tempqcMap.setFkAqMapId(qm); tempqcMap.setCreatedBy(userMB.getUserObject().getPkUserId()); getSelCheckList().getAuditDataQustCheckMaps().add(tempqcMap); } else { } } } // Check if the checklist-question Mapping is present in the version // else add it List<Integer> tempqcMs = new ArrayList<Integer>(); for (AuditDataQustCheckMap qcs : getSelCheckList().getAuditDataQustCheckMaps()) { tempqcMs.add(qcs.getFkAqMapId().getPkAqMapId()); } for (AuditDataQuestion ques : getQlist()) { for (AuditDataQuestionMap qmap : ques.getAuditDataQuestionMaps()) { if (tempqcMs.contains(qmap.getPkAqMapId())) { tempqcMs.remove(qmap.getPkAqMapId()); } } } List<AuditDataQustCheckMap> tempToRemove = new ArrayList<AuditDataQustCheckMap>(); for (Integer in : tempqcMs) { for (AuditDataQustCheckMap qcs : getSelCheckList().getAuditDataQustCheckMaps()) { if (qcs.getFkAqMapId().getPkAqMapId().intValue() == in.intValue()) { tempToRemove.add(qcs); } } } for (AuditDataQustCheckMap tqcs : tempToRemove) { getSelCheckList().getAuditDataQustCheckMaps().remove(tqcs); } for (AuditDataQustCheckMap qcmap : getSelCheckList().getAuditDataQustCheckMaps()) { /* * if(null==qcmap.getPkQcMapId()) { AuditDataChecklistVersionMap * tempVerMap = new AuditDataChecklistVersionMap(); * tempVerMap.setAuditDataQustCheckMap(qcmap); * tempVerMap.setCreatedDate(new Date()); * tempVerMap.setPaceMasterUsersByCreatedBy * (userMB.getUserObject()); * tempVerMap.setVersion(newVers.toString()); * versMap.add(tempVerMap); } else { * AuditDataChecklistVersionMap tempVerMap = * checklistService.getVersionMap(qcmap.getPkQcMapId()); * tempVerMap.setAuditDataQustCheckMap(qcmap); * tempVerMap.setModifiedDate(new Date()); * tempVerMap.setPaceMasterUsersByModifiedBy * (userMB.getUserObject()); * tempVerMap.setVersion(newVers.toString()); * versMap.add(tempVerMap); * tempMapping.add(tempVerMap.getAuditDataQustCheckMap * ().getPkQcMapId()); * * } */ AuditDataChecklistVersionMap tempVerMap = new AuditDataChecklistVersionMap(); tempVerMap.setAuditDataQustCheckMap(qcmap); tempVerMap.setCreatedDate(new Date()); tempVerMap.setPaceMasterUsersByCreatedBy(userMB.getUserObject()); tempVerMap.setVersion(newVers.toString().substring(0, 3)); versMap.add(tempVerMap); } /* * for(AuditDataQustCheckMap qcM : * getSelCheckList().getAuditDataQustCheckMaps()) { * if(tempMapping.contains(qcM.getPkQcMapId())) { * tempMapping.remove(qcM.getPkQcMapId()); } } //Remove the mapping * for removed question List<AuditDataChecklistVersionMap> * tempversMap = new ArrayList<AuditDataChecklistVersionMap>(); * for(AuditDataChecklistVersionMap vM : versMap) { * if(!tempMapping.contains * (vM.getAuditDataQustCheckMap().getPkQcMapId())) { * tempversMap.add(vM); } } * * for(AuditDataChecklistVersionMap vM : tempversMap) { * versMap.remove(vM); } */ checklistService.saveNewVersion(getSelCheckList(), versMap); FacesMessageUtil.showInfoMessage( ResourceBundleBean.getString("message_checklist_version_checklist_version_submitted")); reset(); } }