@Override public void populate(final Map<String, String> source, final CreateSubscriptionResult target) throws ConversionException { validateParameterNotNull(source, "Parameter [Map<String, String>] source cannot be null"); validateParameterNotNull(target, "Parameter [CreateSubscriptionResult] target cannot be null"); final CustomerInfoData data = new CustomerInfoData(); data.setBillToCity(source.get("billTo_city")); data.setBillToCompany(source.get("billTo_company")); data.setBillToCompanyTaxId(source.get("billTo_companyTaxID")); final String countryIso = source.get("billTo_country"); if (StringUtils.isNotBlank(countryIso)) { data.setBillToCountry(countryIso.toUpperCase(Locale.getDefault())); } data.setBillToCustomerIdRef(source.get("billTo_customerID")); data.setBillToDateOfBirth(source.get("billTo_dateOfBirth")); data.setBillToEmail(source.get("billTo_email")); data.setBillToFirstName(source.get("billTo_firstName")); data.setBillToLastName(source.get("billTo_lastName")); data.setBillToPhoneNumber(source.get("billTo_phoneNumber")); data.setBillToPostalCode(source.get("billTo_postalCode")); data.setBillToState(source.get("billTo_state")); data.setBillToStreet1(source.get("billTo_street1")); data.setBillToStreet2(source.get("billTo_street2")); data.setBillToTitleCode(source.get("billTo_titleCode")); target.setCustomerInfoData(data); }
protected Transition executeAction(final OrderProcessModel process) { ServicesUtil.validateParameterNotNull(process, "Process cannot be null"); LOG.info("Process: " + process.getCode() + " in step " + getClass().getSimpleName()); final OrderModel order = process.getOrder(); ServicesUtil.validateParameterNotNull(order, "Order in process cannot be null"); ServicesUtil.validateParameterNotNull( order.getFraudulent(), "Fraudulent value in order cannot be null"); final OrderHistoryEntryModel historyLog = createHistoryLog("Order Manually checked by CSA - Fraud = " + order.getFraudulent(), order); modelService.save(historyLog); LOG.info( "The fraud condition of the order " + order.getCode() + " is " + order.getFraudulent().booleanValue()); if (order.getFraudulent().booleanValue()) { order.setStatus(OrderStatus.SUSPENDED); getModelService().save(order); return Transition.NOK; } else { order.setStatus(OrderStatus.FRAUD_CHECKED); getModelService().save(order); return Transition.OK; } }
@Override public Transition executeAction(final OrderProcessModel process) { LOG.info("Process: " + process.getCode() + " in step " + getClass()); ServicesUtil.validateParameterNotNull(process, "Process can not be null"); ServicesUtil.validateParameterNotNull(process.getOrder(), "Order can not be null"); final double scoreLimit = Double.parseDouble( Config.getParameter( HybrisTestFulfilmentProcessConstants.EXTENSIONNAME + ".fraud.scoreLimitExternal")); final double scoreTolerance = Double.parseDouble( Config.getParameter( HybrisTestFulfilmentProcessConstants.EXTENSIONNAME + ".fraud.scoreToleranceExternal")); final OrderModel order = process.getOrder(); final FraudServiceResponse response = getFraudService().recognizeOrderSymptoms(getProviderName(), order); final double score = response.getScore(); if (score < scoreLimit) { final FraudReportModel fraudReport = createFraudReport(providerName, response, order, FraudStatus.OK); final OrderHistoryEntryModel historyEntry = createHistoryLog(providerName, order, FraudStatus.OK, null); order.setFraudulent(Boolean.FALSE); order.setPotentiallyFraudulent(Boolean.FALSE); order.setStatus(OrderStatus.FRAUD_CHECKED); modelService.save(fraudReport); modelService.save(historyEntry); modelService.save(order); return Transition.OK; } else if (score < scoreLimit + scoreTolerance) { final FraudReportModel fraudReport = createFraudReport(providerName, response, order, FraudStatus.CHECK); final OrderHistoryEntryModel historyEntry = createHistoryLog(providerName, order, FraudStatus.CHECK, fraudReport.getCode()); order.setFraudulent(Boolean.FALSE); order.setPotentiallyFraudulent(Boolean.TRUE); order.setStatus(OrderStatus.FRAUD_CHECKED); modelService.save(fraudReport); modelService.save(historyEntry); modelService.save(order); return Transition.POTENTIAL; } else { final FraudReportModel fraudReport = createFraudReport(providerName, response, order, FraudStatus.FRAUD); final OrderHistoryEntryModel historyEntry = createHistoryLog(providerName, order, FraudStatus.FRAUD, fraudReport.getCode()); order.setFraudulent(Boolean.TRUE); order.setPotentiallyFraudulent(Boolean.FALSE); order.setStatus(OrderStatus.FRAUD_CHECKED); modelService.save(fraudReport); modelService.save(historyEntry); modelService.save(order); return Transition.FRAUD; } }
private Object convertValue( final ClassAttributeAssignmentModel assignment, final String stringValue) { final String typeCode = assignment.getAttributeType().getCode(); if (ClassificationAttributeTypeEnum.BOOLEAN.getCode().equals(typeCode)) { return Boolean.valueOf(stringValue); } else if (ClassificationAttributeTypeEnum.ENUM.getCode().equals(typeCode)) { // YTODO final Item item = JaloSession.getCurrentSession().getItem(PK.parse(stringValue)); final Object value = load(item); validateParameterNotNull(value, "No such value with PK: " + stringValue); return value; } else if (ClassificationAttributeTypeEnum.NUMBER.getCode().equals(typeCode)) { return Double.valueOf(stringValue); } else if (ClassificationAttributeTypeEnum.STRING.getCode().equals(typeCode)) { return stringValue; } else if (ClassificationAttributeTypeEnum.DATE.getCode().equals(typeCode)) { try { return Utilities.getDateTimeInstance().parse(stringValue); } catch (final ParseException e) { throw new IllegalArgumentException(e.getMessage(), e); } } else { throw new IllegalArgumentException("Invalid classifcation attribute type code: " + typeCode); } }
@Override public List<CourseModel> findCourseByCode(final String code) { validateParameterNotNull(code, "Product code must not be null!"); final Map<String, Object> params = new HashMap<String, Object>(); params.put("code", code); final SearchResult<CourseModel> result = flexibleSearchService.search(COURSES_BY_CODE, params); return result.getResult(); }
@Override public void populate(final Map<String, String> source, final CreateSubscriptionResult target) throws ConversionException { validateParameterNotNull(source, "Parameter [Map<String, String>] source cannot be null"); validateParameterNotNull(target, "Parameter [CreateSubscriptionResult] target cannot be null"); final PaymentInfoData data = new PaymentInfoData(); data.setCardAccountNumber(source.get("card_accountNumber")); data.setCardCardType(source.get("card_cardType")); data.setCardAccountHolderName(source.get("card_nameOnCard")); data.setCardExpirationMonth(getIntegerForString(source.get("card_expirationMonth"))); data.setCardExpirationYear(getIntegerForString(source.get("card_expirationYear"))); data.setCardStartMonth(source.get("card_startMonth")); data.setCardStartYear(source.get("card_startYear")); data.setPaymentOption(source.get("paymentOption")); target.setPaymentInfoData(data); }
protected Transition executeAction(final OrderProcessModel process) { ServicesUtil.validateParameterNotNull(process, "Process cannot be null"); final OrderModel order = process.getOrder(); ServicesUtil.validateParameterNotNull(order, "Order in process cannot be null"); if (order.getFraudulent() != null) { final OrderHistoryEntryModel historyLog = createHistoryLog( "Order Manually checked by CSA - Fraud = " + order.getFraudulent(), order); modelService.save(historyLog); if (order.getFraudulent().booleanValue()) { order.setStatus(OrderStatus.SUSPENDED); getModelService().save(order); return Transition.NOK; } return Transition.OK; } return Transition.UNDEFINED; }
@Override public CreditCardPaymentInfoModel findCreditCartPaymentBySubscription( final String subscriptionId) { validateParameterNotNull(subscriptionId, "subscriptionId must not be null!"); final FlexibleSearchQuery fQuery = new FlexibleSearchQuery(PAYMENT_QUERY); fQuery.addQueryParameter("subscriptionId", subscriptionId); final SearchResult<CreditCardPaymentInfoModel> searchResult = getFlexibleSearchService().search(fQuery); final List<CreditCardPaymentInfoModel> results = searchResult.getResult(); if (results != null && results.iterator().hasNext()) { return results.iterator().next(); } return null; }
@Override public CCPaySubValidationModel findSubscriptionValidationBySubscription( final String subscriptionId) { validateParameterNotNull(subscriptionId, "subscriptionId must not be null!"); final FlexibleSearchQuery fQuery = new FlexibleSearchQuery(SUBSCRIPTION_QUERY); fQuery.addQueryParameter("subscriptionId", subscriptionId); final SearchResult<CCPaySubValidationModel> searchResult = getFlexibleSearchService().search(fQuery); final List<CCPaySubValidationModel> results = searchResult.getResult(); if (results != null && results.iterator().hasNext()) { return results.iterator().next(); } return null; }
@Override public void populate(final AddressModel source, final CustomerBillToData target) throws ConversionException { // We may not have any existing billing address. if (source == null) { return; } validateParameterNotNull(target, "Parameter [CustomerBillToData] target cannot be null"); target.setBillToCustomerIdRef(source.getEmail()); // UID is the email address target.setBillToEmail(source.getEmail()); target.setBillToCity(source.getTown()); target.setBillToCompany(source.getCompany()); target.setBillToCountry(source.getCountry().getIsocode()); target.setBillToEmail(source.getEmail()); target.setBillToFirstName(source.getFirstname()); target.setBillToLastName(source.getLastname()); target.setBillToPhoneNumber(source.getPhone1()); target.setBillToPostalCode(source.getPostalcode()); target.setBillToState(source.getDistrict()); target.setBillToStreet1(source.getLine1()); target.setBillToStreet2(source.getLine2()); }