oc_ocdm.counter_handler.filesystem_counter_handler module

class oc_ocdm.counter_handler.filesystem_counter_handler.FilesystemCounterHandler(info_dir)[source]

Bases: oc_ocdm.counter_handler.counter_handler.CounterHandler

A concrete implementation of the CounterHandler interface that persistently stores the counter values within the filesystem.

Constructor of the FilesystemCounterHandler class.

Parameters

info_dir (str) – The path to the folder that does/will contain the counter values.

Raises

ValueError – if info_dir is None or an empty string.

Return type

None

set_counter(new_value, entity_short_name, prov_short_name='', identifier=1)[source]

It allows to set the counter value of graph and provenance entities.

Parameters
  • new_value (int) – The new counter value to be set

  • entity_short_name (str) – The short name associated either to the type of the entity itself or, in case of a provenance entity, to the type of the relative graph entity.

  • prov_short_name (str) – In case of a provenance entity, the short name associated to the type of the entity itself. An empty string otherwise.

  • identifier (int) – In case of a provenance entity, the counter value that identifies the relative graph entity. The integer value ‘1’ otherwise.

Raises

ValueError – if new_value is a negative integer or identifier is less than or equal to zero.

Returns

None

Return type

None

read_counter(entity_short_name, prov_short_name='', identifier=1)[source]

It allows to read the counter value of graph and provenance entities.

Parameters
  • entity_short_name (str) – The short name associated either to the type of the entity itself or, in case of a provenance entity, to the type of the relative graph entity.

  • prov_short_name (str) – In case of a provenance entity, the short name associated to the type of the entity itself. An empty string otherwise.

  • identifier (int) – In case of a provenance entity, the counter value that identifies the relative graph entity. The integer value ‘1’ otherwise.

Raises

ValueError – if identifier is less than or equal to zero.

Returns

The requested counter value.

Return type

int

increment_counter(entity_short_name, prov_short_name='', identifier=1)[source]

It allows to increment the counter value of graph and provenance entities by one unit.

Parameters
  • entity_short_name (str) – The short name associated either to the type of the entity itself or, in case of a provenance entity, to the type of the relative graph entity.

  • prov_short_name (str) – In case of a provenance entity, the short name associated to the type of the entity itself. An empty string otherwise.

  • identifier (int) – In case of a provenance entity, the counter value that identifies the relative graph entity. The integer value ‘1’ otherwise.

Raises

ValueError – if identifier is less than or equal to zero.

Returns

The newly-updated (already incremented) counter value.

Return type

int

set_metadata_counter(new_value, entity_short_name, dataset_name)[source]

It allows to set the counter value of metadata entities.

Parameters
  • new_value (int) – The new counter value to be set

  • entity_short_name (str) – The short name associated either to the type of the entity itself.

  • dataset_name (str) – In case of a Dataset, its name. Otherwise, the name of the relative dataset.

Raises

ValueError – if new_value is a negative integer, dataset_name is None or entity_short_name is not a known metadata short name.

Returns

None

Return type

None

read_metadata_counter(entity_short_name, dataset_name)[source]

It allows to read the counter value of metadata entities.

Parameters
  • entity_short_name (str) – The short name associated either to the type of the entity itself.

  • dataset_name (str) – In case of a Dataset, its name. Otherwise, the name of the relative dataset.

Raises

ValueError – if dataset_name is None or entity_short_name is not a known metadata short name.

Returns

The requested counter value.

Return type

int

increment_metadata_counter(entity_short_name, dataset_name)[source]

It allows to increment the counter value of metadata entities by one unit.

Parameters
  • entity_short_name (str) – The short name associated either to the type of the entity itself.

  • dataset_name (str) – In case of a Dataset, its name. Otherwise, the name of the relative dataset.

Raises

ValueError – if dataset_name is None or entity_short_name is not a known metadata short name.

Returns

The newly-updated (already incremented) counter value.

Return type

int