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

Database admin + route variable instance

parent 19817746
......@@ -3,20 +3,20 @@
require 'vendor/autoload.php';
$settings = require './src/settings.php';
$metadata = $settings['settings']['metadata'];
$adminDb = $settings['settings']['admin_db'];
$c = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array('src/Entity'), $metadata['dev_mode']);
$c->setProxyDir(getcwd() . '/' . $metadata['path_proxy']);
if ($metadata['dev_mode']) {
$c->setAutoGenerateProxyClasses(true);
$c = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array('src/Entity/Admin'), $adminDb['dev_mode']);
$c->setProxyDir(getcwd() . '/' . $adminDb['path_proxy']);
if ($adminDb['dev_mode']) {
$c->setAutoGenerateProxyClasses(true);
} else {
$c->setAutoGenerateProxyClasses(false);
$c->setAutoGenerateProxyClasses(false);
}
$em = \Doctrine\ORM\EntityManager::create($metadata['connection_options'], $c);
$em = \Doctrine\ORM\EntityManager::create($adminDb['connection_options'], $c);
$helpers = new Symfony\Component\Console\Helper\HelperSet(array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));
return \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($em);
......@@ -3,6 +3,7 @@ set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER anis LOGIN PASSWORD 'anis';
CREATE DATABASE anis_admin;
CREATE DATABASE anis_metamodel;
CREATE DATABASE anis_test;
GRANT ALL PRIVILEGES ON DATABASE anis_metamodel TO anis;
......
......@@ -12,7 +12,7 @@ services:
METADATA_DB_DRIVER: "pdo_pgsql"
METADATA_DB_HOST: "db"
METADATA_DB_PORT: 5432
METADATA_DB_DBNAME: "anis_metamodel"
METADATA_DB_DBNAME: "anis_admin"
METADATA_DB_USER: "anis"
METADATA_DB_PASSWORD: "anis"
MAILER_HOST: "mailer"
......
......@@ -22,7 +22,7 @@ use App\Entity\Database;
/**
* Route: /metadata/project/{name}
* {name}: Project name
*
*
* This action is used to manage one project
*
* @author François Agneray <francois.agneray@lam.fr>
......
<?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\Entity\Admin;
/**
* @Entity
* @Table(name="instance")
*/
class Instance implements \JsonSerializable
{
/**
* @var string
*
* @Id
* @Column(type="string", nullable=false)
*/
protected $name;
/**
* @var string
*
* @Column(type="string", nullable=false)
*/
protected $label;
/**
* @var string
*
* @Column(type="string", nullable=false)
*/
protected $dbname;
/**
* @var string
*
* @Column(type="string", nullable=false)
*/
protected $type;
/**
* @var string
*
* @Column(type="string", nullable=false)
*/
protected $host;
/**
* @var integer
*
* @Column(type="integer", nullable=true)
*/
protected $port;
/**
* @var string
*
* @Column(type="string", nullable=false)
*/
protected $login;
/**
* @var string
*
* @Column(type="string", nullable=false)
*/
protected $password;
public function __construct(string $name)
{
$this->name = $name;
}
/**
* Getter property name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Getter property label
*
* @return string
*/
public function getLabel()
{
return $this->label;
}
/**
* Setter property label
*
* @param string $label
*/
public function setLabel($label)
{
$this->label = $label;
}
/**
* Getter property dbname
*
* @return string
*/
public function getDbName()
{
return $this->dbname;
}
/**
* Setter property dbname
*
* @param string $dbname
*/
public function setDbName($dbname)
{
$this->dbname = $dbname;
}
public function getType()
{
return $this->type;
}
public function setType($type)
{
$this->type = $type;
}
public function getHost()
{
return $this->host;
}
public function setHost($host)
{
$this->host = $host;
}
public function getPort()
{
return $this->port;
}
public function setPort($port)
{
$this->port = $port;
}
public function getLogin()
{
return $this->login;
}
public function setLogin($login)
{
$this->login = $login;
}
public function getPassword()
{
return $this->password;
}
public function setPassword($password)
{
$this->password = $password;
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'label' => $this->getLabel(),
'dbname' => $this->getDbName(),
'dbtype' => $this->getType(),
'dbhost' => $this->getHost(),
'dbport' => $this->getPort(),
'dblogin' => $this->getLogin(),
'dbpassword' => $this->getPassword()
];
}
}
......@@ -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\Entity;
namespace App\Entity\Admin;
/**
* @Entity
......
......@@ -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\Entity;
namespace App\Entity\Admin;
/**
* @Entity
......
<?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\Entity\Admin;
/**
* @Entity
* @Table(name="anis_user")
*/
class User implements \JsonSerializable
{
/**
* @var string
*
* @Id
* @Column(type="string", nullable=false)
*/
protected $email;
/**
* @var string
*
* @Column(type="string", nullable=false)
*/
protected $password;
/**
* @var string
*
* @Column(type="string", name="activation_key", nullable=false)
*/
protected $activationKey;
/**
* @var bool
*
* @Column(type="boolean", nullable=false)
*/
protected $activated;
/**
* @var bool
*
* @Column(type="boolean", nullable=false)
*/
protected $adminsi;
/**
* @var bool
*
* @Column(type="boolean", nullable=false)
*/
protected $superuser;
public function __construct($email)
{
return $this->email = $email;
}
public function getEmail()
{
return $this->email;
}
public function getPassword()
{
return $this->password;
}
public function setPassword($password)
{
$this->password = $password;
}
public function getActivationKey()
{
return $this->activationKey;
}
public function setActivationKey($activationKey)
{
$this->activationKey = $activationKey;
}
public function getActivated()
{
return $this->activated;
}
public function setActivated($activated)
{
$this->activated = $activated;
}
public function getAdminsi()
{
return $this->adminsi;
}
public function setAdminsi($adminsi)
{
$this->adminsi = $adminsi;
}
public function getSuperuser()
{
return $this->superuser;
}
public function setSuperuser($superuser)
{
$this->superuser = $superuser;
}
public function jsonSerialize()
{
return [
'email' => $this->getEmail(),
'activated' => $this->getActivated(),
'adminsi' => $this->getAdminsi(),
'superuser' => $this->getSuperuser()
];
}
}
......@@ -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\Entity;
namespace App\Entity\Metamodel;
use Doctrine\Common\Collections\ArrayCollection;
......
......@@ -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\Entity;
namespace App\Entity\Metamodel;
/**
* @Entity
......
......@@ -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\Entity;
namespace App\Entity\Metamodel;
/**
* @Entity
......@@ -76,7 +76,7 @@ class Database implements \JsonSerializable
/**
* Getter property id
*
*
* @return int
*/
public function getId()
......@@ -86,7 +86,7 @@ class Database implements \JsonSerializable
/**
* Getter property label
*
*
* @return string
*/
public function getLabel()
......@@ -96,7 +96,7 @@ class Database implements \JsonSerializable
/**
* Setter property label
*
*
* @param string $label
*/
public function setLabel($label)
......@@ -106,7 +106,7 @@ class Database implements \JsonSerializable
/**
* Getter property dbname
*
*
* @return string
*/
public function getDbName()
......@@ -116,7 +116,7 @@ class Database implements \JsonSerializable
/**
* Setter property dbname
*
*
* @param string $dbname
*/
public function setDbName($dbname)
......
......@@ -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\Entity;
namespace App\Entity\Metamodel;
use Doctrine\Common\Collections\ArrayCollection;
......
......@@ -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\Entity;
namespace App\Entity\Metamodel;
use Doctrine\Common\Collections\ArrayCollection;
......
......@@ -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\Entity;
namespace App\Entity\Metamodel;
/**
* @Entity
......
......@@ -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\Entity;
namespace App\Entity\Metamodel;
/**
* @Entity
......
......@@ -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\Entity;
namespace App\Entity\Metamodel;
/**
* @Entity
......
......@@ -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\Entity;
namespace App\Entity\Metamodel;
/**
* @Entity
......
......@@ -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\Entity;
namespace App\Entity\Metamodel;
/**
* @Entity
......
......@@ -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\Entity;
namespace App\Entity\Metamodel;
/**
* @Entity
......
......@@ -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\Entity;
namespace App\Entity\Metamodel;
/**
* @Entity
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment