コード例 #1
0
  /**
   * Create a new row into the data base
   *
   * @param nodeProfile
   * @throws CantInsertRecordDataBaseException
   */
  private void insertNodesCatalogTransactionsPendingForPropagation(NodeProfile nodeProfile)
      throws CantInsertRecordDataBaseException {

    /*
     * Create the NodesCatalog
     */
    NodesCatalogTransactionsPendingForPropagation transaction =
        new NodesCatalogTransactionsPendingForPropagation();
    transaction.setIp(nodeProfile.getIp());
    transaction.setDefaultPort(nodeProfile.getDefaultPort());
    transaction.setIdentityPublicKey(nodeProfile.getIdentityPublicKey());
    transaction.setName(nodeProfile.getName());
    transaction.setTransactionType(NodesCatalogTransaction.ADD_TRANSACTION_TYPE);
    transaction.setHashId(transaction.getHashId());

    // Validate if location are available
    if (nodeProfile.getLocation() != null) {
      transaction.setLastLatitude(nodeProfile.getLocation().getLatitude());
      transaction.setLastLongitude(nodeProfile.getLocation().getLongitude());
    }

    /*
     * Save into the data base
     */
    getDaoFactory().getNodesCatalogTransactionsPendingForPropagationDao().create(transaction);
  }
コード例 #2
0
  /**
   * Create a new row into the data base
   *
   * @param nodeProfile
   * @throws CantInsertRecordDataBaseException
   */
  private void insertNodesCatalog(NodeProfile nodeProfile)
      throws CantInsertRecordDataBaseException {

    /*
     * Create the NodesCatalog
     */
    NodesCatalog nodeCatalog = new NodesCatalog();
    nodeCatalog.setIp(nodeProfile.getIp());
    nodeCatalog.setDefaultPort(nodeProfile.getDefaultPort());
    nodeCatalog.setIdentityPublicKey(nodeProfile.getIdentityPublicKey());
    nodeCatalog.setName(nodeProfile.getName());
    nodeCatalog.setOfflineCounter(0);

    // Validate if location are available
    if (nodeProfile.getLocation() != null) {
      nodeCatalog.setLastLatitude(nodeProfile.getLocation().getLatitude());
      nodeCatalog.setLastLongitude(nodeProfile.getLocation().getLongitude());
    }

    /*
     * Save into the data base
     */
    getDaoFactory().getNodesCatalogDao().create(nodeCatalog);
  }