コード例 #1
0
ファイル: AssetReceptionDao.java プロジェクト: yeniree/fermat
  private boolean isAssetsByReceptionStatus(ReceptionStatus receptionStatus)
      throws CantExecuteQueryException {
    try {
      this.database = openDatabase();
      DatabaseTable databaseTable;
      databaseTable = database.getTable(AssetReceptionDatabaseConstants.ASSET_RECEPTION_TABLE_NAME);
      databaseTable.addStringFilter(
          AssetReceptionDatabaseConstants.ASSET_RECEPTION_RECEPTION_STATUS_COLUMN_NAME,
          receptionStatus.getCode(),
          DatabaseFilterType.EQUAL);
      databaseTable.addStringFilter(
          AssetReceptionDatabaseConstants.ASSET_RECEPTION_CRYPTO_STATUS_COLUMN_NAME,
          CryptoStatus.PENDING_SUBMIT.getCode(),
          DatabaseFilterType.EQUAL);
      databaseTable.loadToMemory();

      return !databaseTable.getRecords().isEmpty();
    } catch (CantLoadTableToMemoryException exception) {

      throw new CantExecuteQueryException(
          "Error executing query in DB.",
          exception,
          "Getting assets by reception status.",
          "Cannot load table to memory.");
    } catch (Exception exception) {

      throw new CantExecuteQueryException(
          CantExecuteQueryException.DEFAULT_MESSAGE,
          FermatException.wrapException(exception),
          "Getting assets by reception status.",
          "Unexpected exception");
    }
  }
コード例 #2
0
ファイル: AssetReceptionDao.java プロジェクト: yeniree/fermat
  public void persistDigitalAsset(
      String genesisTransaction,
      String localStoragePath,
      String digitalAssetHash,
      String senderId,
      PlatformComponentType platformComponentType)
      throws CantPersistDigitalAssetException {
    try {
      this.database = openDatabase();
      DatabaseTable databaseTable =
          getDatabaseTable(AssetReceptionDatabaseConstants.ASSET_RECEPTION_TABLE_NAME);
      DatabaseTableRecord record = databaseTable.getEmptyRecord();
      record.setStringValue(
          AssetReceptionDatabaseConstants.ASSET_RECEPTION_GENESIS_TRANSACTION_COLUMN_NAME,
          genesisTransaction);
      record.setStringValue(
          AssetReceptionDatabaseConstants.ASSET_RECEPTION_DIGITAL_ASSET_HASH_COLUMN_NAME,
          digitalAssetHash);
      record.setStringValue(
          AssetReceptionDatabaseConstants
              .ASSET_RECEPTION_DIGITAL_ASSET_STORAGE_LOCAL_PATH_COLUMN_NAME,
          localStoragePath);
      record.setStringValue(
          AssetReceptionDatabaseConstants.ASSET_RECEPTION_SENDER_ID_COLUMN_NAME, senderId);
      record.setStringValue(
          AssetReceptionDatabaseConstants.ASSET_RECEPTION_SENDER_TYPE_COLUMN_NAME,
          platformComponentType.getCode());
      record.setStringValue(
          AssetReceptionDatabaseConstants.ASSET_RECEPTION_RECEPTION_STATUS_COLUMN_NAME,
          ReceptionStatus.RECEIVING.getCode());
      record.setStringValue(
          AssetReceptionDatabaseConstants.ASSET_RECEPTION_PROTOCOL_STATUS_COLUMN_NAME,
          ProtocolStatus.TO_BE_NOTIFIED.getCode());
      record.setStringValue(
          AssetReceptionDatabaseConstants.ASSET_RECEPTION_CRYPTO_STATUS_COLUMN_NAME,
          CryptoStatus.PENDING_SUBMIT.getCode());

      databaseTable.insertRecord(record);
    } catch (CantExecuteDatabaseOperationException exception) {
      throw new CantPersistDigitalAssetException(
          exception,
          "Persisting a receiving genesis digital asset",
          "Cannot open the Asset Reception database");
    } catch (CantInsertRecordException exception) {
      throw new CantPersistDigitalAssetException(
          exception,
          "Persisting a receiving genesis digital asset",
          "Cannot insert a record in the Asset Reception database");
    } catch (Exception exception) {
      throw new CantPersistDigitalAssetException(
          exception, "Persisting a receiving genesis digital asset", "Unexpected exception");
    }
  }
コード例 #3
0
  private void loadRecordAsNew(
      DatabaseTableRecord databaseTableRecord,
      UUID trxId,
      String txHash,
      String walletPublicKey,
      CryptoAddress destinationAddress,
      long cryptoAmount,
      String op_Return,
      String notes,
      String deliveredByActorPublicKey,
      Actors deliveredByActorType,
      String deliveredToActorPublicKey,
      Actors deliveredToActorType,
      ReferenceWallet referenceWallet,
      boolean sameDevice,
      BlockchainNetworkType blockchainNetworkType) {

    databaseTableRecord.setUUIDValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_ID_COLUMN_NAME, trxId);
    //        if(requestId != null)
    //
    // databaseTableRecord.setUUIDValue(OutgoingIntraActorTransactionDatabaseConstants.OUTGOING_DRAFT_REQUEST_ID_COLUMN_NAME, requestId);

    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants
            .OUTGOING_DRAFT_WALLET_ID_TO_DEBIT_FROM_COLUMN_NAME,
        walletPublicKey);

    // TODO: This will be completed when the vault gives it to us
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_HASH_COLUMN_NAME,
        txHash);

    // TODO: This need to be completed in the future
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ADDRESS_FROM_COLUMN_NAME,
        "MY_ADDRESS");
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ADDRESS_TO_COLUMN_NAME,
        destinationAddress.getAddress());
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_CRYPTO_CURRENCY_COLUMN_NAME,
        destinationAddress.getCryptoCurrency().getCode());
    databaseTableRecord.setLongValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_CRYPTO_AMOUNT_COLUMN_NAME,
        cryptoAmount);
    if (op_Return != null)
      databaseTableRecord.setStringValue(
          OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_OP_RETURN_COLUMN_NAME,
          op_Return);
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TRANSACTION_STATUS_COLUMN_NAME,
        com.bitdubai.fermat_ccp_plugin.layer.crypto_transaction.outgoing_draft.developer.bitdubai
            .version_1.enums.TransactionState.NEW.getCode());

    // TODO: This have to be changed for the tinestamp when the network recognize the transaction

    // eze te saco la division para obtener el timestamp bien
    databaseTableRecord.setLongValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_TIMESTAMP_COLUMN_NAME,
        System.currentTimeMillis());
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_DESCRIPTION_COLUMN_NAME, notes);
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_CRYPTO_STATUS_COLUMN_NAME,
        CryptoStatus.PENDING_SUBMIT.getCode());

    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ACTOR_FROM_PUBLIC_KEY_COLUMN_NAME,
        deliveredByActorPublicKey);
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ACTOR_FROM_TYPE_COLUMN_NAME,
        deliveredByActorType.getCode());
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ACTOR_TO_PUBLIC_KEY_COLUMN_NAME,
        deliveredToActorPublicKey);
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_ACTOR_TO_TYPE_COLUMN_NAME,
        deliveredToActorType.getCode());
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_SAME_DEVICE_COLUMN_NAME,
        String.valueOf(sameDevice));
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_WALLET_REFERENCE_TYPE_COLUMN_NAME,
        referenceWallet.getCode());
    databaseTableRecord.setStringValue(
        OutgoingDraftTransactionDatabaseConstants.OUTGOING_DRAFT_RUNNING_NETWORK_TYPE,
        blockchainNetworkType.getCode());
  }