Open Data Catalog v2.0.0
Drupal\metastore\Service Class Reference
Inheritance diagram for Drupal\metastore\Service:

Public Member Functions

 __construct (SchemaRetriever $schemaRetriever, DataFactory $factory, ValidMetadataFactory $validMetadataFactory)
 
 getSchemas ()
 
 getSchema ($identifier)
 
 getAll ($schema_id)
 
 getRange (string $schema_id, int $start, int $length)
 
 get ($schema_id, $identifier)
 
 getResources ($schema_id, $identifier)
 
 getValidMetadataFactory ()
 
 post ($schema_id, RootedJsonData $data)
 
 publish (string $schema_id, string $identifier)
 
 put ($schema_id, $identifier, RootedJsonData $data)
 
 patch ($schema_id, $identifier, $json_data)
 
 delete ($schema_id, $identifier)
 
 getCatalog ()
 
 swapReferences (RootedJsonData $object)
 

Static Public Member Functions

static create (ContainerInterface $container)
 
static removeReferences (RootedJsonData $object, $prefix="%")
 
static metadataHash ($data)
 

Public Attributes

const EVENT_DATA_GET = 'dkan_metastore_data_get'
 
const EVENT_DATA_GET_ALL = 'dkan_metastore_data_get_all'
 

Detailed Description

The metastore service.

Definition at line 21 of file Service.php.

Constructor & Destructor Documentation

◆ __construct()

Drupal\metastore\Service::__construct ( SchemaRetriever  $schemaRetriever,
DataFactory  $factory,
ValidMetadataFactory  $validMetadataFactory 
)

Constructor.

Definition at line 72 of file Service.php.

Member Function Documentation

◆ create()

static Drupal\metastore\Service::create ( ContainerInterface  $container)
static

Inherited.

Definition at line 61 of file Service.php.

◆ delete()

Drupal\metastore\Service::delete (   $schema_id,
  $identifier 
)

Implements DELETE method.

Parameters
string$schema_idThe {schema_id} slug from the HTTP request.
string$identifierIdentifier.
Returns
string Identifier.

Definition at line 391 of file Service.php.

◆ get()

Drupal\metastore\Service::get (   $schema_id,
  $identifier 
)

Implements GET method.

Parameters
string$schema_idThe {schema_id} slug from the HTTP request.
string$identifierIdentifier.
Returns
\RootedData\RootedJsonData The json data.

Definition at line 212 of file Service.php.

◆ getAll()

Drupal\metastore\Service::getAll (   $schema_id)

Get all.

Parameters
string$schema_idThe {schema_id} slug from the HTTP request.
Returns
array All objects of the given schema_id.

Definition at line 125 of file Service.php.

◆ getCatalog()

Drupal\metastore\Service::getCatalog ( )

Assembles the data catalog object.

Returns
object The catalog object

Definition at line 405 of file Service.php.

◆ getRange()

Drupal\metastore\Service::getRange ( string  $schema_id,
int  $start,
int  $length 
)

Get a subset of metastore items according to a range.

Parameters
string$schema_idSchema ID.
int$startStart offset.
int$lengthNumber of items to retrieve.
Returns
array Array of RootedJsonData objects.

Definition at line 154 of file Service.php.

◆ getResources()

Drupal\metastore\Service::getResources (   $schema_id,
  $identifier 
)

GET all resources associated with a dataset.

Parameters
string$schema_idThe {schema_id} slug from the HTTP request.
string$identifierIdentifier.
Returns
array An array of resources.
Todo:
Make this aware of revisions and moderation states.

Definition at line 233 of file Service.php.

◆ getSchema()

Drupal\metastore\Service::getSchema (   $identifier)

Get schema.

Definition at line 93 of file Service.php.

◆ getSchemas()

Drupal\metastore\Service::getSchemas ( )

Get schemas.

Definition at line 81 of file Service.php.

◆ getValidMetadataFactory()

Drupal\metastore\Service::getValidMetadataFactory ( )

Get ValidMetadataFactory.

Returns
\Drupal\metastore\ValidMetadataFactory rootedJsonDataWrapper.

Definition at line 249 of file Service.php.

◆ metadataHash()

static Drupal\metastore\Service::metadataHash (   $data)
static

Get the md5 hash for a metadata item.

Parameters
\RootedData\RootedJsonData | object | string$dataMetadata. Can be a RootedJsonData object, a stdObject or JSON string.
Returns
string An md5 hash of the normalized metadata.
Todo:
This should probably be somewhere else.

Definition at line 527 of file Service.php.

◆ patch()

Drupal\metastore\Service::patch (   $schema_id,
  $identifier,
  $json_data 
)

Implements PATCH method.

Parameters
string$schema_idThe {schema_id} slug from the HTTP request.
string$identifierIdentifier.
mixed$json_dataJson payload.
Returns
\Symfony\Component\HttpFoundation\JsonResponse The json response.

Definition at line 359 of file Service.php.

◆ post()

Drupal\metastore\Service::post (   $schema_id,
RootedJsonData  $data 
)

Implements POST method.

Parameters
string$schema_idThe {schema_id} slug from the HTTP request.
\RootedData\RootedJsonData$dataJson payload.
Returns
string The identifier.

Definition at line 264 of file Service.php.

◆ publish()

Drupal\metastore\Service::publish ( string  $schema_id,
string  $identifier 
)

Publish an item's update by making its latest revision its default one.

Parameters
string$schema_idThe {schema_id} slug from the HTTP request.
string$identifierIdentifier.
Returns
bool True if the dataset is successfully published, false otherwise.

Definition at line 289 of file Service.php.

◆ put()

Drupal\metastore\Service::put (   $schema_id,
  $identifier,
RootedJsonData  $data 
)

Implements PUT method.

Parameters
string$schema_idThe {schema_id} slug from the HTTP request.
string$identifierIdentifier.
\RootedData\RootedJsonData$dataJson payload.
Returns
array ["identifier" => string, "new" => boolean].

Definition at line 310 of file Service.php.

◆ removeReferences()

static Drupal\metastore\Service::removeReferences ( RootedJsonData  $object,
  $prefix = "%" 
)
static

Remove references from metadata JSON.

Parameters
\RootedData\RootedJsonData$objectMetadata JSON object.
string$prefixProperty prefix.
Returns
\RootedData\RootedJsonData The metadata without any reference artifacts.
Todo:
Probably remove the prefix param and just always use "%Ref".

Definition at line 499 of file Service.php.

◆ swapReferences()

Drupal\metastore\Service::swapReferences ( RootedJsonData  $object)

Insert full references with identifiers into metadata fields.

Parameters
\RootedData\RootedJsonData$objectThe valid metastore item.
Returns
\RootedData\RootedJsonData Swapped reference object. RootedJsonData for consistency, but will have no defined schema (swapping will break validation).
Exceptions

Definition at line 427 of file Service.php.

Member Data Documentation

◆ EVENT_DATA_GET

const Drupal\metastore\Service::EVENT_DATA_GET = 'dkan_metastore_data_get'

Definition at line 25 of file Service.php.

◆ EVENT_DATA_GET_ALL

const Drupal\metastore\Service::EVENT_DATA_GET_ALL = 'dkan_metastore_data_get_all'

Definition at line 26 of file Service.php.