Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntitiesManager #15357

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 3rdparty
Submodule 3rdparty updated 1 files
+1 −0 composer.json
276 changes: 276 additions & 0 deletions core/Migrations/Version17000Date20190417091242.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
<?php
declare(strict_types=1);


/**
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <[email protected]>
* @copyright 2019, Maxence Lange <[email protected]>
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/


namespace OC\Core\Migrations;


use Closure;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;


/**
*
*/
class Version17000Date20190417091242 extends SimpleMigrationStep {


/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options
): ISchemaWrapper {

/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();


/**
* entities
*
* - id string - a unique uuid to ident the entity
* - type string - type of the entity: no_member, unique, group, admin_group
* - owner_id string - id from 'entitied_accounts' for the owner
* - visibility small int - visible to all, visible to owner only, visible to members
* - access small int - free, invite only, request needed
* - name string - name of the entity
* - creation datetime
*/
$table = $schema->createTable('entities');
$table->addColumn(
'id', Type::STRING,
[
'notnull' => true,
'length' => 11,
]
);
$table->addColumn(
'type', Type::STRING,
[
'notnull' => true,
'length' => 15
]
);
$table->addColumn(
'owner_id', Type::STRING,
[
'notnull' => true,
'length' => 11,
]
);
$table->addColumn(
'visibility', Type::SMALLINT,
[
'notnull' => true,
'length' => 1,
]
);
$table->addColumn(
'access', Type::SMALLINT,
[
'notnull' => true,
'length' => 1,
]
);
$table->addColumn(
'name', Type::STRING,
[
'notnull' => true,
'length' => 63
]
);
$table->addColumn(
'creation', Type::DATETIME,
[
'notnull' => true
]
);
$table->setPrimaryKey(['id']);


/**
* entities_accounts
*
* - id string - a unique uuid to ident the account
* - type string - local_user, mail_address, guest_user
* - account string - account/user_id
* - creation datetime
*/
$table = $schema->createTable('entities_accounts');
$table->addColumn(
'id', Type::STRING,
[
'notnull' => true,
'length' => 11,
]
);
$table->addColumn(
'type', Type::STRING,
[
'notnull' => true,
'length' => 15
]
);
$table->addColumn(
'account', Type::STRING,
[
'notnull' => true,
'length' => 127
]
);
$table->addColumn(
'delete_on', Type::INTEGER,
[
'notnull' => true,
'length' => 12
]
);
$table->addColumn(
'creation', Type::DATETIME,
[
'notnull' => true
]
);
$table->setPrimaryKey(['id']);


/**
* entities_members
*
* - id string - a unique uuid
* - entity_id string - id from 'entities'
* - account_id string - id from 'entities_accounts'
* - slave_entity_id string - id from 'entities'
* - status string - invited, requesting, member
* - level small int - 1=member, 4=moderator, 8=admin
* - creation datetime
*/
$table = $schema->createTable('entities_members');
$table->addColumn(
'id', Type::STRING,
[
'notnull' => true,
'length' => 11,
]
);
$table->addColumn(
'entity_id', Type::STRING,
[
'notnull' => true,
'length' => 11
]
);
$table->addColumn(
'account_id', Type::STRING,
[
'notnull' => false,
'length' => 11
]
);
$table->addColumn(
'slave_entity_id', Type::STRING,
[
'notnull' => false,
'length' => 11
]
);
$table->addColumn(
'status', Type::STRING,
[
'notnull' => true,
'length' => 15
]
);
$table->addColumn(
'level', Type::SMALLINT,
[
'notnull' => true,
'length' => 1,
'unsigned' => true
]
);
$table->addColumn(
'creation', Type::DATETIME,
[
'notnull' => true
]
);
$table->setPrimaryKey(['id']);


/**
* entities_types
*
* - id int - incremented and primary key, nothing more
* - type string - string that define the type
* - interface string - type of the type(sic)
* - class string - class to be called to manage the service
*/
$table = $schema->createTable('entities_types');
$table->addColumn(
'id', Type::INTEGER,
[
'autoincrement' => true,
'notnull' => true,
'length' => 3,
'unsigned' => true,
]
);
$table->addColumn(
'type', Type::STRING,
[
'notnull' => true,
'length' => 15
]
);
$table->addColumn(
'interface', Type::STRING,
[
'notnull' => true,
'length' => 31
]
);
$table->addColumn(
'class', Type::STRING,
[
'notnull' => true,
'length' => 127
]
);
$table->setPrimaryKey(['id']);


return $schema;
}
}
18 changes: 18 additions & 0 deletions core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
*
*/


use OCP\AppFramework\QueryException;


/** @var $application Symfony\Component\Console\Application */
$application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand());
$application->add(new OC\Core\Command\Status);
Expand Down Expand Up @@ -166,6 +170,20 @@
$application->add(new OC\Core\Command\Security\ListCertificates(\OC::$server->getCertificateManager(null), \OC::$server->getL10N('core')));
$application->add(new OC\Core\Command\Security\ImportCertificate(\OC::$server->getCertificateManager(null)));
$application->add(new OC\Core\Command\Security\RemoveCertificate(\OC::$server->getCertificateManager(null)));

try {
$application->add(new OC\Entities\Command\Create(OC::$server->getEntitiesManager(), OC::$server->getEntitiesHelper()));
$application->add(new OC\Entities\Command\Delete(OC::$server->getEntitiesManager(), OC::$server->getEntitiesHelper()));
$application->add(new OC\Entities\Command\Details(OC::$server->getEntitiesManager()));
$application->add(new OC\Entities\Command\Install(OC::$server->getEntitiesHelper()));
$application->add(new OC\Entities\Command\Migration(OC::$server->getEntitiesManager(), OC::$server->getEntitiesMigrationHelper()));
$application->add(new OC\Entities\Command\Modify(OC::$server->getEntitiesManager(), OC::$server->getEntitiesHelper()));
$application->add(new OC\Entities\Command\Search(OC::$server->getEntitiesHelper(), OC::$server->getEntitiesManager()));
$application->add(new OC\Entities\Command\Session(OC::$server->getEntitiesManager(), OC::$server->getEntitiesHelper()));
} catch (QueryException $e) {
OC::$server->getLogger()->log(3, 'QueryException while loading Entities/Commands: ' . $e->getMessage());
}

} else {
$application->add(new OC\Core\Command\Maintenance\Install(\OC::$server->getSystemConfig()));
}
Loading