public static ims.core.resource.people.domain.objects.Gp extractGp(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.core.vo.GPNTPFVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_Gp();
    ims.core.resource.people.domain.objects.Gp domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.resource.people.domain.objects.Gp) domMap.get(valueObject);
      }
      // ims.core.vo.GPNTPFVo ID_Gp field is unknown
      domainObject = new ims.core.resource.people.domain.objects.Gp();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_Gp());
      if (domMap.get(key) != null) {
        return (ims.core.resource.people.domain.objects.Gp) domMap.get(key);
      }
      domainObject =
          (ims.core.resource.people.domain.objects.Gp)
              domainFactory.getDomainObject(ims.core.resource.people.domain.objects.Gp.class, id);

      // TODO: Not sure how this should be handled. Effectively it must be a staleobject exception,
      // but maybe should be handled as that further up.
      if (domainObject == null) return null;

      domMap.put(key, domainObject);
    }
    domainObject.setVersion(valueObject.getVersion_Gp());

    domainObject.setName(
        ims.core.vo.domain.PersonNameAssembler.extractPersonName(
            domainFactory, valueObject.getName(), domMap));
    domainObject.setPractices(
        ims.core.vo.domain.GPToPracticeNTPFVoAssembler.extractGpToPracticeSet(
            domainFactory, valueObject.getPractices(), domainObject.getPractices(), domMap));
    domainObject.setCodeMappings(
        ims.core.vo.domain.TaxonomyMapAssembler.extractTaxonomyMapList(
            domainFactory, valueObject.getCodeMappings(), domainObject.getCodeMappings(), domMap));

    return domainObject;
  }
  /**
   * Update the ValueObject with the Domain Object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param valueObject to be updated
   * @param domainObject ims.core.resource.people.domain.objects.Gp
   */
  public static ims.core.vo.GPNTPFVo insert(
      DomainObjectMap map,
      ims.core.vo.GPNTPFVo valueObject,
      ims.core.resource.people.domain.objects.Gp domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

    valueObject.setID_Gp(domainObject.getId());
    valueObject.setIsRIE(domainObject.getIsRIE());

    // If this is a recordedInError record, and the domainObject
    // value isIncludeRecord has not been set, then we return null and
    // not the value object
    if (valueObject.getIsRIE() != null
        && valueObject.getIsRIE().booleanValue() == true
        && !domainObject.isIncludeRecord()) return null;

    // If this is not a recordedInError record, and the domainObject
    // value isIncludeRecord has been set, then we return null and
    // not the value object
    if ((valueObject.getIsRIE() == null || valueObject.getIsRIE().booleanValue() == false)
        && domainObject.isIncludeRecord()) return null;

    // name
    valueObject.setName(ims.core.vo.domain.PersonNameAssembler.create(map, domainObject.getName()));
    // practices
    valueObject.setPractices(
        ims.core.vo.domain.GPToPracticeNTPFVoAssembler
            .createGPToPracticeNTPFVoCollectionFromGpToPractice(map, domainObject.getPractices()));
    // CodeMappings
    valueObject.setCodeMappings(
        ims.core.vo.domain.TaxonomyMapAssembler.createTaxonomyMapCollectionFromTaxonomyMap(
            map, domainObject.getCodeMappings()));
    return valueObject;
  }
Esempio n. 3
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;
  }