Example #1
0
  private boolean processGPSDSLookup(PDSConfigurationVo conf) {
    if (gps == null || gps.size() == 0) return true;
    // WDEV-23281

    createSystemLogEntry(
        SystemLogType.SDS,
        SystemLogLevel.INFORMATION,
        "Start Process of GP Full SDS Job - Number of records to process = " + gps.size());

    DomainFactoryBridge factory = getDomainFactory();

    Iterator<Gp> it = gps.iterator();

    while (it.hasNext()) {
      Gp gp = it.next();
      if (gp == null) continue;

      String sdsId = "";
      String gpCode = "";

      if (gp.getCodeMappings() != null) {
        for (int j = 0; j < gp.getCodeMappings().size(); j++) {
          Object mapping = gp.getCodeMappings().get(j);

          if (mapping instanceof TaxonomyMap) {
            if (((TaxonomyMap) mapping).getTaxonomyName() != null
                && (TaxonomyType.SDSID.getID()
                    == ((TaxonomyMap) mapping).getTaxonomyName().getId())) {
              sdsId = ((TaxonomyMap) mapping).getTaxonomyCode();
            }

            if (((TaxonomyMap) mapping).getTaxonomyName() != null
                && (TaxonomyType.NAT_GP_CODE.getID()
                    == ((TaxonomyMap) mapping).getTaxonomyName().getId())) {
              gpCode = ((TaxonomyMap) mapping).getTaxonomyCode();
            }
          }
        }
      }

      if ((sdsId != null && sdsId.length() > 0) || (gpCode != null && gpCode.length() > 0)) {
        TotalGPsNo++;

        SdsRequestHelper sdsHelper = new SdsRequestHelper(conf);

        Gp gpNew = null;

        try {
          gpNew = sdsHelper.processGPSdsRequest(gp, conf.getSDSHost(), conf.getSDSPort());

          try {
            if ((gpNew != null && gpNew.getName() != null)
                && (gp != null && gp.getName() != null)) {

              // get the Gp record again and update

              // Only update retrieved gp domain object from db from query on list, not the gp
              // instance returned from the sds request
              gp.getName().setForename(gpNew.getName().getForename());
              gp.getName()
                  .setUpperForename(
                      gpNew.getName().getForename() != null
                          ? gpNew.getName().getForename().toUpperCase()
                          : null);
              gp.getName().setSurname(gpNew.getName().getSurname());
              gp.getName()
                  .setUpperSurname(
                      gpNew.getName().getSurname() != null
                          ? gpNew.getName().getSurname().toUpperCase()
                          : null);
              gp.getName().setMiddleName(gpNew.getName().getMiddleName());
              gp.getName().setTitle(gpNew.getName().getTitle());

              //							if(updatedGps == null)
              //							{
              //								updatedGps = new HashSet<Gp>();
              //							}
              //
              //							updatedGps.add(gp);

              if (factory == null) factory = getDomainFactory();

              factory.save(gp);

              if (TotalGPsNo % 100 == 0) {
                createSystemLogEntry(
                    SystemLogType.SDS,
                    SystemLogLevel.INFORMATION,
                    "Commit tranaction GP Full SDS Job - Number of records processed = "
                        + TotalGPsNo);
                factory.commitTransaction();
              }
            }

          } catch (Exception e) {
            // trace("Error during saving updates for GP '" + gp.getName().toString()  + "': " +
            // e.getMessage());

            if (gp != null && gp.getName() != null)
              createSystemLogEntry(
                  SystemLogType.SDS,
                  SystemLogLevel.ERROR,
                  "Error during saving updates for GP '"
                      + gp.getName().toString()
                      + "': "
                      + e.getMessage());
            else if (gp != null)
              createSystemLogEntry(
                  SystemLogType.SDS,
                  SystemLogLevel.ERROR,
                  "Error during saving updates for GP '" + gp.getName() + "': " + e.getMessage());
            FailedNoSavingGPs++;
            continue;
          }

          SuccessfulGPssNo++;

        } catch (Exception e) {
          if (e.getCause() instanceof ConnectException
              || e.getCause() instanceof SocketException
              || e.getCause() instanceof UnknownHostException) {
            return false;
          }

          // trace("Error processing SDS request for GP '" + gp.getName().toString()  + "': " +
          // e.getMessage());
          if (gp != null && gp.getName() != null)
            createSystemLogEntry(
                SystemLogType.SDS,
                SystemLogLevel.ERROR,
                "Error processing SDS request for GP '"
                    + gp.getName().toString()
                    + "': "
                    + e.getMessage());
          else if (gp != null)
            createSystemLogEntry(
                SystemLogType.SDS,
                SystemLogLevel.ERROR,
                "Error processing SDS request for GP '" + gp.getName() + "': " + e.getMessage());
          FailedNoProcessingGPs++;
          continue;
        }

        //				if(gpNew != null)
        //				{
        //					if(updatedGps == null)
        //					{
        //						updatedGps = new HashSet<Gp>();
        //					}
        //
        //					//Only update retrieved gp domain object from db from query on list, not the gp
        // instance returned from the sds request
        //	        		gp.getName().setForename(gpNew.getName().getForename());
        //	            	gp.getName().setUpperForename(gpNew.getName().getForename() != null ?
        // gpNew.getName().getForename().toUpperCase() : null);
        //	            	gp.getName().setSurname(gpNew.getName().getForename());
        //	            	gp.getName().setUpperSurname(gpNew.getName().getSurname() != null ?
        // gpNew.getName().getSurname().toUpperCase() : null);
        //	            	gp.getName().setMiddleName(gpNew.getName().getMiddleName());
        //	            	gp.getName().setTitle(gpNew.getName().getTitle());
        //
        //					updatedGps.add(gp);
        //				}
      }
    }
    // WDEV-23281

    return true;
  }
