Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function describeTable($table, $refresh = true)
 {
     $name = is_array($table) ? ArrayUtils::get($table, 'name') : $table;
     try {
         $result = $this->parent->callGuzzle('GET', 'sobjects/' . $table . '/describe');
         $out = $result;
         $out['access'] = $this->getPermissions($name);
         return $out;
     } catch (\Exception $ex) {
         throw new InternalServerErrorException("Failed to get table properties for table '{$name}'.\n{$ex->getMessage()}");
     }
 }
 public function testDropTable()
 {
     $request = new TestServiceRequest(Verbs::DELETE);
     $rs = $this->service->handleRequest($request, Schema::RESOURCE_NAME . '/' . static::TABLE_NAME);
     $request->setMethod(Verbs::GET);
     $rs = $this->service->handleRequest($request, Schema::RESOURCE_NAME . '/' . static::TABLE_NAME);
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 protected function commitTransaction($extras = null)
 {
     if (empty($this->batchRecords) && empty($this->batchIds)) {
         if (isset($this->transaction)) {
             $this->transaction->commit();
         }
         return null;
     }
     $fields = ArrayUtils::get($extras, ApiOptions::FIELDS);
     $idFields = ArrayUtils::get($extras, 'id_fields');
     $out = [];
     $action = $this->getAction();
     if (!empty($this->batchRecords)) {
         if (1 == count($this->tableIdsInfo)) {
             // records are used to retrieve extras
             // ids array are now more like records
             $fields = $this->buildFieldList($this->transactionTable, $fields, $idFields);
             $idList = "('" . implode("','", $this->batchRecords) . "')";
             $query = 'SELECT ' . $fields . ' FROM ' . $this->transactionTable . ' WHERE ' . $idFields . ' IN ' . $idList;
             $result = $this->parent->callGuzzle('GET', 'query', ['q' => $query]);
             $out = ArrayUtils::get($result, 'records', []);
             if (empty($out)) {
                 throw new NotFoundException('No records were found using the given identifiers.');
             }
         } else {
             $out = $this->retrieveRecords($this->transactionTable, $this->batchRecords, $extras);
         }
         $this->batchRecords = [];
     } elseif (!empty($this->batchIds)) {
         switch ($action) {
             case Verbs::PUT:
             case Verbs::MERGE:
             case Verbs::PATCH:
                 break;
             case Verbs::DELETE:
                 break;
             case Verbs::GET:
                 $fields = $this->buildFieldList($this->transactionTable, $fields, $idFields);
                 $idList = "('" . implode("','", $this->batchIds) . "')";
                 $query = 'SELECT ' . $fields . ' FROM ' . $this->transactionTable . ' WHERE ' . $idFields . ' IN ' . $idList;
                 $result = $this->parent->callGuzzle('GET', 'query', ['q' => $query]);
                 $out = ArrayUtils::get($result, 'records', []);
                 if (empty($out)) {
                     throw new NotFoundException('No records were found using the given identifiers.');
                 }
                 break;
             default:
                 break;
         }
         if (empty($out)) {
             $out = $this->batchIds;
         }
         $this->batchIds = [];
     }
     return $out;
 }