コード例 #1
0
 public CountryEbo getVendorCountry() {
   if (StringUtils.isBlank(vendorCorpCitizenCode)) {
     vendorCountry = null;
   } else {
     if (vendorCountry == null
         || !StringUtils.equals(vendorCountry.getCode(), vendorCorpCitizenCode)) {
       ModuleService moduleService =
           SpringContext.getBean(KualiModuleService.class)
               .getResponsibleModuleService(CountryEbo.class);
       if (moduleService != null) {
         Map<String, Object> keys = new HashMap<String, Object>(1);
         keys.put(LocationConstants.PrimaryKeyConstants.CODE, vendorCorpCitizenCode);
         vendorCountry = moduleService.getExternalizableBusinessObject(CountryEbo.class, keys);
       } else {
         throw new RuntimeException(
             "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed.");
       }
     }
   }
   return vendorCountry;
 }
コード例 #2
0
  public Object retrieveDataObject(Map<String, String> parameters) {
    if (dataObjectClass == null) {
      LOG.error("Data object class must be set in inquirable before retrieving the object");
      throw new RuntimeException(
          "Data object class must be set in inquirable before retrieving the object");
    }

    // build list of key values from the map parameters
    List<String> pkPropertyNames =
        getDataObjectMetaDataService().listPrimaryKeyFieldNames(dataObjectClass);

    // some classes might have alternate keys defined for retrieving
    List<List<String>> alternateKeyNames = this.getAlternateKeysForClass(dataObjectClass);

    // add pk set as beginning so it will be checked first for match
    alternateKeyNames.add(0, pkPropertyNames);

    List<String> dataObjectKeySet = retrieveKeySetFromMap(alternateKeyNames, parameters);
    if ((dataObjectKeySet == null) || dataObjectKeySet.isEmpty()) {
      LOG.warn("Matching key set not found in request for class: " + getDataObjectClass());

      return null;
    }
    String patronHome = parameters.get("flow");

    // found key set, now build map of key values pairs we can use to retrieve the object
    Map<String, Object> keyPropertyValues = new HashMap<String, Object>();
    for (String keyPropertyName : dataObjectKeySet) {
      String keyPropertyValue = parameters.get(keyPropertyName);

      // uppercase value if needed
      Boolean forceUppercase = Boolean.FALSE;
      try {
        forceUppercase =
            getDataDictionaryService().getAttributeForceUppercase(dataObjectClass, keyPropertyName);
      } catch (UnknownBusinessClassAttributeException ex) {
        // swallowing exception because this check for ForceUppercase would
        // require a DD entry for the attribute, and we will just set force uppercase to false
        LOG.warn(
            "Data object class "
                + dataObjectClass
                + " property "
                + keyPropertyName
                + " should probably have a DD definition.",
            ex);
      }

      if (forceUppercase.booleanValue() && (keyPropertyValue != null)) {
        keyPropertyValue = keyPropertyValue.toUpperCase();
      }

      // check security on key field
      if (getDataObjectAuthorizationService()
          .attributeValueNeedsToBeEncryptedOnFormsAndLinks(dataObjectClass, keyPropertyName)) {
        try {
          keyPropertyValue = getEncryptionService().decrypt(keyPropertyValue);
        } catch (GeneralSecurityException e) {
          LOG.error(
              "Data object class "
                  + dataObjectClass
                  + " property "
                  + keyPropertyName
                  + " should have been encrypted, but there was a problem decrypting it.",
              e);
          throw new RuntimeException(
              "Data object class "
                  + dataObjectClass
                  + " property "
                  + keyPropertyName
                  + " should have been encrypted, but there was a problem decrypting it.",
              e);
        }
      }

      keyPropertyValues.put(keyPropertyName, keyPropertyValue);
    }

    // now retrieve the object based on the key set
    Object dataObject = null;

    ModuleService moduleService =
        KRADServiceLocatorWeb.getKualiModuleService()
            .getResponsibleModuleService(getDataObjectClass());
    if (moduleService != null && moduleService.isExternalizable(getDataObjectClass())) {
      dataObject =
          moduleService.getExternalizableBusinessObject(
              getDataObjectClass().asSubclass(ExternalizableBusinessObject.class),
              keyPropertyValues);
    } else if (BusinessObject.class.isAssignableFrom(getDataObjectClass())) {
      dataObject =
          getBusinessObjectService()
              .findByPrimaryKey(
                  getDataObjectClass().asSubclass(BusinessObject.class), keyPropertyValues);
    }
    // OleEntityAddressBo entityAddressBo = new OleEntityAddressBo();
    EntityAddressBo entityAddress = new EntityAddressBo();
    List<OleEntityAddressBo> oleEntityAddressList = new ArrayList<OleEntityAddressBo>();
    List<OleEntityPhoneBo> oleEntityPhoneBoList = new ArrayList<>();
    List<OleEntityEmailBo> oleEntityEmailBoList = new ArrayList<>();
    OlePatronDocument patronDocument = (OlePatronDocument) dataObject;
    if (patronDocument != null) {
      EntityBo kimEnity = patronDocument.getEntity();
      if (kimEnity.getNames().size() > 0) {
        patronDocument.setName(kimEnity.getNames().get(0));
      }
      if (kimEnity.getEntityTypeContactInfos().size() > 0) {
        List<EntityAddressBo> entityAddressList =
            kimEnity.getEntityTypeContactInfos().get(0).getAddresses();
        for (EntityAddressBo entityAdd : entityAddressList) {
          OleEntityAddressBo entityAddressBo = new OleEntityAddressBo();
          entityAddressBo.setEntityAddressBo(entityAdd);
          Map addMap = new HashMap();
          // addMap.put(OLEConstants.OlePatron.OLE_ADDRESS_ID, entityAdd.getId());
          addMap.put(OLEConstants.OlePatron.ENTITY_BO_ID, entityAdd.getId());
          addMap.put(OLEConstants.OlePatron.PATRON_ID, patronDocument.getId());
          List<OleAddressBo> oleAddressBos =
              (List<OleAddressBo>)
                  getBusinessObjectService().findMatching(OleAddressBo.class, addMap);
          if (CollectionUtils.isNotEmpty(oleAddressBos)) {
            entityAddressBo.setOleAddressBo(oleAddressBos.get(0));
          }
          oleEntityAddressList.add(entityAddressBo);
        }
        patronDocument.setOleEntityAddressBo(oleEntityAddressList);
        List<EntityPhoneBo> entityPhoneBoList =
            kimEnity.getEntityTypeContactInfos().get(0).getPhoneNumbers();
        for (EntityPhoneBo entityPhoneBo : entityPhoneBoList) {
          OleEntityPhoneBo oleEntityPhoneBo = new OleEntityPhoneBo();
          oleEntityPhoneBo.setEntityPhoneBo(entityPhoneBo);
          Map map = new HashMap();
          map.put(OLEConstants.OlePatron.ENTITY_BO_ID, entityPhoneBo.getId());
          map.put(OLEConstants.OlePatron.PATRON_ID, patronDocument.getId());
          List<OlePhoneBo> olePhoneBos =
              (List<OlePhoneBo>) getBusinessObjectService().findMatching(OlePhoneBo.class, map);
          if (CollectionUtils.isNotEmpty(olePhoneBos)) {
            oleEntityPhoneBo.setOlePhoneBo(olePhoneBos.get(0));
          }
          oleEntityPhoneBoList.add(oleEntityPhoneBo);
        }
        patronDocument.setOleEntityPhoneBo(oleEntityPhoneBoList);
        List<EntityEmailBo> entityEmailBoList =
            kimEnity.getEntityTypeContactInfos().get(0).getEmailAddresses();
        for (EntityEmailBo entityEmailBo : entityEmailBoList) {
          OleEntityEmailBo oleEntityEmailBo = new OleEntityEmailBo();
          oleEntityEmailBo.setEntityEmailBo(entityEmailBo);
          Map map = new HashMap();
          map.put(OLEConstants.OlePatron.ENTITY_BO_ID, entityEmailBo.getId());
          map.put(OLEConstants.OlePatron.PATRON_ID, patronDocument.getId());
          List<OleEmailBo> oleEmailBos =
              (List<OleEmailBo>) getBusinessObjectService().findMatching(OleEmailBo.class, map);
          if (CollectionUtils.isNotEmpty(oleEmailBos)) {
            oleEntityEmailBo.setOleEmailBo(oleEmailBos.get(0));
          }
          oleEntityEmailBoList.add(oleEntityEmailBo);
        }
        patronDocument.setOleEntityEmailBo(oleEntityEmailBoList);
        patronDocument.setPatronAffiliations(
            getPatronAffiliationFromEntity(
                kimEnity.getAffiliations(), kimEnity.getEmploymentInformation()));
        if (patronHome != null) {
          if (patronHome.equalsIgnoreCase("start")) patronDocument.setPatronHomePage(false);
          else patronDocument.setPatronHomePage(true);
        }
      }
      if (null != patronDocument.getName()) {
        String createBillUrl =
            OLEConstants.OlePatron.PATRON_CREATE_BILL_URL
                + patronDocument.getOlePatronId()
                + "&firstName="
                + patronDocument.getName().getFirstName()
                + "&lastName="
                + patronDocument.getName().getLastName();
        patronDocument.setCreateBillUrl(createBillUrl);
      }
      if (CollectionUtils.isNotEmpty(patronDocument.getPatronBillPayments())) {
        patronDocument.setPatronBillFileName(OLEConstants.OlePatron.PATRON_VIEW_BILLS);
        patronDocument.setViewBillUrl(
            OLEConstants.OlePatron.PATRON_VIEW_BILL_URL + patronDocument.getOlePatronId());
      }
      patronDocument.setShowBillUrlsFlag(true);
    }

    if (CollectionUtils.isNotEmpty(patronDocument.getOleProxyPatronDocuments())) {
      OlePatronDocument olePatronDocument;
      for (OleProxyPatronDocument oleProxyPatronDocument :
          patronDocument.getOleProxyPatronDocuments()) {
        olePatronDocument = oleProxyPatronDocument.getOlePatronDocument();
        oleProxyPatronDocument.setProxyForPatronFirstName(
            olePatronDocument.getEntity().getNames().get(0).getFirstName());
        oleProxyPatronDocument.setProxyForPatronLastName(
            olePatronDocument.getEntity().getNames().get(0).getLastName());
      }
    }
    if (CollectionUtils.isNotEmpty(patronDocument.getOleProxyPatronDocumentList())) {
      OlePatronDocument olePatronDocument;
      for (OleProxyPatronDocument oleProxyPatronDocument :
          patronDocument.getOleProxyPatronDocumentList()) {
        olePatronDocument = oleProxyPatronDocument.getOlePatronDocument();
        oleProxyPatronDocument.setProxyForPatronFirstName(
            olePatronDocument.getEntity().getNames().get(0).getFirstName());
        oleProxyPatronDocument.setProxyForPatronLastName(
            olePatronDocument.getEntity().getNames().get(0).getLastName());
      }
    }

    if (patronDocument.getOleLoanDocuments() != null) {
      patronDocument.setLoanCount(patronDocument.getOleLoanDocuments().size());
    }
    if (patronDocument.getOleTemporaryCirculationHistoryRecords() != null) {
      patronDocument.setTempCirculationHistoryCount(
          patronDocument.getOleTemporaryCirculationHistoryRecords().size());
    }
    if (patronDocument.getOleDeliverRequestBos() != null) {
      patronDocument.setRequestedItemRecordsCount(patronDocument.getOleDeliverRequestBos().size());
    }

    return patronDocument;
  }