Example #2
0
  // WDEV-23281
  private void processPracticeSDSLookup(PDSConfigurationVo conf) {
    if (practices == null || practices.size() == 0) return;

    createSystemLogEntry(
        SystemLogType.SDS,
        SystemLogLevel.INFORMATION,
        "Start Process of Practice Full SDS Job - Number of records to process = "
            + practices.size());

    Iterator<Organisation> it = practices.iterator();
    while (it.hasNext()) {

      Organisation practice = it.next();

      DomainFactoryBridge factory = getDomainFactory();

      if (practice == null) continue;

      String sdsOrgId = getTaxonomyCode(practice, TaxonomyType.ICAB);

      if (sdsOrgId == null || sdsOrgId.length() == 0) {
        sdsOrgId = getTaxonomyCode(practice, TaxonomyType.NAT_LOC_CODE);
      }

      if (sdsOrgId != null && sdsOrgId.length() > 0) {
        TotalPracticesNo++;

        SdsRequestHelper sdsHelper = new SdsRequestHelper(conf);

        Organisation updatedPractice = null;

        try {
          updatedPractice =
              sdsHelper.processPracticeSdsRequest(practice, conf.getSDSHost(), conf.getSDSPort());

          if (updatedPractice != null && practice != null) {
            practice.setName(updatedPractice.getName());
            practice.setUpperName(updatedPractice.getUpperName());
            practice.setAddress(updatedPractice.getAddress());
            practice.setIsActive(updatedPractice.isIsActive());
            practice.setPctCode(updatedPractice.getPctCode());

            try {
              factory.save(practice);
              if (TotalPracticesNo % 100 == 0) {
                createSystemLogEntry(
                    SystemLogType.SDS,
                    SystemLogLevel.INFORMATION,
                    "Commit tranaction Practice Full SDS Job - Number of records processed = "
                        + TotalPracticesNo);
                factory.commitTransaction();
              }
            } catch (Exception e) {
              // trace("Error saving SDS request for Practice '" + practice.getName()  + "': " +
              // e.getMessage());
              if (practice != null)
                createSystemLogEntry(
                    SystemLogType.SDS,
                    SystemLogLevel.ERROR,
                    "Error saving SDS request for Practice '"
                        + practice.getName()
                        + "': "
                        + e.getMessage());
              FailedNoSavingPractices++;
              continue;
            }
          }

        } catch (Exception e) {
          // trace("Error processing SDS request for Practice '" + practice.getName()  + "': " +
          // e.getMessage());
          if (practice != null)
            createSystemLogEntry(
                SystemLogType.SDS,
                SystemLogLevel.ERROR,
                "Error processing SDS request for Practice '"
                    + practice.getName()
                    + "': "
                    + e.getMessage());
          FailedNoProcessingPractices++;
          continue;
        }

        //				if(updatedPractice != null)
        //				{
        //					if(updatedPractices == null)
        //					{
        //						updatedPractices = new HashSet<Organisation>();
        //					}
        //
        //					updatedPractices.add(updatedPractice);
        //				}
      }
    }
  }