示例#1
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);
        //				}
      }
    }
  }