Package com.ufis_as.ek_if.rms.entities

Examples of com.ufis_as.ek_if.rms.entities.EntDbStaffShift


    return em;
  }

  @Override
  public EntDbStaffShift merge(EntDbStaffShift staffShift) {
    EntDbStaffShift result = null;
    try {
      result = em.merge(staffShift);
    } catch (OptimisticLockException Oexc) {
      LOG.error("OptimisticLockException Entity:{} , Error:{}",
          staffShift, Oexc);
View Full Code Here


    return result;
  }

  @Override
  public EntDbStaffShift findById(String idStaffShift) {
    EntDbStaffShift entStaffShift = null;
    //String[] staffTypeList = new String[]{"ROP", "SPHL"};
    //String staffType = "'ROP', 'SPHL'";
    try {
      Query query = em.createNamedQuery("EntDbStaffShift.findById");
      query.setParameter("id", idStaffShift);
View Full Code Here

  

    public boolean readResourceShiftType(ResourceShiftType resourceShiftType)  {
     
      if (resourceShiftType != null){
        EntDbStaffShift edpiod = new EntDbStaffShift();
       
        logLevel = entStartupInitSingleton.getIrmLogLev();
       
        msgLogged = Boolean.FALSE;
        if (irmtabRef > 0) {
          msgLogged = Boolean.TRUE;
        }
       
//        SimpleDateFormat RTCdf = new SimpleDateFormat(HpEKConstants.EKRTC_TIME_FORMAT);
        // convert local time to UTC
//        RTCdf.setTimeZone(HpEKConstants.utcTz);
       
//        // get condition
//        boolean isShiftOut = false;
//        if (resourceShiftType.getSFT().getAET() == null || "".equals(resourceShiftType.getSFT().getAET())){
//          isShiftOut = true;
//        }
       
        // check meta
        if (resourceShiftType.getMeta() == null){
          LOG.info("Mandatory field Meta is null, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
       
          return false;
        }
       
        // set message time
        if (resourceShiftType.getMeta().getMessageTime() != null){
          edpiod.setMsgSendDate(convertXMLGregorianCalendarToDate(resourceShiftType.getMeta().getMessageTime()));
        }else {
          LOG.info("Mandatory field message time is null, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }
       
        // check messageID
        if (resourceShiftType.getMeta().getMessageID() == 0){
          LOG.info("Mandatory field messageID time is 0, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }
       
        // check message type
        if (resourceShiftType.getMeta().getMessageType() == null || "".equals(resourceShiftType.getMeta().getMessageType())){
          LOG.info("Mandatory field message type is null or empty string, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }else if (!Arrays.asList(messageTypeArray).contains(resourceShiftType.getMeta().getMessageType())){
          LOG.info("Mandatory field message type {} is not in possible value, ResourceShiftType message is rejected", resourceShiftType.getMeta().getMessageType());
         
          sendErroNotification(EnumExceptionCodes.EENUM);
         
          return false;
        }
       
        // check messageSubtype
        if (resourceShiftType.getMeta().getMessageSubtype() == null || "".equals(resourceShiftType.getMeta().getMessageSubtype().trim())){
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          LOG.info("Mandatory field messageSubtype is null or empty string, ResourceShiftType message is rejected");
          return false;
        }else if (!Arrays.asList(messageShiftSubtypeArray).contains(resourceShiftType.getMeta().getMessageSubtype().toUpperCase().trim())){
          LOG.info("Mandatory field messageSubtype {} is not in possible value, ResourceShiftType message is rejected", resourceShiftType.getMeta().getMessageSubtype());
         
          sendErroNotification(EnumExceptionCodes.EENUM);
         
          return false;
        }else{
          staffShiftMsgSubType = resourceShiftType.getMeta().getMessageSubtype();
        }
       
        // set messageSource
        if (resourceShiftType.getMeta().getMessageSource() != null && !"".equals(resourceShiftType.getMeta().getMessageSource().trim())){
          if (Arrays.asList(messageSourceArray).contains(resourceShiftType.getMeta().getMessageSource().toUpperCase().trim())){
            switch(resourceShiftType.getMeta().getMessageSource().toUpperCase().trim()){
              case "EKRTC":
                edpiod.setStaffType("EK");
                break;
              case "GXRTC":
                edpiod.setStaffType("GX");
                break;
              case "CSRTC":
                edpiod.setStaffType("CS");
                break;
            }
          }else{
            LOG.info("Mandatory field messageSource {} is not in possible value, ResourceShiftType message is rejected", resourceShiftType.getMeta().getMessageSource());
           
            sendErroNotification(EnumExceptionCodes.EENUM);
           
              return false;
          }
         
        }else {
          LOG.info("Mandatory field messageSource is null or empty string, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }
       
        // check SFT
        if (resourceShiftType.getSFT() == null){
          LOG.info("Mandatory field messageSource is null or empty string, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }
       
        // set AID
        if (resourceShiftType.getSFT().getAID() != null && !"".equals(resourceShiftType.getSFT().getAID())){
          edpiod.setShiftId(new BigDecimal(resourceShiftType.getSFT().getAID()));
        }else {
          LOG.info("Mandatory field AID is null or empty string, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }
       
        // set SNM
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
       
        if (resourceShiftType.getSFT().getSNM() != null && !"".equals(resourceShiftType.getSFT().getSNM())){
          edpiod.setStaffName(resourceShiftType.getSFT().getSNM());
        }else {
          LOG.info("Mandatory field SNM is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;         
        }
       
        }
       
        // set FNM
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
       
        if (resourceShiftType.getSFT().getFNM() != null && !"".equals(resourceShiftType.getSFT().getFNM())){
          edpiod.setStaffFirstName(resourceShiftType.getSFT().getFNM());
        }else {
          LOG.info("Mandatory field FNM is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;         
        }
       
        }
       
        // set SID (invalid for delete message)
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
       
        if (resourceShiftType.getSFT().getSID() != null && !"".equals(resourceShiftType.getSFT().getSID())){
          edpiod.setStaffNumber(resourceShiftType.getSFT().getSID());
        }else {
          LOG.info("Mandatory field SID is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;         
        }
       
        }
       
        // set SST (invalid for delete message)
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType) ){
       
        if (resourceShiftType.getSFT().getSST() != null && !"".equals(resourceShiftType.getSFT().getSST())){
          try {
          edpiod.setShiftScheStartDate(convertStringToDate(resourceShiftType.getSFT().getSST()));
        } catch (ParseException e) {
          LOG.error("erro when parse String to Date SST, {}", e);
//          LOG.info("Mandatory field SST can not be parsed correctly, ResourceShiftType message is rejected");
//            return false;
        }
        }else {
          LOG.info("Mandatory field SST is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;         
        }
       
        }
       
        // set SET
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
       
        if (resourceShiftType.getSFT().getSET() != null && !"".equals(resourceShiftType.getSFT().getSET())){
          try {
          edpiod.setShiftScheEndDate(convertStringToDate(resourceShiftType.getSFT().getSET()));
        } catch (ParseException e) {
          LOG.error("erro when parse String to Date SET, {}", e);
//          LOG.info("Mandatory field SET can not be parsed correctly, ResourceShiftType message is rejected");
//            return false;
        }
        }else {
          LOG.info("Mandatory field SET is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;         
        }
       
        }
       
        // set EST
        if (resourceShiftType.getSFT().getEST() != null && !"".equals(resourceShiftType.getSFT().getEST())){
          try {
          edpiod.setShiftEstStartDate(convertStringToDate(resourceShiftType.getSFT().getEST()));
        } catch (ParseException e) {
          LOG.error("erro when parse String to Date EST, {}", e);
        }
        }
//        else if(isShiftOut){
//          LOG.error(" field EST under 'out' condition and it is null or empty String, ResourceShiftType message is rejected");
//          return false;
//        }
       
        // set EET
        if (resourceShiftType.getSFT().getEET() != null && !"".equals(resourceShiftType.getSFT().getEET())){
          try {
          edpiod.setShiftEstEndDate(convertStringToDate(resourceShiftType.getSFT().getEET()));
        } catch (ParseException e) {
          LOG.error("erro when parse String to Date EET, {}", e);
        }
        }
//        else if(isShiftOut){
//          LOG.error(" field EET under 'out' condition and it is null or empty String, ResourceShiftType message is rejected");
//          return false;
//        }
       
        // set AST
        if (resourceShiftType.getSFT().getAST() != null && !"".equals(resourceShiftType.getSFT().getAST().trim())){
          try {
          edpiod.setShiftActualStartDate(convertStringToDate(resourceShiftType.getSFT().getAST()));
        } catch (ParseException e) {
          LOG.error("erro when parse String to Date AST, {}", e);
//          LOG.info("Mandatory field AST can not be parsed correctly, ResourceShiftType message is rejected");
//            return false;
        }
        }
//        else {
//          LOG.info("Mandatory field AST is null or empty String, ResourceShiftType message is rejected");
//         
//          sendErroNotification(EnumExceptionCodes.EMAND);
//         
//          return false;         
//        }
       
        // set AET
        if (resourceShiftType.getSFT().getAET() != null && !"".equals(resourceShiftType.getSFT().getAET())){
          try {
          edpiod.setShiftActualEndDate(convertStringToDate(resourceShiftType.getSFT().getAET()));
        } catch (ParseException e) {
          LOG.error("erro when parse String to Date AET, {}", e);
        }
        }
//        else if(isShiftOut){
//          LOG.error(" field EST under 'out' condition and it is null or empty String, ResourceShiftType message is rejected");
//          return false;
//        }
       
        // set STT
        if (resourceShiftType.getSFT().getSTT() != null && !"".equals(resourceShiftType.getSFT().getSTT().trim())){
          edpiod.setMutateCode(resourceShiftType.getSFT().getSTT());
          if (!Arrays.asList(shiftsttArray).contains(resourceShiftType.getSFT().getSTT().toUpperCase().trim())){
              LOG.info("Mandatory field STT {} is in possible value, ResourceShiftType message is rejected", resourceShiftType.getSFT().getSTT());
             
              sendErroNotification(EnumExceptionCodes.EENUM);
             
              return false;
          }
        }else {
          LOG.info("Mandatory field STT is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;       
        }
       
        // set RNO (change to conditional according to version 2)
        if (resourceShiftType.getSFT().getRNO() != null && !"".equals(resourceShiftType.getSFT().getRNO().trim())){
          edpiod.setStaffMobileNo(resourceShiftType.getSFT().getRNO());
        }
//        else {
//          LOG.info("Mandatory field RNO is null or empty String, ResourceShiftType message is rejected");
//          return false;         
//        }
       
        // set FNC
        if (resourceShiftType.getSFT().getFNC() != null && !"".equals(resourceShiftType.getSFT().getFNC().trim())){
          edpiod.setShiftFunction(resourceShiftType.getSFT().getFNC());
        }else {
          LOG.info("Mandatory field FNC is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;         
        }
       
        // set PDA (change to conditional according to version 2.0 )
        if (resourceShiftType.getSFT().getPDA() != null && !"".equals(resourceShiftType.getSFT().getPDA().trim())){
          edpiod.setStaffHhdNo(resourceShiftType.getSFT().getPDA());
        }
//        else {
//          LOG.info("Mandatory field PDA is null or empty String, ResourceShiftType message is rejected");
//          return false;         
//        }
       
        // set RNG
        if (resourceShiftType.getSFT().getRNG() != null && !"".equals(resourceShiftType.getSFT().getRNG().trim())){
          edpiod.setPdaRange(resourceShiftType.getSFT().getRNG());
        }
       
        // set LOC
        if (resourceShiftType.getSFT().getLOC() != null && !"".equals(resourceShiftType.getSFT().getLOC().trim())){
          edpiod.setShiftLoc(resourceShiftType.getSFT().getLOC());
        }
       
       
        // set DEP (invaild for delete message)
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
       
        if (resourceShiftType.getSFT().getDEP() != null && !"".equals(resourceShiftType.getSFT().getDEP().trim())){
          if (entStartupInitSingleton.isMDDeptListOn()){
          // to check master data
          switch (edpiod.getStaffType()){
          case "EK":
            if (!entStartupInitSingleton.getEKASDeptList().contains(resourceShiftType.getSFT().getDEP().trim())){
              LOG.warn("not matching the master data, staffType {}, deptId {}", resourceShiftType.getSFT().getDEP().trim() ,"EKAS");
            }
            break;
          case "GX":
            if (!entStartupInitSingleton.getGXDeptList().contains(resourceShiftType.getSFT().getDEP().trim())){
              LOG.warn("not matching the master data, staffType {}, deptId {}", resourceShiftType.getSFT().getDEP().trim() ,"GX");
            }
            break;
          case "CS":
            if (!entStartupInitSingleton.getCSDeptList().contains(resourceShiftType.getSFT().getDEP().trim())){
              LOG.warn("not matching the master data, staffType {}, deptId {}", resourceShiftType.getSFT().getDEP().trim() ,"CS");
            }
            break;
          }
         
          sendErroNotification(EnumExceptionCodes.WNOMD);
         
        }     
          edpiod.setStaffDept(resourceShiftType.getSFT().getDEP());
        }else {
          LOG.info("Mandatory field DEP is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;         
        }
       
        }
       
        // set MWA (not available for DEP = B)
        if(!"CB".equalsIgnoreCase(resourceShiftType.getSFT().getDEP())){
       
        if (resourceShiftType.getSFT().getMWA() != null && !"".equals(resourceShiftType.getSFT().getMWA().trim())){
          if (entStartupInitSingleton.isMDWorkAreasListOn()){
          // to check with master data
            switch (edpiod.getStaffType()){
          case "EK":
            if (!entStartupInitSingleton.getEKASWorkAreasList().contains(resourceShiftType.getSFT().getMWA().trim())){
              LOG.warn("not matching the master data, staffType {}, workArea {}", resourceShiftType.getSFT().getMWA().trim() ,"EKAS");
            }
            break;
          case "GX":
            if (!entStartupInitSingleton.getGXWorkAreasList().contains(resourceShiftType.getSFT().getMWA().trim())){
              LOG.warn("not matching the master data, staffType {}, workArea {}", resourceShiftType.getSFT().getMWA().trim() ,"GX");
            }
            break;
          case "CS":
            if (!entStartupInitSingleton.getCSWorkAreasList().contains(resourceShiftType.getSFT().getMWA().trim())){
              LOG.warn("not matching the master data, staffType {}, workArea {}", resourceShiftType.getSFT().getMWA().trim() ,"CS");
            }
            break;
            }
           
            sendErroNotification(EnumExceptionCodes.WNOMD);
       
          edpiod.setStaffWorkArea(resourceShiftType.getSFT().getMWA());
        }else {
          LOG.info("Mandatory field MWA is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;         
        }
       
        }
       
        // set RTY (not available for delete message)
        if (staffShiftMsgSubType != null && !"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
       
        if (resourceShiftType.getSFT().getRTY() != null && !"".equals(resourceShiftType.getSFT().getRTY().trim())){
          edpiod.setResourceType(resourceShiftType.getSFT().getRTY());
          if (!Arrays.asList(shiftrtyArray).contains(resourceShiftType.getSFT().getRTY().toUpperCase().trim())){
              LOG.info("Mandatory field RTY {} is in possible value, ResourceShiftType message is rejected", resourceShiftType.getSFT().getRTY());
              return false;
          }
        }else {
          LOG.info("Mandatory field RTY is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;       
        }
       
        }
       
         // set WLK
        if (resourceShiftType.getSFT().getWLK() != null && !"".equals(resourceShiftType.getSFT().getWLK().trim())){
          edpiod.setStaffWalkieNo(resourceShiftType.getSFT().getWLK());
        }
//        else if(isShiftOut){
//          LOG.error(" field EST under 'out' condition and it is null or empty String, ResourceShiftType message is rejected");
//          return false;
//        }
View Full Code Here

                 
           }
          
         }else if ("UPD".equalsIgnoreCase(blHandleEKRTC.getStaffShiftMsgSubType())){
           // search exist record
           EntDbStaffShift existStaffShift;
        long startTime = System.currentTimeMillis();
        existStaffShift = dlEKRTCStaffShiftBean
            .getExsitRecordByShiftIdX(entDbStaffShift.getShiftId());
        LOG.info("search records in staffShift table, takes {} ms", System.currentTimeMillis()
            - startTime);

           
           if (existStaffShift != null){
     
             EntDbStaffShift oldEntDbStaffShift = (EntDbStaffShift)SerializationUtils.clone(existStaffShift);
            
           startTime = System.currentTimeMillis();
          // update staffShift table
          Class<EntDbStaffShift> EntDbStaffShiftClass = EntDbStaffShift.class;
          Field[] EntDbStaffShiftClassFields = EntDbStaffShiftClass
              .getDeclaredFields();
          //             Field[] EntDbStaffShiftClassFields = EntDbStaffShiftClass.getFields();
          for (Field f : EntDbStaffShiftClassFields) {
            if (!"id".equalsIgnoreCase(f.getName())
                && !"serialVersionUID".equalsIgnoreCase(f
                    .getName())) {
              setEntityValue(
                  existStaffShift,
                  f.getName(),
                  getEntityValue(entDbStaffShift, f.getName()));
            }
          }
          existStaffShift.setRecStatus(" ");
          existStaffShift.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
          existStaffShift.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
          //             dlEKRTCStaffShiftBean.Update(entDbStaffShift);
          LOG.info("update  staffShift table, takes {} ms", System.currentTimeMillis()
              - startTime);
         
          // send notification
          ufisTopicProducer.sendNotification(true, UfisASCommands.URT,
              String.valueOf(existStaffShift.getIdFlight()), oldEntDbStaffShift, existStaffShift);

//             EntDbFltJobTask existJobTask = dlEKRTCFltJobTaskBean.getExsitRecordByJobAssignShiftId(entDbStaffShift.getShiftId());
             List<EntDbFltJobAssign> existJobAssignList;
          startTime = System.currentTimeMillis();
          existJobAssignList = dlEKRTCFltJobAssignBean
              .getExsitRecordByShiftIdX(entDbStaffShift
                  .getShiftId());
          LOG.info("search records in FltJobAssign table, takes {} ms", System.currentTimeMillis()
              - startTime);
   
//             // search record in FltJobTask table
//             EntDbFltJobTask existJobTask = dlEKRTCFltJobTaskBean.getExsitRecordByJobAssignShiftId(entDbStaffShift.getShiftId());
            EntDbFltJobAssign existJobAssignForTask = null;
           
            if (existJobAssignList != null && existJobAssignList.size() >0){
              existJobAssignForTask = existJobAssignList.get(0);
            }
           
           
             if (existJobAssignForTask != null){
               EntDbFltJobAssign oldEntDbFltJobAssign = (EntDbFltJobAssign)SerializationUtils.clone(existJobAssignForTask);
              
               // staffShift set idFlight
               existStaffShift.setIdFlight(existJobAssignForTask.getIdFlight());
               existStaffShift.setIdFltJobTask(existJobAssignForTask.getIdFltJobTask());
              
               // added by 2013-11-15
            startTime = System.currentTimeMillis();
            existJobAssignForTask.setStaffFirstName(existStaffShift
                .getStaffFirstName());
            existJobAssignForTask.setStaffName(existStaffShift
                .getStaffName());
            existJobAssignForTask.setStaffNumber(existStaffShift
                .getStaffNumber());
            existJobAssignForTask.setStaffType(existStaffShift
                .getStaffType());
            existJobAssignForTask.setIdStaffShift(existStaffShift
                .getId());
           
            existJobAssignForTask.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
            existJobAssignForTask.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
            LOG.info("update FltJobAssign table, takes {} ms",
                System.currentTimeMillis() - startTime);

              
//               dlEKRTCStaffShiftBean.Update(entDbStaffShift);
              
//               // search record in jobAssign table and set value
//               EntDbFltJobAssign existJobAssign = dlEKRTCFltJobAssignBean.getExsitRecord(existJobTask.getTaskId(), existStaffShift.getShiftId());
              
//               EntDbFltJobAssign existJobAssign = null;            comment on 2013-11-15
//              
//                Iterator<EntDbFltJobAssign> existJobAssignListIt = existJobAssignList.iterator();
//                while (existJobAssignListIt.hasNext()){
//                  EntDbFltJobAssign jobAssign = existJobAssignListIt.next();
//                  if (jobAssign.getShiftId().equals(entDbStaffShift.getShiftId())){
//                    existJobAssign = jobAssign;
//                  }
//                }
//              
//              
//               if (existJobAssign != null){
//                 startTime = System.currentTimeMillis();
//                
//                 existJobAssign.setStaffFirstName(existStaffShift.getStaffFirstName());
//                 existJobAssign.setStaffName(existStaffShift.getStaffName());
//                 existJobAssign.setStaffNumber(existStaffShift.getStaffNumber());
//                 existJobAssign.setStaffType(existStaffShift.getStaffType());
//                 existJobAssign.setIdStaffShift(existStaffShift.getId());
////                 dlEKRTCFltJobAssignBean.Update(existJobAssign);   
//                
//                endTime = System.currentTimeMillis();
//                LOG.info("takes {} ms to update FltJobAssign table ", (endTime - startTime));
//               }
                   
             }
            
           }
              
          
         }
         else if ("DEL".equalsIgnoreCase(blHandleEKRTC.getStaffShiftMsgSubType())){ // added by 2013-11-15

           long startTime = System.currentTimeMillis();
        EntDbStaffShift existStaffShift = dlEKRTCStaffShiftBean
            .getExsitRecordByShiftIdX(entDbStaffShift.getShiftId());
        LOG.info("search records in staffShift table, takes {} ms", System.currentTimeMillis()
            - startTime);
       
        // update staffShift
        if (existStaffShift != null){
          existStaffShift.setRecStatus("X");
         
          // send notification
          ufisTopicProducer.sendNotification(true, UfisASCommands.DET,
              String.valueOf(existStaffShift.getIdFlight()), null, existStaffShift);
        }else{
          LOG.warn("could not find exist record from staffShif for DEL msg");
        }
       
        // update fltJobAssign table
View Full Code Here

        // send notification
        ufisTopicProducer.sendNotification(true, UfisASCommands.IRT,
            String.valueOf(entDbFltJobAssign.getIdFlight()), null, entDbFltJobAssign);
 
           // search record in staffShift table
           EntDbStaffShift existStaffShift;
        startTime = System.currentTimeMillis();
        existStaffShift = dlEKRTCStaffShiftBean
            .getExsitRecordByShiftIdX(entDbFltJobAssign
                .getShiftId());
        LOG.info("search records in staffShift table, takes {} ms", System.currentTimeMillis()
            - startTime);
 
          
           if (existStaffShift != null){
            
             EntDbStaffShift oldEntDbStaffShift = (EntDbStaffShift)SerializationUtils.clone(existStaffShift);
             EntDbFltJobTask oldEntDbFltJobTask = (EntDbFltJobTask)SerializationUtils.clone(entDbFltJobTask);
            
             // staffShift set idFlight and updated
             existStaffShift.setIdFlight(entDbFltJobTask.getIdFlight());
             existStaffShift.setIdFltJobTask(entDbFltJobTask.getId());
             existStaffShift.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
//             dlEKRTCStaffShiftBean.Update(existStaffShift);
            
             // update fltJboAssign
             entDbFltJobAssign.setIdStaffShift(existStaffShift.getId());
             entDbFltJobAssign.setStaffFirstName(existStaffShift.getStaffFirstName());
             entDbFltJobAssign.setStaffName(existStaffShift.getStaffName());
             entDbFltJobAssign.setStaffNumber(existStaffShift.getStaffNumber());
             entDbFltJobAssign.setStaffType(existStaffShift.getStaffType());      
//             dlEKRTCFltJobAssignBean.Update(entDbFltJobAssign);     
            
            // send notification
            ufisTopicProducer.sendNotification(true, UfisASCommands.URT,
                String.valueOf(entDbFltJobTask.getIdFlight()), oldEntDbFltJobTask, entDbFltJobTask);
           
            ufisTopicProducer.sendNotification(true, UfisASCommands.URT,
                String.valueOf(existStaffShift.getIdFlight()), oldEntDbStaffShift, existStaffShift);
           }
          
          
         }else if ("UPD".equalsIgnoreCase(blHandleEKRTC.getResAssignMsgSubType())){
          
     
           // search record in FltJobTask table
           EntDbFltJobTask existJobTask;
        startTime = System.currentTimeMillis();
        existJobTask = dlEKRTCFltJobTaskBean
            .getExsitRecordX(entDbFltJobTask.getTaskId());
        LOG.info("search records in jobTask table, takes {} ms", System.currentTimeMillis()
            - startTime);

//           // search record in FltJobTask table
//           EntDbFltJobTask existJobTask = dlEKRTCFltJobTaskBean.getExsitRecord(entDbFltJobTask);
//           // search exist record of fltJobTask
//           EntDbFltJobAssign existJobAssign = dlEKRTCFltJobAssignBean.getExsitRecord(existJobTask.getId(), entDbFltJobAssign.getShiftId());
          
           if (existJobTask != null){
             // search exist record of FltJobAssign and StaffShift by idFltJobTask            startTime = System.currentTimeMillis();
             // search record in staffShift table
            
             EntDbFltJobTask oldEntDbFltJobTask = (EntDbFltJobTask)SerializationUtils.clone(existJobTask);
            
             boolean isContainShiftId = false;
            

             List<EntDbStaffShift> existStaffShiftList;
          startTime = System.currentTimeMillis();
          existStaffShiftList = dlEKRTCStaffShiftBean
              .getExsitRecordByidFltJboTaskX(existJobTask.getId());
          LOG.info("search records in staffShift table, takes {} ms", System.currentTimeMillis()
              - startTime);

//               EntDbFltJobTask existJobTask = dlEKRTCFltJobTaskBean.getExsitRecordByJobAssignShiftId(entDbStaffShift.getShiftId());
               List<EntDbFltJobAssign> existJobAssignList;
            startTime = System.currentTimeMillis();
            existJobAssignList = dlEKRTCFltJobAssignBean
                .getExsitRecordX(existJobTask.getId());
            LOG.info("search records in jobAssign table, takes {} ms",
                System.currentTimeMillis() - startTime);

           
              EntDbStaffShift MatchStaffShift = null;
             
            if (existStaffShiftList != null){
            Iterator<EntDbStaffShift> existStaffShiftListIt = existStaffShiftList.iterator();
            while (existStaffShiftListIt.hasNext()){
              EntDbStaffShift StaffShift = existStaffShiftListIt.next();
              if (StaffShift.getShiftId().equals(entDbFltJobAssign.getShiftId())){
                isContainShiftId = true;
                MatchStaffShift = StaffShift;
                break;
              }
            }
            }
           
             if (isContainShiftId){
   
              startTime = System.currentTimeMillis();
              // update jobTask
              Class<EntDbFltJobTask> EntDbFltJobTask = EntDbFltJobTask.class;
              Field[] EntDbFltJobTaskClassFields = EntDbFltJobTask
                  .getDeclaredFields();
              for (Field f : EntDbFltJobTaskClassFields) {
                if (!"id".equalsIgnoreCase(f.getName())
                    && !"serialVersionUID"
                        .equalsIgnoreCase(f.getName())) {
                  setEntityValue(
                      existJobTask,
                      f.getName(),
                      getEntityValue(entDbFltJobTask,
                          f.getName()));
                }
              }
              existJobTask.setRecStatus(" ");
              existJobTask.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
              existJobTask.setUpdatedDate(HpUfisCalendar
                  .getCurrentUTCTime());
              LOG.info("update fltJobTask table, takes {} ms",
                  System.currentTimeMillis() - startTime);
             
              // send notification
              ufisTopicProducer.sendNotification(true, UfisASCommands.URT,
                  String.valueOf(existJobTask.getIdFlight()), oldEntDbFltJobTask, existJobTask);
             
            EntDbFltJobAssign matchFltJobAssign = null;
               Iterator<EntDbFltJobAssign> existJobAssignListIt = existJobAssignList.iterator();
               while (existJobAssignListIt.hasNext()){
                 EntDbFltJobAssign FltJobAssign = existJobAssignListIt.next();
                 if (FltJobAssign.getShiftId().equals(entDbFltJobAssign.getShiftId())){
                   matchFltJobAssign = FltJobAssign;
                   break;
                 }
               }
              
               if (matchFltJobAssign != null){
          
               startTime = System.currentTimeMillis();
              // update jobAssign
              Class<EntDbFltJobAssign> EntDbFltJobAssign = EntDbFltJobAssign.class;
              Field[] EntDbFltJobAssignClassFields = EntDbFltJobAssign
                  .getDeclaredFields();
              for (Field f : EntDbFltJobAssignClassFields) {
                if (!"id".equalsIgnoreCase(f.getName())
                    && !"serialVersionUID"
                        .equalsIgnoreCase(f.getName())) {
                  setEntityValue(
                      matchFltJobAssign,
                      f.getName(),
                      getEntityValue(entDbFltJobAssign,
                          f.getName()));
                }
              }
              matchFltJobAssign.setRecStatus(" ");
              matchFltJobAssign.setUpdatedDate(HpUfisCalendar
                  .getCurrentUTCTime());
              LOG.info("update fltJobAssign table, takes {} ms",
                  System.currentTimeMillis() - startTime);

//                 dlEKRTCFltJobAssignBean.Update(existJobAssign);
                 }else {
                   LOG.info("existJobAssign is null, jobAssign table will not be updated");
                 }
           
                   if (MatchStaffShift != null){
                    startTime = System.currentTimeMillis();
                    
                   startTime = System.currentTimeMillis();
                // update staffShift
                MatchStaffShift.setIdFlight(existJobTask
                    .getIdFlight());
                MatchStaffShift.setIdFltJobTask(existJobTask
                    .getId());
                LOG.info("update staffShift table, takes {} ms",
                    System.currentTimeMillis() - startTime);
 
                   }
           
             }else{
              startTime = System.currentTimeMillis();
              
               // mark fltJobTask as 'X'
               existJobTask.setRecStatus("X");
               existJobTask.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
               existJobTask.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
              
               Iterator<EntDbStaffShift> existStaffShifListIt = existStaffShiftList.iterator();
               while(existStaffShifListIt.hasNext()){
                 EntDbStaffShift entDbStaffShiftX = existStaffShifListIt.next();
                 // mark existing staffShift  as 'X', delete
                 entDbStaffShiftX.setRecStatus("X");
                 entDbStaffShiftX.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
                 entDbStaffShiftX.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
               }
              
               Iterator<EntDbFltJobAssign> existEntDbFltJobAssignListIt = existJobAssignList.iterator();
               while (existEntDbFltJobAssignListIt.hasNext()){
                 EntDbFltJobAssign entDbFltJobAssignX  = existEntDbFltJobAssignListIt.next();
                 // mark existing fltJobTask  as 'X', delete
                 entDbFltJobAssignX.setRecStatus("X");
                 entDbFltJobAssignX.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
                 entDbFltJobAssignX.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());

               }

              LOG.info("update related staffShift fltJobAssign fltJobTask records to 'X', takes {} ms ", (System.currentTimeMillis() - startTime));

              startTime = System.currentTimeMillis();
              // insert new record to fltJobTask and fltJobAssign table
              entDbFltJobTask.setIdFlight(urno);
              dlEKRTCFltJobTaskBean.Persist(entDbFltJobTask);
              entDbFltJobAssign.setIdFlight(urno);
              entDbFltJobAssign.setIdFltJobTask(entDbFltJobTask
                  .getId());
              dlEKRTCFltJobAssignBean.Persist(entDbFltJobAssign);
              LOG.info("insert new record to fltJobTask and fltJobAssign table, takes {} ms",
                  System.currentTimeMillis() - startTime);
   
             }

         
           }
//           else {
//             LOG.info("exist record for JobTask not found, resourceAssignmentType 'UPD' message will be insert as new record");
//             // insert into fltJobTask table
//             entDbFltJobTask.setIdFlight(urno);
//             dlEKRTCFltJobTaskBean.Persist(entDbFltJobTask);
//             // insert into fltJobAssign table
//             entDbFltJobAssign.setIdFlight(urno);
//             entDbFltJobAssign.setIdFltJobTask(entDbFltJobTask.getId());
//             dlEKRTCFltJobAssignBean.Persist(entDbFltJobAssign);
//            
//             startTime = System.currentTimeMillis();
//             // search record in staffShift table
//             EntDbStaffShift existStaffShift = dlEKRTCStaffShiftBean.getExsitRecordByShiftIdX(entDbFltJobAssign.getShiftId());
//             endTime = System.currentTimeMillis();
//            LOG.info("takes {} ms to search records in staffShift table ", (endTime - startTime));
//            
//             if (existStaffShift != null){
//               // staffShift set idFlight and updated
//               existStaffShift.setIdFlight(entDbFltJobTask.getIdFlight());
//               existStaffShift.setIdFltJobTask(entDbFltJobTask.getId());
//               existStaffShift.setUpdatedDate(new Date());
////               dlEKRTCStaffShiftBean.Update(existStaffShift);
//              
//               // update fltJboAssign
//               entDbFltJobAssign.setIdStaffShift(existStaffShift.getId());
//               entDbFltJobAssign.setStaffFirstName(existStaffShift.getStaffFirstName());
//               entDbFltJobAssign.setStaffName(existStaffShift.getStaffName());
//               entDbFltJobAssign.setStaffNumber(existStaffShift.getStaffNumber());
//               entDbFltJobAssign.setStaffType(existStaffShift.getStaffType());      
////               dlEKRTCFltJobAssignBean.Update(entDbFltJobAssign);     
//             }
//           }
        
          
         }else if ("DEL".equalsIgnoreCase(blHandleEKRTC.getResAssignMsgSubType())){

           // search record in FltJobTask table
           EntDbFltJobTask existJobTask;
         startTime = System.currentTimeMillis();
        existJobTask = dlEKRTCFltJobTaskBean
            .getExsitRecordX(entDbFltJobTask.getTaskId());
        LOG.info("search records in jobTask table, takes {} ms", System.currentTimeMillis()
            - startTime);
          
           if (existJobTask != null){
            
             startTime = System.currentTimeMillis();
             // mark task record as deleted, "X"
            // update jobTask
             Class<EntDbFltJobTask> entDbFltJobTaskClass = EntDbFltJobTask.class;
             Field[] entDbFltJobTaskClassFields = entDbFltJobTaskClass.getDeclaredFields();
             for(Field f : entDbFltJobTaskClassFields){
               if (!"id".equalsIgnoreCase(f.getName()) && !"serialVersionUID".equalsIgnoreCase(f.getName())){
                 setEntityValue(existJobTask, f.getName(), getEntityValue(entDbFltJobTask, f.getName()));
               }
             }  
            
             existJobTask.setRecStatus("X");
//             dlEKRTCFltJobTaskBean.Update(existJobTask);
             existJobTask.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
             existJobTask.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
            
             // search exist record of jobAssign
             List<EntDbFltJobAssign> existJobAssignList = dlEKRTCFltJobAssignBean.getExsitRecordX(existJobTask.getId());
             Iterator<EntDbFltJobAssign>  existJobAssignListIt = existJobAssignList.iterator();
             while (existJobAssignListIt.hasNext()){
               EntDbFltJobAssign existFltJobAssign = existJobAssignListIt.next();
              
              // update jobTask
               Class<EntDbFltJobAssign> entDbFltJobAssignClass = EntDbFltJobAssign.class;
               Field[] entDbFltJobAssignClassFields = entDbFltJobAssignClass.getDeclaredFields();
               for(Field f : entDbFltJobAssignClassFields){
                 if (!"id".equalsIgnoreCase(f.getName()) && !"serialVersionUID".equalsIgnoreCase(f.getName())){
                   setEntityValue(existFltJobAssign, f.getName(), getEntityValue(entDbFltJobAssign, f.getName()));
                 }
               }  
            // mark job assign as deleted, "X"
               existFltJobAssign.setIdFlight(existJobTask.getIdFlight());
               existFltJobAssign.setRecStatus("X");
               existFltJobAssign.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
//               dlEKRTCFltJobAssignBean.Update(existFltJobAssign);
               existFltJobAssign.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
              
              // send notification
              ufisTopicProducer.sendNotification(true, UfisASCommands.DET,
                  String.valueOf(existFltJobAssign.getIdFlight()), null, existFltJobAssign);
             }
            
             // search exist record of staffShift
             List<EntDbStaffShift> existStaffShiftList  = dlEKRTCStaffShiftBean.getExsitRecordByidFltJboTaskX(existJobTask.getId());
             Iterator<EntDbStaffShift> existStaffShiftListIt = existStaffShiftList.iterator();
             while (existStaffShiftListIt.hasNext()){
               EntDbStaffShift existStaffShift = existStaffShiftListIt.next();
            // mark staff shift record as deleted, "X"
               existStaffShift.setRecStatus("X");
               existStaffShift.setUpdatedUser(HpEKConstants.EKRTC_DATA_SOURCE);
//               dlEKRTCStaffShiftBean.Update(existStaffShift);
               existStaffShift.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
              
              // send notification
              ufisTopicProducer.sendNotification(true, UfisASCommands.DET,
                  String.valueOf(existStaffShift.getIdFlight()), null, existStaffShift);
             }
      
            LOG.info("update related staffShift fltJobTask fltJobAssign records to 'X' , takes {} ms", ( System.currentTimeMillis() - startTime));
            
           }else {
View Full Code Here

  

    public boolean readResourceShiftType(ResourceShiftType resourceShiftType) {
     
      if (resourceShiftType != null){
        EntDbStaffShift edpiod = new EntDbStaffShift();
       
        logLevel = entStartupInitSingleton.getIrmLogLev();
       
        msgLogged = Boolean.FALSE;
        if (irmtabRef > 0) {
          msgLogged = Boolean.TRUE;
        }
       
//        SimpleDateFormat RTCdf = new SimpleDateFormat(HpEKConstants.EKRTC_TIME_FORMAT);
        // convert local time to UTC
//        RTCdf.setTimeZone(HpEKConstants.utcTz);
       
//        // get condition
//        boolean isShiftOut = false;
//        if (resourceShiftType.getSFT().getAET() == null || "".equals(resourceShiftType.getSFT().getAET())){
//          isShiftOut = true;
//        }
       
        // check meta
        if (resourceShiftType.getMeta() == null){
          LOG.info("Mandatory field Meta is null, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }
       
        // set message time
        if (resourceShiftType.getMeta().getMessageTime() != null){
          edpiod.setMsgSendDate(convertXMLGregorianCalendarToDate(resourceShiftType.getMeta().getMessageTime()));
        }else {
          LOG.info("Mandatory field message time is null, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }
       
        // check messageID
        if (resourceShiftType.getMeta().getMessageID() == 0){
          LOG.info("Mandatory field messageID time is 0, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }
       
        // check message type
        if (resourceShiftType.getMeta().getMessageType() == null || "".equals(resourceShiftType.getMeta().getMessageType())){
          LOG.info("Mandatory field message type is null or empty string, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }else if (!Arrays.asList(messageTypeArray).contains(resourceShiftType.getMeta().getMessageType())){
          LOG.info("Mandatory field message type {} is not in possible value, ResourceShiftType message is rejected", resourceShiftType.getMeta().getMessageType());
         
          sendErroNotification(EnumExceptionCodes.EENUM);
         
          return false;
        }
       
        // check messageSubtype
        if (resourceShiftType.getMeta().getMessageSubtype() == null || "".equals(resourceShiftType.getMeta().getMessageSubtype().trim())){
          LOG.info("Mandatory field messageSubtype is null or empty string, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }else if (!Arrays.asList(messageShiftSubtypeArray).contains(resourceShiftType.getMeta().getMessageSubtype().toUpperCase().trim())){
          LOG.info("Mandatory field messageSubtype {} is not in possible value, ResourceShiftType message is rejected", resourceShiftType.getMeta().getMessageSubtype());
         
          sendErroNotification(EnumExceptionCodes.EENUM);
         
          return false;
        }else{
          staffShiftMsgSubType = resourceShiftType.getMeta().getMessageSubtype();
        }
       
        // set messageSource
        if (resourceShiftType.getMeta().getMessageSource() != null && !"".equals(resourceShiftType.getMeta().getMessageSource().trim())){
          if (Arrays.asList(messageSourceArray).contains(resourceShiftType.getMeta().getMessageSource().toUpperCase().trim())){
            switch(resourceShiftType.getMeta().getMessageSource().toUpperCase().trim()){
              case "ENGRTC":
                edpiod.setStaffType("ENGR");
                break;
            }
          }else{
            LOG.info("Mandatory field messageSource {} is not in possible value, ResourceShiftType message is rejected", resourceShiftType.getMeta().getMessageSource());
           
            sendErroNotification(EnumExceptionCodes.EENUM);
           
              return false;
          }
         
        }else {
          LOG.info("Mandatory field messageSource is null or empty string, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }
       
        // check SFT
        if (resourceShiftType.getSFT() == null){
          LOG.info("Mandatory field messageSource is null or empty string, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }
       
        // set AID
        if (resourceShiftType.getSFT().getAID() != null && !"".equals(resourceShiftType.getSFT().getAID())){
          edpiod.setShiftId(new BigDecimal(resourceShiftType.getSFT().getAID()));
        }else {
          LOG.info("Mandatory field AID is null or empty string, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;
        }
       
        //  (invaild for delete message)
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
         
        // set SNM
        if (resourceShiftType.getSFT().getSNM() != null && !"".equals(resourceShiftType.getSFT().getSNM())){
          edpiod.setStaffName(resourceShiftType.getSFT().getSNM());
        }
//        else {
//          LOG.info("Mandatory field SNM is null or empty String, ResourceShiftType message is rejected");
//          return false;         
//        }
       
        }
       
        //  (invaild for delete message)
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
         
        // set FNM
        if (resourceShiftType.getSFT().getFNM() != null && !"".equals(resourceShiftType.getSFT().getFNM())){
          edpiod.setStaffFirstName(resourceShiftType.getSFT().getFNM());
        }
//        else {
//          LOG.info("Mandatory field FNM is null or empty String, ResourceShiftType message is rejected");
//          return false;         
//        }
       
        }
       
        // (invaild for delete message)
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
       
        // set SID
        if (resourceShiftType.getSFT().getSID() != null && !"".equals(resourceShiftType.getSFT().getSID())){
          edpiod.setStaffNumber(resourceShiftType.getSFT().getSID());
        }
//        else {
//          LOG.info("Mandatory field SID is null or empty String, ResourceShiftType message is rejected");
//          return false;         
//        }
       
        }
       
        //  (invaild for delete message)
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
       
        // set SST
        if (resourceShiftType.getSFT().getSST() != null && !"".equals(resourceShiftType.getSFT().getSST())){
          try {
          edpiod.setShiftScheStartDate(convertStringToDate(resourceShiftType.getSFT().getSST()));
        } catch (ParseException e) {
          LOG.error("erro when parse String to Date SST, {}", e);
//          LOG.info("Mandatory field SST can not be parsed correctly, ResourceShiftType message is rejected");
//            return false;
        }
        }
//        else {
//          LOG.info("Mandatory field SST is null or empty String, ResourceShiftType message is rejected");
//          return false;         
//        }
       
        }
       
       
       
        // (invaild for delete message)
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
       
        // set SET
        if (resourceShiftType.getSFT().getSET() != null && !"".equals(resourceShiftType.getSFT().getSET())){
          try {
          edpiod.setShiftScheEndDate(convertStringToDate(resourceShiftType.getSFT().getSET()));
        } catch (ParseException e) {
          LOG.error("erro when parse String to Date SET, {}", e);
//          LOG.info("Mandatory field SET can not be parsed correctly, ResourceShiftType message is rejected");
//            return false;
        }
        }
//        else {
//          LOG.info("Mandatory field SET is null or empty String, ResourceShiftType message is rejected");
//          return false;         
//        }
       
        }
       
        // set EST
        if (resourceShiftType.getSFT().getEST() != null && !"".equals(resourceShiftType.getSFT().getEST())){
          try {
          edpiod.setShiftEstStartDate(convertStringToDate(resourceShiftType.getSFT().getEST()));
        } catch (ParseException e) {
          LOG.error("erro when parse String to Date EST, {}", e);
        }
        }
//        else if(isShiftOut){
//          LOG.error(" field EST under 'out' condition and it is null or empty String, ResourceShiftType message is rejected");
//          return false;
//        }
       
        // set EET
        if (resourceShiftType.getSFT().getEET() != null && !"".equals(resourceShiftType.getSFT().getEET())){
          try {
          edpiod.setShiftEstEndDate(convertStringToDate(resourceShiftType.getSFT().getEET()));
        } catch (ParseException e) {
          LOG.error("erro when parse String to Date EET, {}", e);
        }
        }
//        else if(isShiftOut){
//          LOG.error(" field EET under 'out' condition and it is null or empty String, ResourceShiftType message is rejected");
//          return false;
//        }
       
       
       
        // set AST
        if (resourceShiftType.getSFT().getAST() != null && !"".equals(resourceShiftType.getSFT().getAST())){
          try {
          edpiod.setShiftActualStartDate(convertStringToDate(resourceShiftType.getSFT().getAST()));
        } catch (ParseException e) {
          LOG.error("erro when parse String to Date AST, {}", e);
//          LOG.info("Mandatory field AST can not be parsed correctly, ResourceShiftType message is rejected");
//            return false;
        }
        }
//        else {
//          LOG.info("Mandatory field AST is null or empty String, ResourceShiftType message is rejected");
//          return false;         
//        }
       
        // set AET
        if (resourceShiftType.getSFT().getAET() != null && !"".equals(resourceShiftType.getSFT().getAET())){
          try {
          edpiod.setShiftActualEndDate(convertStringToDate(resourceShiftType.getSFT().getAET()));
        } catch (ParseException e) {
          LOG.error("erro when parse String to Date AET, {}", e);
        }
        }
//        else if(isShiftOut){
//          LOG.error(" field EST under 'out' condition and it is null or empty String, ResourceShiftType message is rejected");
//          return false;
//        }
       
        // set STT
        if (resourceShiftType.getSFT().getSTT() != null && !"".equals(resourceShiftType.getSFT().getSTT().trim())){
          edpiod.setMutateCode(resourceShiftType.getSFT().getSTT());
          if (!Arrays.asList(shiftsttArray).contains(resourceShiftType.getSFT().getSTT().toUpperCase().trim())){
              LOG.info("Mandatory field STT {} is in possible value, ResourceShiftType message is rejected", resourceShiftType.getSFT().getSTT());
             
              sendErroNotification(EnumExceptionCodes.EENUM);
             
              return false;
          }
        }else {
          LOG.info("Mandatory field STT is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;       
        }
       
        // set RNO
        if (resourceShiftType.getSFT().getRNO() != null && !"".equals(resourceShiftType.getSFT().getRNO())){
          edpiod.setStaffMobileNo(resourceShiftType.getSFT().getRNO());
        }
//        else {
//          LOG.info("Mandatory field RNO is null or empty String, ResourceShiftType message is rejected");
//          return false;         
//        }
       
        // (invaild for delete message)
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
        // set FNC
        if (resourceShiftType.getSFT().getFNC() != null && !"".equals(resourceShiftType.getSFT().getFNC())){
          edpiod.setShiftFunction(resourceShiftType.getSFT().getFNC());
        }else {
          LOG.info("Mandatory field FNC is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;         
        }
       
        }
       
        // set PDA
        if (resourceShiftType.getSFT().getPDA() != null && !"".equals(resourceShiftType.getSFT().getPDA())){
          edpiod.setStaffHhdNo(resourceShiftType.getSFT().getPDA());
        }
//        else {
//          LOG.info("Mandatory field PDA is null or empty String, ResourceShiftType message is rejected");
//          return false;         
//        }
       
        // set RNG
        if (resourceShiftType.getSFT().getRNG() != null && !"".equals(resourceShiftType.getSFT().getRNG())){
          edpiod.setPdaRange(resourceShiftType.getSFT().getRNG());
        }
       
//        // set LOC
//        if (resourceShiftType.getSFT().getLOC() != null && !"".equals(resourceShiftType.getSFT().getLOC())){
//          edpiod.setShiftLoc(resourceShiftType.getSFT().getLOC());
//        }
       
        // (invaild for delete message)
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
        // set DEP
        if (resourceShiftType.getSFT().getDEP() != null && !"".equals(resourceShiftType.getSFT().getDEP())){
          if (entStartupInitSingleton.isMDDeptListOn()){
          // to check master data
          switch (edpiod.getStaffType()){
          case "ENGR":
            if (!entStartupInitSingleton.getENGRDeptList().contains(resourceShiftType.getSFT().getDEP().trim())){
              LOG.warn("not matching the master data, staffType {}, deptId {}", resourceShiftType.getSFT().getDEP().trim() ,"ENGR");
             
              sendErroNotification(EnumExceptionCodes.WNOMD);
             
            }
            break;
          }
        }     
          edpiod.setStaffDept(resourceShiftType.getSFT().getDEP());
        }else {
          LOG.info("Mandatory field DEP is null or empty String, ResourceShiftType message is rejected");
         
          sendErroNotification(EnumExceptionCodes.EMAND);
         
          return false;         
        }
       
        }
       
       
        // (invaild for delete message)
        if (!"DEL".equalsIgnoreCase(staffShiftMsgSubType)){
        // set MWA
        if (resourceShiftType.getSFT().getMWA() != null && !"".equals(resourceShiftType.getSFT().getMWA())){
          if (entStartupInitSingleton.isMDWorkAreasListOn()){
          // to check with master data
            switch (edpiod.getStaffType()){
          case "ENGR":
            if (!entStartupInitSingleton.getENGRWorkAreasList().contains(resourceShiftType.getSFT().getMWA().trim())){
              LOG.warn("not matching the master data, staffType {}, workArea {}", resourceShiftType.getSFT().getMWA().trim() ,"ENGR");
             
              sendErroNotification(EnumExceptionCodes.WNOMD);
             
            }
            break;
            }
        } 
          edpiod.setStaffWorkArea(resourceShiftType.getSFT().getMWA());
        }
//        else {
//          LOG.info("Mandatory field MWA is null or empty String, ResourceShiftType message is rejected");
//          return false;         
//        }
       
        }
       
        // set VHI
        if (resourceShiftType.getSFT().getVHI() != null && !"".equals(resourceShiftType.getSFT().getVHI().trim())){
          edpiod.setResourceType(resourceShiftType.getSFT().getVHI());
        }
//        else {
//          LOG.info("Mandatory field VHI is null or empty String, ResourceShiftType message is rejected");
//          return false;       
//        }
View Full Code Here

    protected EntityManager getEntityManager() {
        return em;
    }
   
    public EntDbStaffShift getExsitRecord(EntDbStaffShift entDbStaffShift){
      EntDbStaffShift existRecord = null;
     
      Query query = em.createNamedQuery("EntDbStaffShift.findRecord");
    query.setParameter("shiftId", entDbStaffShift.getShiftId());
   
    List<?> resultList = query.getResultList();
View Full Code Here

     
      return existRecord;
    }
   
    public EntDbStaffShift getExsitRecordByShiftIdX(BigDecimal shiftId){
      EntDbStaffShift result = null;
     
    CriteriaBuilder cb = em.getCriteriaBuilder();
     CriteriaQuery<EntDbStaffShift> cq = cb.createQuery(EntDbStaffShift.class);
    Root<EntDbStaffShift> r = cq.from(EntDbStaffShift.class);
    cq.select(r);
View Full Code Here

   
    return resultList;
    }
   
    public EntDbStaffShift getExsitRecord(BigDecimal shiftId){
      EntDbStaffShift existRecord = null;
     
      Query query = em.createNamedQuery("EntDbStaffShift.findRecord");
    query.setParameter("shiftId", shiftId);
   
    List<?> resultList = query.getResultList();
View Full Code Here

     
      return existRecord;
    }
   
    public EntDbStaffShift getExsitRecord(String idFltJobTask, BigDecimal shiftId){
      EntDbStaffShift existRecord = null;
     
      Query query = em.createNamedQuery("EntDbStaffShift.findRecordByIdFltJobTaskAndShiftIdAndShiftId");
    query.setParameter("idFltJobTask", idFltJobTask);
    query.setParameter("shiftId", shiftId);
   
View Full Code Here

TOP

Related Classes of com.ufis_as.ek_if.rms.entities.EntDbStaffShift

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.