private function TripalDocService_v0_1::addEntryPointClass

3.x TripalDocService_v0_1.inc private TripalDocService_v0_1::addEntryPointClass()

Generates the EntryPoint class for the API documents.

Return value

TripalWebServiceResource

1 call to TripalDocService_v0_1::addEntryPointClass()
TripalDocService_v0_1::handleRequest in tripal_ws/includes/TripalWebService/TripalDocService_v0_1.inc

File

tripal_ws/includes/TripalWebService/TripalDocService_v0_1.inc, line 79

Class

TripalDocService_v0_1

Code

private function addEntryPointClass() {

  $service_path = $this->getServicePath();
  $details = array(
    'id' => $service_path . '#EntryPoint',
    'term' => 'vocab:EntryPoint',
    'title' => 'EntryPoint',
    'description' => 'The main entry point or homepage of the API',
    'subClassOf' => NULL,
  );

  // Add each service as a property.
  $properties = array();
  foreach ($this->services as $service_class) {
    $service = new $service_class($this->base_path);

    // Create a WebServiceResource for the hydra:Link type.
    $link = new TripalWebServiceResource($this->base_path);
    $link->setID('vocab:EntryPoint/' . $service::$type);
    $link->setType('hydra:Link');
    $link->addContextItem('domain', array(
      "@id" => "rdfs:domain",
      "@type" => "@id"
    ));
    $link->addContextItem('range', array(
      "@id" => "rdfs:range",
      "@type" => "@id"
    ));
    $link->addContextItem('readable', 'hydra:readable');
    $link->addContextItem('writeable', 'hydra:writeable');
    $link->addContextItem('required', 'hydra:required');
    $link->addContextItem('description', 'rdfs:comment');
    $link->addContextItem('label', 'rdfs:label');
    $link->addProperty('hydra:title', $service_class::$label);
    $link->addProperty('hydra:description', $service_class::$description);
    //       $link->addProperty('domain', $service_path . '#EntryPoint');
    //       $link->addProperty('range', $service_class::$label);

    $ops = array();
    $op = new TripalWebServiceResource($this->base_path);

    $op->setID('_:' . $service::$type . '_retrieve');
    $op->setType('hydra:Operation');
    $op->addContextItem('method', 'hydra:method');
    $op->addContextItem('label', 'rdfs:label');
    $op->addContextItem('description', 'rdfs:comment');
    $op->addContextItem('expects', array(
      "@id" => "hydra:expects",
      "@type" => "@id"
    ));
    $op->addContextItem('returns', array(
      "@id" => "hydra:returns",
      "@type" => "@id"
    ));
    $op->addContextItem('statusCodes', 'hydra:statusCodes');
    $op->addProperty('method', "GET");
    $op->addProperty('label', 'Retrieves the ' . $service_class::$label . ' resource.');
    $op->addProperty('description', NULL);
    $op->addProperty('expects', NULL);
    $op->addProperty('returns', 'local:EntryPoint/' . $service::$type);
    $op->addProperty('statusCodes', array());
    $ops[] = $op;
    $link->addContextItem('supportedOperation', 'hydra:supportedOperation');
    $link->addProperty('supportedOperation', $ops);

    $property = array(
      'type' => $link,
      'title' => $service_class::$label,
      'description' => $service_class::$description,
      'domain', 'vocab:EntryPoint',
      'range', $service->getServicePath(),
    );
    $properties[] = $property;
  }

  $operations = array();
  $operations['GET'] = array(
    'label' => "The APIs main entry point.",
    'description' => NULL,
    'expects' => NULL,
    'returns' => $service_path . '#EntryPoint',
    'type' => '_:entry_point_retrieve'
  );


  $this->addDocClass($details, $operations, $properties);
}