Skip to content

Commit

Permalink
Merge changes to main (#189)
Browse files Browse the repository at this point in the history
* 045Q/01 (Basisklassifikation) is not displayed at the Sacherschließung page #178

* Don't show \!\! when footer missing

* Add configuration parameter `include`

* Turn on/off the git connection feature by configuration #179

* Add configuration parameter : check if the key is existing in the config

* When checking the list of Solr fields exported into a file, we should consider not only the existence, but if it is empty or not.

* Issues status graphic does not work with zero issues #183: fix the issue

* Issues status graphic does not work with zero issues #183: fix the issue

* Add configuration parameter include: check if the key is existing in the config (#181) (#184)

* 045Q/01 (Basisklassifikation) is not displayed at the Sacherschließung page #178

* Don't show \!\! when footer missing

* Add configuration parameter `include`

* Turn on/off the git connection feature by configuration #179

* Add configuration parameter : check if the key is existing in the config

---------

Co-authored-by: Jakob Voss <[email protected]>

* Remove multitenant key (#162) (#188)

---------

Co-authored-by: Jakob Voss <[email protected]>
  • Loading branch information
pkiraly and nichtich authored May 27, 2024
1 parent 6b1c6ef commit e8cd30e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ Additional configuration parameters are listed below. Data type and version numb
- `id` (string) the machine name of the data directory. By default, it comes from the URL as the path of the application
(qa-catalogue). With this parameter the administrator can overwrite the path. Note: this parameter was called `db`
previously. For compatibility reason we will support `db` as well for some time.
- `multitenant`: (bool, v0.8.0) flag to denote if the site is in multi-tenant mode, i.e. it hosts the evaluation of multiple
catalogues. If it is set you can specify general and catalogue-specific settings, e.g. `versions=false` is a
general setting, while `versions[loc]=false` is a library specific settings, which override the previous one.
- `extractGitVersion` (bool, v0.8.0): a flag that enables to display the current git commit hash on the bottom of
the user interface. Default is `true`.

Expand Down Expand Up @@ -165,6 +162,11 @@ The following parameters can be set either for all catalogues (`parameter=value`

The parameter `include` can be used to include another configuration file and merge its parameters into the base configuration. Recursive inclusion is not supported and include is ignored if the referenced file does not exist.

Multiple catalogues can be configured in one file. To do so, add an individual
catalogue `id` in brackets after a configuration field to override its default
value. For instance if `versions=false` is a general setting, while
`versions[loc]=false` is a library specific setting.

Example:

```
Expand Down
32 changes: 8 additions & 24 deletions classes/Utils/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Configuration {
private array $configuration;
private string $id;
private ?string $catalogue;
private bool $multitenant = false;
private bool $displayNetwork;
private bool $displayShacl;
private bool $versioning;
Expand Down Expand Up @@ -62,11 +61,7 @@ private function __construct(array $configuration) {
// global
$this->configuration = $configuration;
$this->id = $configuration["id"]; // REQUIRED
$this->multitenant = $configuration['multitenant'] ?? false;

// multi-tennant
// $this->displayNetwork = isset($configuration['display-network']) && (int) $configuration['display-network'] == 1;
// $this->displayShacl = isset($configuration['display-shacl']) && (int) $configuration['display-shacl'] == 1;
$this->dir = $this->getValue('dir', 'output');
$this->catalogue = $this->getValue('catalogue', $this->id);
$this->defaultTab = $this->getValue('default-tab', 'issues');
Expand Down Expand Up @@ -95,11 +90,15 @@ private function __construct(array $configuration) {
}

private function getValue($key, $defaultValue) {
if ($this->multitenant) {
$value = $this->getMultitenantValue($key, $defaultValue);
} else {
$value = $this->configuration[$key] ?? $defaultValue;
if (isset($this->configuration[$key])) {
if (isset($this->configuration[$key][$this->id])) {
$value = $this->configuration[$key];
} elseif (is_scalar($this->configuration[$key])) {
$value = $this->configuration[$key][$this->id];
}
}
$valu ??= $defaultValue;

// expected boolean
if (is_bool($defaultValue)) {
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
Expand All @@ -110,17 +109,6 @@ private function getValue($key, $defaultValue) {
return $value;
}

private function getMultitenantValue($key, $defaultValue) {
// error_log($key . ': ' . gettype($this->{$key}));
if (isset($this->configuration[$key]) && isset($this->configuration[$key][$this->id])) {
$value = $this->configuration[$key][$this->id];
} else if (isset($this->configuration[$key]) && is_scalar($this->configuration[$key])) {
$value = $this->configuration[$key];
} else {
$value = $defaultValue;
}
return $value;
}

public function getId(): string {
return $this->id;
Expand All @@ -130,10 +118,6 @@ public function getCatalogue(): ?string {
return $this->catalogue;
}

public function isMultitenant(): bool {
return $this->multitenant;
}

public function getDir(): ?string {
return $this->dir;
}
Expand Down
2 changes: 0 additions & 2 deletions tests/files/example.cnf
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
id=abc

multitenant=true

dir=this-will-be-overridden
dir[abc]=new-value

0 comments on commit e8cd30e

Please sign in to comment.