Example #1
0
  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();
    }
  }
Example #2
0
  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();
    }
  }