Esempio n. 1
0
 public ResourceMaster getResourceMasterByNumberAndProvider(String number, Provider provider) {
   ResourceMaster resourceMaster = null;
   try {
     resourceMaster = resourceMasterDao.getResourceByNumber(number, provider.getId());
   } catch (Exception e) {
     LOG.error(ImiDataFormatUtils.getStackTrace(e));
   }
   return resourceMaster;
 }
Esempio n. 2
0
 public ResourceMaster updateResource(
     String number,
     PurchaseResponse purchaseResponse,
     ServiceConstants serviceTypeEnum,
     Provider provider,
     Country country,
     Integer userid,
     Integer clientId,
     Integer groupid,
     Integer teamid,
     String clientname,
     String clientkey,
     String teamuuid,
     String numberType) {
   ResourceMaster resourceMaster = new ResourceMaster();
   try {
     resourceMaster.setServiceCode(number);
     // may need to configure
     resourceMaster.setChannel(ImiDataFormatUtils.getChannel(serviceTypeEnum));
     List<Object> creditsResultList = defaultQueryDao.getNamedQueryResults(creditsConfigQuery);
     BigInteger creditsMultiplier = new BigInteger("1");
     if (creditsResultList.size() > 0) {
       creditsMultiplier = (BigInteger) creditsResultList.get(0);
     }
     // hardcoding need to configure
     int resourceType = 4;
     resourceMaster.setResourceType((byte) resourceType);
     resourceMaster.setCategory((byte) 2);
     resourceMaster.setSubCategory((byte) 0);
     resourceMaster.setProviderId(provider.getId());
     resourceMaster.setNumberType(numberType);
     // hardcoding 2,5 for now need to configure
     String monthlyRentalRate =
         purchaseResponse.getMonthlyRentalRate() == null
                 || purchaseResponse.getMonthlyRentalRate().trim().equals("")
             ? "0"
             : ImiDataFormatUtils.roundOffToN(purchaseResponse.getMonthlyRentalRate(), 2);
     monthlyRentalRate =
         ImiDataFormatUtils.multiply(monthlyRentalRate, creditsMultiplier.toString());
     monthlyRentalRate = ImiDataFormatUtils.roundOffToN(monthlyRentalRate, 0);
     resourceMaster.setMonthlyRentalPrice(monthlyRentalRate);
     String voiceRate =
         purchaseResponse.getVoicePrice() == null
                 || purchaseResponse.getVoicePrice().trim().equals("")
             ? "0"
             : ImiDataFormatUtils.roundOffToN(purchaseResponse.getVoicePrice(), 5);
     voiceRate = ImiDataFormatUtils.multiply(voiceRate, creditsMultiplier.toString());
     voiceRate = ImiDataFormatUtils.roundOffToN(voiceRate, 0);
     resourceMaster.setVoiceInboundPrice(voiceRate);
     String smsRate =
         purchaseResponse.getSmsRate() == null || purchaseResponse.getSmsRate().trim().equals("")
             ? "0"
             : ImiDataFormatUtils.roundOffToN(purchaseResponse.getSmsRate(), 5);
     smsRate = ImiDataFormatUtils.multiply(smsRate, creditsMultiplier.toString());
     smsRate = ImiDataFormatUtils.roundOffToN(smsRate, 0);
     resourceMaster.setSmsInboundPrice(smsRate);
     updateCreditsConfigResource(number, teamuuid, monthlyRentalRate);
     resourceMaster.setCountryCode(country.getCountryCode());
     resourceMaster.setCountryIso(country.getCountryIso());
     resourceMaster.setCreatedOn(new Date());
     resourceMasterDao.createNewResource(resourceMaster);
   } catch (Exception e) {
     LOG.error(ImiDataFormatUtils.getStackTrace(e));
   }
   return resourceMaster;
 }