Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\Validators\FingerprintUniquenessValidator Class Reference

Validates the uniqueness of changing parts in a ChangeOpFingerprintResult across entities in store. More...

+ Inheritance diagram for Wikibase\Repo\Validators\FingerprintUniquenessValidator:
+ Collaboration diagram for Wikibase\Repo\Validators\FingerprintUniquenessValidator:

Public Member Functions

 __construct (TermsCollisionDetector $termsCollisionDetector, TermLookup $termLookup)
 
 setOptions (array $options)
 
 validate ( $value)
 

Private Member Functions

 validateProperty (ChangeOpFingerprintResult $fingerprintChangeOpResult)
 
 validateItem (ChangeOpFingerprintResult $fingerprintChangeOpResult)
 
 getChangedLabelsPerLanguage (ChangeOpFingerprintResult $changeOpsResult)
 
 getChangedLabelsAndDescriptionsPerLanguage (ChangeOpFingerprintResult $changeOpsResult)
 
 collectNewAndOldTerms (ChangeOpFingerprintResult $changeOpsResult)
 
 generateLabelDescriptionPairs (array $newTerms, array $oldTerms, EntityId $entityId)
 In order to check label and decsription uniqueness, this validator need to know both the label and the description in a language, where one or both of them are going to change.
 
 getEntityTerm (EntityId $entityId, $lang, $termType)
 
 collisionToError ( $code, $collidingEntityId, $lang, $label)
 

Private Attributes

 $termsCollisionDetector
 
 $termLookup
 

Detailed Description

Validates the uniqueness of changing parts in a ChangeOpFingerprintResult across entities in store.

Business logic in here is as following: Given an item Q1 in language L When L label or description of Q1 are being modified Then there should be no other Q2 in the store with L label and/or description Items are unique on their label and description in a language. This means, given a language, no two items should have same label and same description in that language.

Properties are unique on their label alone in a language. This means, given a language, no two properties should have same label in that language.

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Validators\FingerprintUniquenessValidator::__construct ( TermsCollisionDetector  $termsCollisionDetector,
TermLookup  $termLookup 
)

Member Function Documentation

◆ collectNewAndOldTerms()

Wikibase\Repo\Validators\FingerprintUniquenessValidator::collectNewAndOldTerms ( ChangeOpFingerprintResult  $changeOpsResult)
private
Returns
array containing two entries [ 0 => new terms, 1 => old terms ] new terms will contain new term values per language per term type that appear in $changeOpsResult as changing the entity, while old terms will contain old term values per language per term type that appear in $changeOpsResult as not changing the entity

old terms might not contain complementary data to those entries in new terms, as that depends on whether the ChangeOpsResult contains results of things that are not being changed or not (which in turn depends on ChangeOpFingerprint that produced the ChangeOpFingerprintResult). Example scenario is an api call that is sending to server only the terms that need to change. Counter example scenario is a frontend (e.g. termbox) sending back to server all terms, whether changed or not.

◆ collisionToError()

Wikibase\Repo\Validators\FingerprintUniquenessValidator::collisionToError (   $code,
  $collidingEntityId,
  $lang,
  $label 
)
private

◆ generateLabelDescriptionPairs()

Wikibase\Repo\Validators\FingerprintUniquenessValidator::generateLabelDescriptionPairs ( array  $newTerms,
array  $oldTerms,
EntityId  $entityId 
)
private

In order to check label and decsription uniqueness, this validator need to know both the label and the description in a language, where one or both of them are going to change.

This method purpose is take those terms that are about to change ($newTerms) and make sure to yield pairs of label and description, filling in those missing labels or descriptions from either $oldTerms or from term store directly.

Returns
Generator yielding entries of the shape [ language code => [ 'label' => label text, 'descripition' => description text ] ]

◆ getChangedLabelsAndDescriptionsPerLanguage()

Wikibase\Repo\Validators\FingerprintUniquenessValidator::getChangedLabelsAndDescriptionsPerLanguage ( ChangeOpFingerprintResult  $changeOpsResult)
private
Returns
Generator yielding entries of the shape [ language code => [ 'label' => label text, 'descripition' => description text ] ]

◆ getChangedLabelsPerLanguage()

Wikibase\Repo\Validators\FingerprintUniquenessValidator::getChangedLabelsPerLanguage ( ChangeOpFingerprintResult  $changeOpsResult)
private
Returns
Generator yield entries of the shape [ language code => label text ]

◆ getEntityTerm()

Wikibase\Repo\Validators\FingerprintUniquenessValidator::getEntityTerm ( EntityId  $entityId,
  $lang,
  $termType 
)
private

◆ setOptions()

Wikibase\Repo\Validators\FingerprintUniquenessValidator::setOptions ( array  $options)

◆ validate()

Wikibase\Repo\Validators\FingerprintUniquenessValidator::validate (   $value)

◆ validateItem()

Wikibase\Repo\Validators\FingerprintUniquenessValidator::validateItem ( ChangeOpFingerprintResult  $fingerprintChangeOpResult)
private

◆ validateProperty()

Wikibase\Repo\Validators\FingerprintUniquenessValidator::validateProperty ( ChangeOpFingerprintResult  $fingerprintChangeOpResult)
private

Member Data Documentation

◆ $termLookup

Wikibase\Repo\Validators\FingerprintUniquenessValidator::$termLookup
private

◆ $termsCollisionDetector

Wikibase\Repo\Validators\FingerprintUniquenessValidator::$termsCollisionDetector
private

The documentation for this class was generated from the following file: