Skip to content

Commit

Permalink
Merge pull request #116 from TripalCultivate/g4.91-removeOldDesignRem…
Browse files Browse the repository at this point in the history
…nants

G4.91 Remove all deprecations
  • Loading branch information
carolyncaron authored Nov 4, 2024
2 parents 7551244 + 1461f72 commit bb0dc68
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 372 deletions.
17 changes: 17 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"ms-azuretools.vscode-docker",
"github.vscode-github-actions",
"GitHub.vscode-pull-request-github"
//"valeryanm.vscode-phpsab"
],
"settings": {
// This turns off basic PHP suggestions provided by Visual Studio Code (in lieu of Intelephense's).
Expand Down Expand Up @@ -116,6 +117,22 @@
"composer.bin": "/usr/local/bin/composer",
"tws.trimOnSave": true,
"tws.highlightTrailingWhiteSpace": true
/* PHP Sniffer & Beautifier */
/**
"phpsab.snifferEnable": true,
"phpsab.executablePathCS": "/var/www/drupal/vendor/bin/phpcs",
"phpsab.fixerEnable": true,
"phpsab.executablePathCBF": "/var/www/drupal/vendor/bin/phpcbf",
"phpsab.standard": "Drupal,DrupalPractice",
"phpsab.snifferMode": "onType",
"phpsab.debug": false,
"phpsab.fixerArguments": [
"--extensions=inc,theme,install,module,profile,php,phtml"
],
"phpsab.snifferArguments": [
"--extensions=inc,theme,install,module,profile,php,phtml"
]
*/
}
}
},
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ class TripalCultivatePhenotypesValidator extends Plugin {
*/
public $validator_name;

/**
* The scope a validator will perform a check
* ie. FILE level check, Project/Genus level check or Data Values level check.
*
* @deprecated Remove in issue #91
*
* @var string.
*/
public $validator_scope;

/**
* The type of the data this validator supports validating.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@

abstract class TripalCultivatePhenotypesValidatorBase extends PluginBase implements TripalCultivatePhenotypesValidatorInterface {

/**
* An associative array containing the needed context, which is dependant
* on the validator. For example, instead of validating each cell by default,
* a validator may need a list of indices which correspond to the columns in
* the row for which the validator should act on.
*
* Key-value pairs are set by the setter methods in ValidatorTraits.
*/
protected array $context = [];

/**
* A mapping of supported file mime-types and their supported delimiters.
*
* More specifically, the file is split based on the appropriate delimiter
* for the mime-type passed in. For example, the mime-type
* "text/tab-separated-values" maps to the tab (i.e. "\t") delimiter.
*
* By using this mapping approach we can actually support a number of different
* file types with different delimiters for the same importer while keeping
* the performance hit to a minimum. Especially as in many cases, this is a
* one-to-one mapping.
*
* @var array
*/
public static array $mime_to_delimiter_mapping = [
'text/tab-separated-values' => ["\t"],
'text/csv' => [','],
'text/plain' => ["\t", ','],
];

/**
* Get validator plugin validator_name definition annotation value.
*
Expand Down Expand Up @@ -45,37 +75,6 @@ public function checkInputTypeSupported(string $input_type) {
return FALSE;
}

/**
* An associative array containing the needed context, which is dependant
* on the validator. For example, instead of validating each cell by default,
* a validator may need a list of indices which correspond to the columns in
* the row for which the validator should act on.
*
* Key-value pairs are set by the setter methods in ValidatorTraits.
*/
protected array $context = [];

/**
* A mapping of supported file mime-types and their supported delimiters.
*
* More specifically, the file is split based on the appropriate delimiter
* for the mime-type passed in. For example, the mime-type
* "text/tab-separated-values" maps to the tab (i.e. "\t") delimiter.
*
* By using this mapping approach we can actually support a number of different
* file types with different delimiters for the same importer while keeping
* the performance hit to a minimum. Especially as in many cases, this is a
* one-to-one mapping.
*
* @var array
*/
public static array $mime_to_delimiter_mapping = [
'text/tab-separated-values' => ["\t"],
'text/csv' => [','],
'text/plain' => ["\t", ','],
];


/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -108,91 +107,6 @@ public function validateRawRow(string $raw_row) {
throw new \Exception("Method validateRawRow() from base class called for $plugin_name. If this plugin wants to support this type of validation then they need to override it.");
}

/**
* {@inheritdoc}
* @deprecated Remove in issue #91
*/
public function validate() {
$plugin_name = $this->getValidatorName();
throw new \Exception("Method validate() from base class called for $plugin_name. This method is being deprecated and should be upgraded to validateMetadata(), validateFile() or validateRow().");
}

/**
* Project name/title.
* @deprecated Remove in issue #91
*/
public $project;

/**
* Genus.
* @deprecated Remove in issue #91
*/
public $genus;

/**
* Drupal File ID Number.
* @deprecated Remove in issue #91
*/
public $file_id;

/**
* Required column headers as defined in the importer.
* @deprecated Remove in issue #91
*/
public $column_headers;

/**
* Skip flag, indicate validator not to execute validation logic and
* set the validator as upcoming or todo.
* @deprecated Remove in issue #91
*/
public $skip;

/**
* Load phenotypic data upload assets to validated.
*
* @deprecated Remove in issue #91
*
* @param $project
* String, Project name/title - chado.project: name.
* @param $genus
* String, Genus - chado.organism: genus.
* @param $file_id
* Integer, Drupal file id number.
* @param $headers
* Array, required column headers defined in the importer.
* @param $skip
* Boolean, skip flag when set to true will skip the validation
* logic and set the validator as upcoming/todo.
* Default: false - execute validation process.
*/
public function loadAssets($project, $genus, $file_id, $headers, $skip = 0) {
// Prepare assets:

// Project.
$this->project = $project;
// Genus.
$this->genus = $genus;
// File id.
$this->file_id = $file_id;
// Column Headers.
$this->column_headers = $headers;
// Skip.
$this->skip = $skip;
}

/**
* Get validator plugin validator_scope definition annotation value.
*
* @deprecated Remove in issue #91
*
* @return string
* The validator plugin scope annotation definition value.
*/
public function getValidatorScope() {
return (array_key_exists('validator_scope', $this->pluginDefinition)) ? $this->pluginDefinition['validator_scope'] : NULL;
}

/**
* {@inheritdoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ public function checkInputTypeSupported(string $input_type);
* For example, if this validator checks a specific set of form elements,
* then this array should be keyed by the form element key and the value
* matches what was provided by the user input in form_values.
* The old style keys we are deprecating are:
* @deprecated Remove in issue #91
* - title: the title of the validation (shown both when passes or fails).
* - details: string describing the failure to users with failed items embedded.
* - status: one of 'pass' or 'fail'
*/
public function validateMetadata(array $form_values);

Expand All @@ -84,11 +79,6 @@ public function validateMetadata(array $form_values);
* For example, if this validator checks the permissions of the file, then
* this array might contain the permissions the file actually had that
* did not match what was expected.
* The old style keys we are deprecating are:
* @deprecated Remove in issue #91
* - title: the title of the validation (shown both when passes or fails).
* - details: string describing the failure to users with failed items embedded.
* - status: one of 'pass' or 'fail'
*/
public function validateFile(string $filename, int $fid);

Expand All @@ -112,11 +102,6 @@ public function validateFile(string $filename, int $fid);
* if this validator checks that a number of indices have values in a
* specific list, then this array would use the index as the key and
* the value the column actually had, for each failed column.
* The old style keys we are deprecating are:
* @deprecated Remove in issue #91
* - title: the title of the validation (shown both when passes or fails).
* - details: string describing the failure to users with failed items embedded.
* - status: one of 'pass' or 'fail'
*/
public function validateRow(array $row_values);

Expand Down Expand Up @@ -173,51 +158,6 @@ public function validateRawRow(string $raw_row);
*/
public function checkIndices($row_values, $indices);

/**
* Return the scope of the validator.
*
* @deprecated Remove in issue #91
*
* @return string.
*/
public function getValidatorScope();

/**
* Load data file import assets Project title, Genus and Data File Id
* as entered in the Importer form.
*
* @deprecated Remove in issue #91
*
* @param $project
* String, Project name/title - chado.project: name.
* @param $genus
* String, Genus - chado.organism: genus.
* @param $file_id
* Integer, Drupal file id number.
* @param $headers
* Array, required column headers defined in the importer.
* @param $skip
* Boolean, skip flag when set to true will skip the validation
* logic and set the validator as upcoming/todo.
* Default: false - execute validation process.
*
* @return void.
*/
public function loadAssets($project, $genus, $file_id, $headers, $skip);

/**
* Validate items in the phenotypic data upload assets.
*
* @deprecated Remove in issue #91
*
* @return array
* An associative array with the following keys.
* - title: string, section or title of the validation as it appears in the result window.
* - status: string, pass if it passed the validation check/test, fail string otherwise and todo string if validation was not applied.
* - details: details about the offending field/value.
*/
public function validate();

/**
* Traits, method and unit may be created/inserted through
* the phenotypic data importer using the configuration allow new.
Expand All @@ -228,7 +168,7 @@ public function validate();
* validation error and will not permit creation of terms.
*/
public function getConfigAllowNew();

/**
* Split or explode a data file line/row values into an array using a delimiter.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,40 +39,4 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac
$this->alterInfo('trpcultivate_phenotypes_validators_info');
$this->setCacheBackend($cache_backend, 'tripalcultivate_phenotypes_validators');
}

/**
* Retrieve validator implementation with a specific scope.
*
* @deprecated Remove in issue #91
*
* @param string $scope
* The validator_scope you are interested in.
*
* @return string
* The id of the validator with that scope based on it's annotation.
*/
public function getValidatorIdWithScope($scope) {
$plugins = $this->getDefinitions();
$plugin_definitions = array_values($plugins);
$plugin_with_scope = [];

// Remove all plugins without scope.
foreach($plugin_definitions as $i => $plugin) {
if (!isset($plugin['validator_scope'])) {
continue;
}

array_push($plugin_with_scope, $plugin);
}

unset($plugin_definitions);
$plugin_definitions = $plugin_with_scope;

$plugin_key = array_search(
$scope,
array_column($plugin_definitions, 'validator_scope')
);

return $plugin_definitions[ $plugin_key ]['id'];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
*
* Available variables:
* - header_notes: array of headers keyed by the header name. Value is description and expected value.
* - template_file: a file name of a template file.
* - template_file: a file name of a template file.
*/
#}

{{ attach_library('trpcultivate_phenotypes/trpcultivate-phenotypes-style-importer-header') }}

<div id="tcp-header-notes">
<p>This should be a tab-separated file with the following columns:</p>

<ol id="tcp-header-notes">
{% for header,description in data.headers %}
{% for header in data.headers %}
<li>
<strong>{{header}}</strong>: {{description}}
</li>
<strong>{{header['name']}}</strong>: {{header['description']}} ({{header['type']}})
</li>
{% endfor %}
</ol>
</div>
Expand All @@ -27,4 +27,4 @@
<a href="{{data.template_file}}" target="_blank">Download a template file</a>
</div>

<br />
<br />
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Trait Name Trait Description Method Short Name Collection Method Unit Type
trait1 trait1 description method1 Collect measurements for the trait by the best method possible. unit1 Quantitative

trait2 trait2 description Collect measurements for the trait by the best method possible. unit2 Qualitative
Loading

0 comments on commit bb0dc68

Please sign in to comment.