private boolean verifyStatusClause(Collection<Clause> clausules) throws CantUpdateCustomerBrokerPurchaseNegotiationException { Map<ClauseType, String> clausesAgreed = new HashMap<ClauseType, String>(); for (Clause clause : clausules) { if (clause.getStatus() == ClauseStatus.AGREED) { clausesAgreed.put(clause.getType(), clause.getValue()); } } if ((!clausesAgreed.containsKey(ClauseType.CUSTOMER_CURRENCY)) && (!clausesAgreed.containsKey(ClauseType.EXCHANGE_RATE)) && (!clausesAgreed.containsKey(ClauseType.CUSTOMER_CURRENCY_QUANTITY)) && (!clausesAgreed.containsKey(ClauseType.CUSTOMER_PAYMENT_METHOD))) { return false; } if (clausesAgreed.containsValue(CurrencyType.CRYPTO_MONEY.getCode())) { if (!clausesAgreed.containsKey(ClauseType.CUSTOMER_CRYPTO_ADDRESS)) { return false; } } if (clausesAgreed.containsValue(CurrencyType.BANK_MONEY.getCode())) { if ((!clausesAgreed.containsKey(ClauseType.CUSTOMER_BANK)) && (!clausesAgreed.containsKey(ClauseType.CUSTOMER_BANK_ACCOUNT))) { return false; } } if (clausesAgreed.containsValue(CurrencyType.CASH_ON_HAND_MONEY.getCode())) { if ((!clausesAgreed.containsKey(ClauseType.PLACE_TO_MEET)) && (!clausesAgreed.containsKey(ClauseType.DATE_TIME_TO_MEET))) { return false; } } if (clausesAgreed.containsValue(CurrencyType.CASH_DELIVERY_MONEY.getCode())) { if ((!clausesAgreed.containsKey(ClauseType.CUSTOMER_PLACE_TO_DELIVER)) && (!clausesAgreed.containsKey(ClauseType.CUSTOMER_DATE_TIME_TO_DELIVER))) { return false; } } return true; }
// PROCESS THE UPDATE PURCHASE NEGOTIATION TRANSACTION public void sendPurchaseNegotiationTranasction( CustomerBrokerPurchaseNegotiation customerBrokerPurchaseNegotiation) throws CantNewPurchaseNegotiationTransactionException { try { UUID transactionId = UUID.randomUUID(); System.out.print( "\n\n**** 3) MOCK NEGOTIATION TRANSACTION - CUSTOMER BROKER NEW - PURCHASE NEGOTIATION - CUSTOMER BROKER NEW PURCHASE NEGOTIATION TRANSACTION. transactionId: " + transactionId + " ****\n"); System.out.print( "\n\n --- 3.1) Negotiation Mock Date" + "\n- NegotiationId = " + customerBrokerPurchaseNegotiation.getNegotiationId() + "\n- CustomerPublicKey = " + customerBrokerPurchaseNegotiation.getCustomerPublicKey() + "\n- BrokerPublicKey = " + customerBrokerPurchaseNegotiation.getBrokerPublicKey() + "\n- Status = " + customerBrokerPurchaseNegotiation.getStatus()); System.out.print( "\n**** 3.2) MOCK MODULE CRYPTO CUSTOMER - PURCHASE NEGOTIATION - CLAUSES NEGOTIATION****\n"); for (Clause information : customerBrokerPurchaseNegotiation.getClauses()) { System.out.print( "\n**** 3.2.1) - CLAUSES: ****\n" + "\n- " + information.getType().getCode() + ": " + information.getValue() + " (STATUS: " + information.getStatus() + ")"); } // CREATE NEGOTIATION this.customerBrokerPurchaseNegotiationManager.createCustomerBrokerPurchaseNegotiation( customerBrokerPurchaseNegotiation); // TEST GET NEGOTIATION CustomerBrokerPurchaseNegotiation purchase = this.customerBrokerPurchaseNegotiationManager.getNegotiationsByNegotiationId( customerBrokerPurchaseNegotiation.getNegotiationId()); System.out.print( "\n\n --- 3.3) Negotiation DATABASE Date" + "\n- NegotiationId = " + purchase.getNegotiationId() + "\n- CustomerPublicKey = " + purchase.getCustomerPublicKey() + "\n- BrokerPublicKey = " + purchase.getBrokerPublicKey() + "\n- Status = " + customerBrokerPurchaseNegotiation.getStatus()); // CREATE NEGOTIATION TRANSATION this.customerBrokerNewNegotiationTransactionDatabaseDao .createCustomerBrokerNewNegotiationTransaction( transactionId, customerBrokerPurchaseNegotiation, NegotiationType.PURCHASE, NegotiationTransactionStatus.PENDING_SUBMIT); } catch (CantCreateCustomerBrokerPurchaseNegotiationException e) { errorManager.reportUnexpectedPluginException( pluginVersionReference, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw new CantNewPurchaseNegotiationTransactionException( e.getMessage(), e, CantNewPurchaseNegotiationTransactionException.DEFAULT_MESSAGE, "ERROR CREATE CUSTOMER BROKER PURCHASE NEGOTIATION, UNKNOWN FAILURE."); } catch (CantRegisterCustomerBrokerNewNegotiationTransactionException e) { errorManager.reportUnexpectedPluginException( pluginVersionReference, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw new CantNewPurchaseNegotiationTransactionException( e.getMessage(), e, CantNewPurchaseNegotiationTransactionException.DEFAULT_MESSAGE, "ERROR REGISTER CUSTOMER BROKER PURCHASE NEGOTIATION TRANSACTION, UNKNOWN FAILURE."); } catch (Exception e) { errorManager.reportUnexpectedPluginException( pluginVersionReference, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, e); throw new CantNewPurchaseNegotiationTransactionException( e.getMessage(), FermatException.wrapException(e), CantNewPurchaseNegotiationTransactionException.DEFAULT_MESSAGE, "ERROR PROCESS CUSTOMER BROKER PURCHASE NEGOTIATION, UNKNOWN FAILURE."); } }