Commit 206be0aa authored by François Agneray's avatar François Agneray
Browse files

Update for multi-instances feature done

parent e2d4e872
......@@ -6,18 +6,17 @@ list:
@echo "Useful targets:"
@echo ""
@echo " install > install php composer dependancies"
@echo " up > build php image and start anis-v3-server containers for dev only (php + mailer)"
@echo " start > start anis-v3-server containers"
@echo " restart > restart anis-v3-server containers"
@echo " stop > stop and kill running anis-v3-server containers"
@echo " logs > display anis-v3-server containers logs"
@echo " shell > shell into php anis-v3-server container"
@echo " up > build php image and start anis-server containers for dev only (php + mailer)"
@echo " start > start anis-server containers"
@echo " restart > restart anis-server containers"
@echo " stop > stop and kill running anis-server containers"
@echo " logs > display anis-server containers logs"
@echo " shell > shell into php anis-server container"
@echo " phpunit > run php unit test suite"
@echo " phpcs > run php code sniffer test suite"
@echo " init-db > generate a new metadata database (anis-v3-server containers running needed)"
@echo " remove-db > remove the metadata database"
@echo " validate-db > validate the doctrine mapping entity files (anis-v3-server containers running needed)"
@echo " add-superuser > add an Anis server superuser. Example: make email=admin@anis.fr password=admin add-superuser"
@echo " anis-init > generate a new anis admin database and a default metamodel database (anis-server containers running needed)"
@echo " dev-init > add metadata datasets for devlopment purpose"
@echo " remove-pgdata > remove the metadata database"
@echo " gen-key > generate a new encryption key that you can use to encrypt data (see anis server config file)"
@echo ""
......@@ -56,22 +55,14 @@ phpcs:
-v $(CURDIR):/project \
-w /project jakzal/phpqa phpcs --standard=PSR2 --extensions=php --colors src
init-meta-db:
@docker-compose exec php sh ./conf-dev/metamodel_init.sh
anis-init:
@docker-compose exec php sh ./conf-dev/anis_init.sh
init-db-dev:
@docker-compose exec php sh ./conf-dev/init-db-dev.sh
dev-init:
@docker-compose exec php sh ./conf-dev/dev-init.sh
remove-db:
remove-pgdata:
@docker volume rm anis-server_pgdata
validate-db:
@docker-compose exec php ./vendor/bin/doctrine orm:validate-schema
gen-key:
@docker-compose exec php php ./conf-dev/generate_encryption_key.php
add-superuser:
@[ "${email}" ] || ( echo ">> email is not set"; exit 1 )
@[ "${password}" ] || ( echo ">> password is not set"; exit 1 )
@docker-compose exec php curl -d '{"email":"${email}","password":"${password}"}' -H "Content-Type: application/json" -X POST http://localhost/metadata/superuser
\ No newline at end of file
@docker-compose exec php php ./conf-dev/generate_encryption_key.php
\ No newline at end of file
#!/bin/sh
set -e
# Create the anis admin database (only tables)
./vendor/bin/doctrine orm:schema-tool:create
curl -d '{"label":"Admin"}' -H "Content-Type: application/json" -X POST http://localhost/metadata/group
curl -d '{"label":"Default dataset family","display":10}' -H "Content-Type: application/json" -X POST http://localhost/metadata/family/dataset
curl -d '{"label":"Default criteria family","display":10}' -H "Content-Type: application/json" -X POST http://localhost/metadata/family/criteria
curl -d '{"label":"Default output family","display":10}' -H "Content-Type: application/json" -X POST http://localhost/metadata/family/output
curl -d '{"label":"Default output category","display":10,"id_output_family":1}' -H "Content-Type: application/json" -X POST http://localhost/metadata/output-category
curl -d '{"name":"search_flag","label":"Search flag"}' -H "Content-Type: application/json" -X POST http://localhost/settings/select
curl -d '{"name":"search_type","label":"Search Type"}' -H "Content-Type: application/json" -X POST http://localhost/settings/select
curl -d '{"name":"operator","label":"Operator"}' -H "Content-Type: application/json" -X POST http://localhost/settings/select
curl -d '{"name":"renderer","label":"Renderer"}' -H "Content-Type: application/json" -X POST http://localhost/settings/select
curl -d '{"name":"renderer_detail","label":"Renderer detail"}' -H "Content-Type: application/json" -X POST http://localhost/settings/select
curl -d '{"label":"ID","value":"ID","display":10,"id_settings_select":1}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"RA","value":"RA","display":20,"id_settings_select":1}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"DEC","value":"DEC","display":30,"id_settings_select":1}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Field","value":"field","display":10,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Between","value":"between","display":20,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Select","value":"select","display":30,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Select multiple","value":"select-multiple","display":40,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Datalist","value":"datalist","display":50,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Radio","value":"radio","display":60,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Checkbox","value":"checkbox","display":70,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Between date","value":"between-date","display":80,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Date","value":"date","display":90,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Time","value":"time","display":100,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Date time","value":"date-time","display":110,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"JSON","value":"json","display":120,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"=","value":"eq","display":10,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"≠","value":"neq","display":20,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"between","value":"bw","display":30,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":">","value":"gt","display":40,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":">=","value":"gte","display":50,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"<","value":"lt","display":60,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"<=","value":"lte","display":70,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"like","value":"lk","display":80,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"not like","value":"nlk","display":90,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"in","value":"in","display":100,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"not in","value":"nin","display":110,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"null","value":"nl","display":120,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"not null","value":"nnl","display":130,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"json","value":"js","display":140,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Image","value":"img","display":10,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Thumbnail","value":"thumbnail","display":20,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Link","value":"link","display":30,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Button","value":"btn","display":40,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Detail link","value":"detail-link","display":50,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Detail button","value":"detail-btn","display":60,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Download","value":"download","display":70,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"JSON","value":"json","display":80,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
curl -d '{"label":"Image","value":"img","display":10,"id_settings_select":5}' -H "Content-Type: application/json" -X POST http://localhost/settings/option
# Add the first anis superuser
curl -d '{"email":"admin@anis.fr","password":"admin"}' -H "Content-Type: application/json" -X POST http://localhost/login/register
curl -d '{"adminsi":true,"superuser":true,"activated":true}' -H "Content-Type: application/json" -X PUT http://localhost/admin/user/admin@anis.fr
# Add settings for admin inteface
curl -d '{"name":"search_flag","label":"Search flag"}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/select
curl -d '{"name":"search_type","label":"Search Type"}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/select
curl -d '{"name":"operator","label":"Operator"}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/select
curl -d '{"name":"renderer","label":"Renderer"}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/select
curl -d '{"name":"renderer_detail","label":"Renderer detail"}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/select
curl -d '{"label":"ID","value":"ID","display":10,"id_settings_select":1}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"RA","value":"RA","display":20,"id_settings_select":1}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"DEC","value":"DEC","display":30,"id_settings_select":1}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Field","value":"field","display":10,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Between","value":"between","display":20,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Select","value":"select","display":30,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Select multiple","value":"select-multiple","display":40,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Datalist","value":"datalist","display":50,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Radio","value":"radio","display":60,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Checkbox","value":"checkbox","display":70,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Between date","value":"between-date","display":80,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Date","value":"date","display":90,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Time","value":"time","display":100,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Date time","value":"date-time","display":110,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"JSON","value":"json","display":120,"id_settings_select":2}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"=","value":"eq","display":10,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"≠","value":"neq","display":20,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"between","value":"bw","display":30,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":">","value":"gt","display":40,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":">=","value":"gte","display":50,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"<","value":"lt","display":60,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"<=","value":"lte","display":70,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"like","value":"lk","display":80,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"not like","value":"nlk","display":90,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"in","value":"in","display":100,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"not in","value":"nin","display":110,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"null","value":"nl","display":120,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"not null","value":"nnl","display":130,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"json","value":"js","display":140,"id_settings_select":3}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Image","value":"img","display":10,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Thumbnail","value":"thumbnail","display":20,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Link","value":"link","display":30,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Button","value":"btn","display":40,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Detail link","value":"detail-link","display":50,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Detail button","value":"detail-btn","display":60,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Download","value":"download","display":70,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"JSON","value":"json","display":80,"id_settings_select":4}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
curl -d '{"label":"Image","value":"img","display":10,"id_settings_select":5}' -H "Content-Type: application/json" -X POST http://localhost/admin/settings/option
# Generate default metamodel
curl -d '{"name":"default","label":"Default instance","dev_mode":true,"driver":"pdo_pgsql","path":"","host":"db","port":5432,"login":"anis","password":"anis","path_proxy":"/tmp/doctrine_proxy","dbname":"anis_metamodel"}' -H "Content-Type: application/json" -X POST http://localhost/admin/instance
curl -X GET http://localhost/admin/instance/default/create-database
# Add admin group to the default metamodel
curl -d '{"label":"Admin"}' -H "Content-Type: application/json" -X POST http://localhost/metadata/default/group
# Add all default families
curl -d '{"label":"Default dataset family","display":10}' -H "Content-Type: application/json" -X POST http://localhost/metadata/default/family/dataset
curl -d '{"label":"Default criteria family","display":10}' -H "Content-Type: application/json" -X POST http://localhost/metadata/default/family/criteria
curl -d '{"label":"Default output family","display":10}' -H "Content-Type: application/json" -X POST http://localhost/metadata/default/family/output
curl -d '{"label":"Default output category","display":10,"id_output_family":1}' -H "Content-Type: application/json" -X POST http://localhost/metadata/default/output-category
\ No newline at end of file
curl -d '{"email":"admin@anis.fr","password":"admin"}' -H "Content-Type: application/json" -X POST http://localhost/metadata/superuser
#!/bin/sh
set -e
curl -d '{"label":"Test","dbname":"anis_test","dbtype":"pdo_pgsql","dbhost":"db","dbport":5432,"dblogin":"anis","dbpassword":"anis"}' -H "Content-Type: application/json" -X POST http://localhost/metadata/database
curl -d '{"name":"anis_project","label":"Anis Project Test","description":"Project used for testing","link":"http://project.com","manager":"M. Durand","id_database":1}' -H "Content-Type: application/json" -X POST http://localhost/metadata/project
curl -d '{"label":"Test","dbname":"anis_test","dbtype":"pdo_pgsql","dbhost":"db","dbport":5432,"dblogin":"anis","dbpassword":"anis"}' -H "Content-Type: application/json" -X POST http://localhost/metadata/default/database
curl -d '{"name":"anis_project","label":"Anis Project Test","description":"Project used for testing","link":"http://project.com","manager":"M. Durand","id_database":1}' -H "Content-Type: application/json" -X POST http://localhost/metadata/default/project
curl -d '{"name":"obs_cat","table_ref":"obs_cat","label":"ObsCat dataset","description":"ObsCat","display":"10","count":"10000","vo":false,"data_path":"/mnt/mount","project_name":"anis_project","id_dataset_family":1}' -H "Content-Type: application/json" -X POST http://localhost/metadata/dataset
curl -d '{"name":"observations","table_ref":"observations_info","label":"Observations dataset","description":"Observations","display":"20","count":"177454","vo":false,"data_path":"/mnt/mount","project_name":"anis_project","id_dataset_family":1}' -H "Content-Type: application/json" -X POST http://localhost/metadata/dataset
curl -d '{"name":"obs_cat","table_ref":"obs_cat","label":"ObsCat dataset","description":"ObsCat","display":"10","count":"10000","vo":false,"data_path":"/mnt/mount","project_name":"anis_project","id_dataset_family":1}' -H "Content-Type: application/json" -X POST http://localhost/metadata/default/dataset
curl -d '{"name":"observations","table_ref":"observations_info","label":"Observations dataset","description":"Observations","display":"20","count":"177454","vo":false,"data_path":"/mnt/mount","project_name":"anis_project","id_dataset_family":1}' -H "Content-Type: application/json" -X POST http://localhost/metadata/default/dataset
......@@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Action\Instance;
namespace App\Action\Admin;
use Psr\Log\LoggerInterface;
use Doctrine\ORM\EntityManagerInterface;
......@@ -50,19 +50,31 @@ final class InstanceAction
}
if ($request->isGet()) {
$newResponse = $response->withJson($select);
$newResponse = $response->withJson($instance);
}
if ($request->isPut()) {
$parsedBody = $request->getParsedBody();
// Vérification des champs vides
foreach (array('name', 'label', 'path_proxy', 'dev_mode', 'driver', 'path', 'host', 'port', 'dbname', 'login', 'password') as $a) {
if ($this->isEmptyField($a, $parsedBody)) {
$fields = array(
'label',
'path_proxy',
'dev_mode',
'driver',
'path',
'host',
'port',
'dbname',
'login',
'password'
);
foreach ($fields as $f) {
if ($this->isEmptyField($f, $parsedBody)) {
return $this->dispatchHttpError(
$response,
'Invalid request',
'Param ' . $a . ' needed to add a new instance'
'Param ' . $f . ' needed to edit an instance'
);
}
}
......@@ -83,7 +95,6 @@ final class InstanceAction
private function editInstance(Instance $instance, array $parsedBody): void
{
$instance->setName($parsedBody['name']);
$instance->setLabel($parsedBody['label']);
$instance->setPathProxy($parsedBody['path_proxy']);
$instance->setDevMode($parsedBody['dev_mode']);
......
......@@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Action\Instance;
namespace App\Action\Admin;
use Psr\Log\LoggerInterface;
use Doctrine\ORM\EntityManagerInterface;
......@@ -48,12 +48,25 @@ final class InstanceListAction
$parsedBody = $request->getParsedBody();
// Vérification des champs vides
foreach (array('name', 'label', 'path_proxy', 'dev_mode', 'driver', 'path', 'host', 'port', 'dbname', 'login', 'password') as $a) {
if ($this->isEmptyField($a, $parsedBody)) {
$fields = array(
'name',
'label',
'path_proxy',
'dev_mode',
'driver',
'path',
'host',
'port',
'dbname',
'login',
'password'
);
foreach ($fields as $f) {
if ($this->isEmptyField($f, $parsedBody)) {
return $this->dispatchHttpError(
$response,
'Invalid request',
'Param ' . $a . ' needed to add a new instance'
'Param ' . $f . ' needed to add a new instance'
);
}
}
......
<?php declare(strict_types=1);
/*
* This file is part of ANIS SERVER API.
*
* (c) François Agneray <francois.agneray@lam.fr>
* (c) Chrystel Moreau <chrystel.moreau@lam.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Action\Admin;
use Psr\Log\LoggerInterface;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\SchemaTool;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use App\Utils\ActionTrait;
use App\Utils\MetaEntityManagerFactory;
final class MetamodelAction
{
use ActionTrait;
private $logger;
private $aem;
private $memf;
public function __construct(LoggerInterface $logger, EntityManagerInterface $aem, MetaEntityManagerFactory $memf)
{
$this->logger = $logger;
$this->aem = $aem;
$this->memf = $memf;
}
public function __invoke(Request $request, Response $response, array $args): Response
{
$this->logger->info('Metamodel action dispatched');
if ($request->isOptions()) {
return $response->withHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
}
$instance = $this->aem->find('App\Entity\Admin\Instance', $args['name']);
if (is_null($instance)) {
return $this->dispatchHttpError(
$response,
'Invalid request',
'Instance with name ' . $args['name'] . ' is not found'
)->withStatus(404);
}
if (!in_array($args['action'], array('create-database', 'update-database', 'delete-database'))) {
return $this->dispatchHttpError(
$response,
'Invalid request',
'Action ' . $args['action'] . ' is not allowed!'
)->withStatus(400);
}
$this->memf->createMetaEntityManager($args['name']);
$instanceEntityManager = $this->memf->getMetaEntityManager();
$schemaTool = new SchemaTool($instanceEntityManager);
$classes = $instanceEntityManager->getMetadataFactory()->getAllMetadata();
switch ($args['action']) {
case 'create-database':
$schemaTool->createSchema($classes);
$message = 'Database metamodel has been created!';
break;
case 'update-database':
$schemaTool->updateSchema($classes);
$message = 'Database metamodel has been updated!';
break;
case 'delete-database':
$schemaTool->dropSchema($classes);
$message = 'Database metamodel has been removed!';
break;
}
return $response->withJson(array('message' => $message));
}
}
......@@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Action\Settings;
namespace App\Action\Admin;
use Psr\Log\LoggerInterface;
use Doctrine\ORM\EntityManagerInterface;
......@@ -16,19 +16,19 @@ use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use App\Utils\ActionTrait;
use App\Entity\SettingsOption;
use App\Entity\Admin\SettingsOption;
final class OptionAction
{
use ActionTrait;
private $logger;
private $em;
private $aem;
public function __construct(LoggerInterface $logger, EntityManagerInterface $em)
public function __construct(LoggerInterface $logger, EntityManagerInterface $aem)
{
$this->logger = $logger;
$this->em = $em;
$this->aem = $aem;
}
public function __invoke(Request $request, Response $response, array $args): Response
......@@ -39,7 +39,7 @@ final class OptionAction
return $response->withHeader('Access-Control-Allow-Methods', 'GET, PUT, DELETE, OPTIONS');
}
$option = $this->em->find('App\Entity\SettingsOption', $args['id']);
$option = $this->aem->find('App\Entity\Admin\SettingsOption', $args['id']);
if (is_null($option)) {
return $this->dispatchHttpError(
......@@ -73,8 +73,8 @@ final class OptionAction
if ($request->isDelete()) {
$id = $option->getId();
$this->em->remove($option);
$this->em->flush();
$this->aem->remove($option);
$this->aem->flush();
$newResponse = $response->withJson(array('message' => 'Settings option with id ' . $id . ' is removed!'));
}
......@@ -86,6 +86,6 @@ final class OptionAction
$option->setLabel($parsedBody['label']);
$option->setValue($parsedBody['value']);
$option->setDisplay($parsedBody['display']);
$this->em->flush();
$this->aem->flush();
}
}
......@@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Action\Settings;
namespace App\Action\Admin;
use Psr\Log\LoggerInterface;
use Doctrine\ORM\EntityManagerInterface;
......@@ -16,20 +16,20 @@ use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use App\Utils\ActionTrait;
use App\Entity\SettingsSelect;
use App\Entity\SettingsOption;
use App\Entity\Admin\SettingsSelect;
use App\Entity\Admin\SettingsOption;
final class OptionListAction
{
use ActionTrait;
private $logger;
private $em;
private $aem;
public function __construct(LoggerInterface $logger, EntityManagerInterface $em)
public function __construct(LoggerInterface $logger, EntityManagerInterface $aem)
{
$this->logger = $logger;
$this->em = $em;
$this->aem = $aem;
}
public function __invoke(Request $request, Response $response, array $args): Response
......@@ -41,7 +41,7 @@ final class OptionListAction
}
if ($request->isGet()) {
$options = $this->em->getRepository('App\Entity\SettingsOption')->findAll();
$options = $this->aem->getRepository('App\Entity\Admin\SettingsOption')->findAll();
$newResponse = $response->withJson($options);
}
......@@ -59,7 +59,7 @@ final class OptionListAction
}
}
$select = $this->em->find('App\Entity\SettingsSelect', $parsedBody['id_settings_select']);
$select = $this->aem->find('App\Entity\Admin\SettingsSelect', $parsedBody['id_settings_select']);
if (is_null($select)) {
return $this->dispatchHttpError(
$response,
......@@ -82,8 +82,8 @@ final class OptionListAction
$option->setValue($parsedBody['value']);
$option->setDisplay($parsedBody['display']);
$this->em->persist($option);
$this->em->flush();
$this->aem->persist($option);
$this->aem->flush();
return $option;
}
......
......@@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Action\Settings;
namespace App\Action\Admin;
use Psr\Log\LoggerInterface;
use Doctrine\ORM\EntityManagerInterface;
......@@ -16,19 +16,19 @@ use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use App\Utils\ActionTrait;
use App\Entity\SettingsSelect;
use App\Entity\Admin\SettingsSelect;
final class SelectAction
{
use ActionTrait;
private $logger;
private $em;
private $aem;
public function __construct(LoggerInterface $logger, EntityManagerInterface $em)
public function __construct(LoggerInterface $logger, EntityManagerInterface $aem)
{
$this->logger = $logger;
$this->em = $em;
$this->aem = $aem;
}
public function __invoke(Request $request, Response $response, array $args): Response
......@@ -39,7 +39,7 @@ final class SelectAction
return $response->withHeader('Access-Control-Allow-Methods', 'GET, PUT, DELETE, OPTIONS');
}
$select = $this->em->find('App\Entity\SettingsSelect', $args['id']);
$select = $this->aem->find('App\Entity\Admin\SettingsSelect', $args['id']);
if (is_null($select)) {
return $this->dispatchHttpError(
......@@ -73,8 +73,8 @@ final class SelectAction
if ($request->isDelete()) {
$id = $select->getId();
$this->em->remove($select);
$this->em->flush();
$this->aem->remove($select);
$this->aem->flush();
$newResponse = $response->withJson(array('message' => 'Settings select with id ' . $id . ' is removed!'));
}
......@@ -85,6 +85,6 @@ final class SelectAction
{
$select->setName($parsedBody['name']);
$select->setLabel($parsedBody['label']);
$this->em->flush();
$this->aem->flush();
}
}
......@@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Action\Settings;
namespace App\Action\Admin;
use Psr\Log\LoggerInterface;
use Doctrine\ORM\EntityManagerInterface;
......@@ -16,19 +16,19 @@ use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use App\Utils\ActionTrait;
use App\Entity\SettingsSelect;
use App\Entity\Admin\SettingsSelect;
final class SelectListAction
{
use ActionTrait;
private $logger;
private $em;
private $aem;
public function __construct(LoggerInterface $logger, EntityManagerInterface $em)
public function __construct(LoggerInterface $logger, EntityManagerInterface $aem)
{
$this->logger = $logger;
$this->em = $em;
$this->aem = $aem;
}
public function __invoke(Request $request, Response $response, array $args): Response
......@@ -40,7 +40,7 @@ final class SelectListAction
}
if ($request->isGet()) {
$selects = $this->em->getRepository('App\Entity\SettingsSelect')->findAll();
$selects = $this->aem->getRepository('App\Entity\Admin\SettingsSelect')->findAll();
$newResponse = $response->withJson($selects);
}
......@@ -71,8 +71,8 @@ final class SelectListAction
$select->setName($parsedBody['name']);
$select->setLabel($parsedBody['label']);
$this->em->persist($select);
$this->em->flush();
$this->