Open Data Catalog v
Drupal\metastore\Service Class Reference
Inheritance diagram for Drupal\metastore\Service:

Public Member Functions

 __construct (SchemaRetriever $schemaRetriever, DataFactory $factory, ValidMetadataFactory $validMetadataFactory)
 
 getSchemas ()
 
 getSchema ($identifier)
 
 count (string $schema_id, bool $unpublished=FALSE)
 
 getIdentifiers (string $schema_id, ?int $start=NULL, ?int $length=NULL, $unpublished=FALSE)
 
 getAll (string $schema_id, ?int $start=NULL, ?int $length=NULL, $unpublished=FALSE)
 
 isPublished (string $schema_id, string $identifier)
 
 get (string $schema_id, string $identifier)
 
 getValidMetadataFactory ()
 
 post ($schema_id, RootedJsonData $data)
 
 publish (string $schema_id, string $identifier)
 
 archive (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'
 

Protected Member Functions

 getStorage (string $schema_id)
 

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

◆ archive()

Drupal\metastore\Service::archive ( 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 archived, false otherwise.

Definition at line 313 of file Service.php.

◆ count()

Drupal\metastore\Service::count ( string  $schema_id,
bool  $unpublished = FALSE 
)

Count objects of the given schema ID.

Parameters
string$schema_idThe schema ID to be counted.
bool$unpublishedWhether to include unpublished items.
Returns
int Object count.

Definition at line 127 of file Service.php.

◆ 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 415 of file Service.php.

◆ get()

Drupal\metastore\Service::get ( string  $schema_id,
string  $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 240 of file Service.php.

◆ getAll()

Drupal\metastore\Service::getAll ( string  $schema_id,
?int  $start = NULL,
?int  $length = NULL,
  $unpublished = FALSE 
)

Get all items, with optional pagination and status filters.

Parameters
string$schema_idSchema ID.
int | null$startStart offset. Null for no range.
int | null$lengthNumber of items to retrieve.
bool$unpublishedWhether to include unpublished items. Should default to false.
Returns
array Array of RootedJsonData objects.

Definition at line 167 of file Service.php.

◆ getCatalog()

Drupal\metastore\Service::getCatalog ( )

Assembles the data catalog object.

Returns
object The catalog object

Definition at line 429 of file Service.php.

◆ getIdentifiers()

Drupal\metastore\Service::getIdentifiers ( string  $schema_id,
?int  $start = NULL,
?int  $length = NULL,
  $unpublished = FALSE 
)

Get range of object UUIDs of the given schema ID.

If no start or length is specified, all dataset UUIDs will be returned.

Parameters
string$schema_idThe schema ID to be counted.
int | null$startSchema object offset or null for all.
int | null$lengthNumber of objects to fetch or null for all.
bool$unpublishedWhether to include unpublished items.
Returns
string[] Range of object UUIDs of the given schema_id.

Definition at line 148 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.

◆ getStorage()

Drupal\metastore\Service::getStorage ( string  $schema_id)
protected

Get storage.

Parameters
string$schema_idThe {schema_id} slug from the HTTP request.
Returns
\Drupal\metastore\Storage\MetastoreStorageInterface Entity storage.

Definition at line 109 of file Service.php.

◆ getValidMetadataFactory()

Drupal\metastore\Service::getValidMetadataFactory ( )

Get ValidMetadataFactory.

Returns
\Drupal\metastore\ValidMetadataFactory rootedJsonDataWrapper.

Definition at line 254 of file Service.php.

◆ isPublished()

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

Determine whether the given metastore item is published.

Parameters
string$schema_idThe metastore schema in question.
string$identifierThe ID of the metastore item in question.
Returns
bool Whether the given metastore item is published.

Definition at line 225 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 554 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 383 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 269 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 294 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 334 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 523 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 451 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.