Generates the necessary tables to store information.

@throws Exception
423406
@Override
	public void createResource() throws Exception {
		cluster = builder.getCluster();
		session = cluster.connect();

		session.execute(String.format("CREATE KEYSPACE IF NOT EXISTS %s with replication={'class':'SimpleStrategy', 'replication_factor':1};", keySpace));
		session.execute(String.format("CREATE TABLE IF NOT EXISTS %s.%s (sink_id text, sub_id int, checkpoint_id bigint, PRIMARY KEY (sink_id, sub_id));", keySpace, table));

		try {
			session.close();
		} catch (Exception e) {
			LOG.error("Error while closing session.", e);
		}
		try {
			cluster.close();
		} catch (Exception e) {
			LOG.error("Error while closing cluster.", e);
		}
	}
977183
protected void setUp() throws SQLException {
        Connection connection = getConnection();
        try {
            if (!isSetUp(connection)) {
                Statement stmt = connection.createStatement();
                stmt.execute(Query.CREATE_TABLE_RECORDS);
                stmt.execute(Query.CREATE_TABLE_FILEHASHES);
                stmt.execute(Query.CREATE_TABLE_META);
                stmt.execute(Query.CREATE_TABLE_CVES);
                stmt.close();
            }
        } finally {
            connection.close();
        }
    }
688691
@Override
    public List<InputRecord> generate() throws Exception {
        List<InputRecord> result = new ArrayList<InputRecord>();
        InputRecord testRecord = (InputRecord) this.getInput().clone();
        this.validate();
        // Value is set explicitly
        result.add(testRecord);
        result.add(nonCurrentValue(this.getInput()));
        return result;
    }
104420
public function GenerateDaoClasses() {
        $tableList = $this->app()->dal()->getDalInstance()->GetListOfTablesInDatabase();
        if ($tableList > 0) {
            foreach ($tableList as $table) {
                $tableName = $table[0];
                $tableColumnNames = $this->app()->dal()->getDalInstance()->GetTableColumnNames($tableName);
                $tableColumnMetadata = $this->app()->dal()->getDalInstance()->GetTableColumnsMeta($tableName, $tableColumnNames);
                $dao = new \Puzzlout\Framework\Dal\Generator\DaoClassGenerator($tableName);
                $dao->BuildClassHeader($tableName);
                $dao->BuildClassBody($tableColumnMetadata);
                $dao->ClassEnd();
            }
        } else {
            throw new \Exception("No tables in database!", 0, null);
        }
    }
851844
protected function generateLayout()
    {
        if ($this->user === null) {
            throw new Exception('User is not set.');
        }
        
        $request = $this->framework->getRequest();
        
        $accessLevelSelectorItems = $this->accessLevelHelper->transformAccessLevels(
            $this->accessLevelManager->getAccessLevels(),
            $request->getSession()->getUser()
        );
        
        $rawPermissionsForUuid = $this->accessControlManager->getPermissionsRawForUuid($this->user->getUuid());
        if ($rawPermissionsForUuid === false) {
            $rawPermissionsForUuid = array();
        }
        
        $page = new Page(
            array(
                new Form('edit-user', $request->getFullRoute(), 'post', array(
                    new ErrorBox(
                        'edit-user-errors'
                    ),
                    new Tabs(
                        array(
                            new Tab(
                                array(
                                    new Row(
                                        array(
                                            new Column(array(
                                                new Group(
                                                    'required-data',
                                                    $this->translate('Required data', '\\Zepi\\Web\\AccessControl'),
                                                    array(
                                                        new Text(
                                                            'username',
                                                            $this->translate('Username', '\\Zepi\\Web\\AccessControl'),
                                                            true,
                                                            $this->user->getName(),
                                                            $this->translate('The username must be unique. Only one user can use an username.', '\\Zepi\\Web\\AccessControl')
                                                        ),
                                                        new Password(
                                                            'password',
                                                            $this->translate('Password', '\\Zepi\\Web\\AccessControl'),
                                                            $this->user->isNew()
                                                        ),
                                                        new Password(
                                                            'password-confirmed',
                                                            $this->translate('Confirm password', '\\Zepi\\Web\\AccessControl'),
                                                            $this->user->isNew()
                                                        ),
                                                    ),
                                                    1
                                                )
                                            ), array('col-md-6')),
                                            new Column(array(
                                                new Group(
                                                    'optional-data',
                                                    $this->translate('Optional data', '\\Zepi\\Web\\AccessControl'),
                                                    array(
                                                        new Text(
                                                            'email',
                                                            $this->translate('Email address', '\\Zepi\\Web\\AccessControl'),
                                                            false,
                                                            $this->user->getMetaData('email')
                                                        ),
                                                        new Text(
                                                            'location',
                                                            $this->translate('Location', '\\Zepi\\Web\\AccessControl'),
                                                            false,
                                                            $this->user->getMetaData('location')
                                                        ),
                                                        new Text(
                                                            'website',
                                                            $this->translate('Website', '\\Zepi\\Web\\AccessControl'),
                                                            false,
                                                            $this->user->getMetaData('website')
                                                        ),
                                                        new Text(
                                                            'twitter',
                                                            $this->translate('Twitter', '\\Zepi\\Web\\AccessControl'),
                                                            false,
                                                            $this->user->getMetaData('twitter')
                                                        ),
                                                        new Textarea(
                                                            'biography',
                                                            $this->translate('Biography', '\\Zepi\\Web\\AccessControl'),
                                                            false,
                                                            $this->user->getMetaData('biography')
                                                        )
                                                    ),
                                                    2
                                                )
                                            ), array('col-md-6')),
                                        )
                                    ),
                                ),
                                array(),
                                'user-tab',
                                $this->translate('User informations', '\\Zepi\\Web\\AccessControl')
                            ),
                            new Tab(
                                array(
                                    new Selector(
                                        'access-levels',
                                        $this->translate('Access Level Selector', '\\Zepi\\Web\\AccessControl'),
                                        false,
                                        $rawPermissionsForUuid,
                                        $accessLevelSelectorItems,
                                        $this->translate('Available Access Levels', '\\Zepi\\Web\\AccessControl'),
                                        $this->translate('Granted Access Levels', '\\Zepi\\Web\\AccessControl'),
                                        '\\Zepi\\Web\\AccessControl\\Templates\\Form\\Snippet\\AccessLevel'
                                    ),
                                ),
                                array(),
                                'access-tab',
                                $this->translate('Permissions', '\\Zepi\\Web\\AccessControl')
                            )
                        )
                    ),
                    new Row(
                        array(
                            new Column(array(
                                new ButtonGroup(
                                    'buttons-left',
                                    array(
                                        new Button(
                                            'back',
                                            $this->translate('Back', '\\Zepi\\Web\\AccessControl'),
                                            array('btn-default'),
                                            '',
                                            'a',
                                            $request->getFullRoute('/administration/users/')
                                        )
                                    ),
                                    1000,
                                    array('text-left')
                                )
                            ), array('col-md-4')),
                            new Column(array(
                                new ButtonGroup(
                                    'buttons',
                                    array(
                                        new Submit(
                                            'submit',
                                            $this->translate('Save', '\\Zepi\\Web\\AccessControl'),
                                            array('btn-large', 'btn-primary'),
                                            'mdi mdi-save'
                                        )
                                    ),
                                    1000
                                )
                            ), array('col-md-4'))
                        )
                    )
                ))
            )
        );
        
        return $page;
    }
577379
public static void generate(Elements elementUtils, Filer filer, SQLiteDatabaseSchema schema) throws Exception {
		BindDaoBuilder visitor = new BindDaoBuilder(elementUtils, filer);

		for (SQLiteDaoDefinition item : schema.getCollection()) {
			item.accept(visitor);
		}
	}
1157785
public function generate()
    {
        if (!$this->iKnowWhatIAmDoing) {
            throw new \Exception('You don\'t know what you\'re doing!');
        }

        $this->cleanUp();

        $schema = $this->getSchema();

        echo "Interfaces generation...\r\n";
        $this->generateInterfaces();

        echo "Class generation...\r\n";
        $this->generateClasses($schema);

        if ($this->backwardCompatibility) {
            $this->php7ClassNames = false;
            $this->generateClasses($schema);
            $this->php7ClassNames = true;
        }
    }
770474
protected function prepare()
        {
            if (!Core::getDBlink() instanceof \PDO) {
                throw new Exception('Connection not up, can\'t prepare the statement');
            }

            $this->statement = Core::getDBlink()->prepare($this->query->getSql());
        }
1190680
public void createTables( boolean makeIndexes ) throws Exception {
        database.executeInsertUpdateDeleteSql("DROP TABLE IF EXISTS " + TABLE_TILES);
        database.executeInsertUpdateDeleteSql("DROP TABLE IF EXISTS " + TABLE_METADATA);
        database.executeInsertUpdateDeleteSql(CREATE_TILES);
        database.executeInsertUpdateDeleteSql(CREATE_METADATA);
        if (makeIndexes) {
            createIndexes();
        }
    }
1140138
public function create()
        {
            $sql = $this->generateCreateSql();
            $query = new RawQuery($sql);
            try {
                $this->drop();
                return Statement::getPreparedStatement($query)->execute();
            } catch (\Exception $e) {
                throw new Exception('Error creating table ' . $this->getB2DBName() . ': ' . $e->getMessage(), $sql);
            }
        }
1032254
private function createTable()
    {
        $sql = "CREATE TABLE `" . $this->schemaName . "` (";

        $definitions = [];

        foreach ($this->columns as $columnName => $column) {
            // The column might be using a more generic type for it's storage.
            $storageColumns = $column->createStorageColumns();

            foreach ($storageColumns as $storageColumn) {
                // And if so that column will be a generic column type - we need to upgrade it.
                $storageColumn = $storageColumn->getRepositorySpecificColumn("MySql");
                $definitions[] = $storageColumn->getDefinition();
            }
        }

        foreach ($this->indexes as $indexName => $index) {
            $indexDefinition = $index->getDefinition();
            if ($indexDefinition) {
                $definitions[] = $indexDefinition;
            }
        }

        $sql .= implode(",", $definitions);
        $sql .= "
			)";

        /** @var MySql $repos */
        $repos = Repository::getDefaultRepositoryClassName();
        $repos::executeStatement($sql);
    }
1256844
private void prepareDatabase() throws ClassNotFoundException, SQLException, UnknownPoiCategoryException {
        Class.forName("org.sqlite.JDBC");
        this.conn = DriverManager.getConnection("jdbc:sqlite:" + this.configuration.getOutputFile().getAbsolutePath());
        this.conn.setAutoCommit(false);

        Statement stmt = this.conn.createStatement();

        // Create tables
        stmt.execute(DbConstants.DROP_WAYNODES_STATEMENT);
        stmt.execute(DbConstants.DROP_NODES_STATEMENT);
        stmt.execute(DbConstants.DROP_METADATA_STATEMENT);
        stmt.execute(DbConstants.DROP_INDEX_STATEMENT);
        stmt.execute(DbConstants.DROP_CATEGORY_MAP_STATEMENT);
        stmt.execute(DbConstants.DROP_DATA_STATEMENT);
        stmt.execute(DbConstants.DROP_CATEGORIES_STATEMENT);
        stmt.execute(DbConstants.CREATE_CATEGORIES_STATEMENT);
        stmt.execute(DbConstants.CREATE_DATA_STATEMENT);
        stmt.execute(DbConstants.CREATE_CATEGORY_MAP_STATEMENT);
        stmt.execute(DbConstants.CREATE_INDEX_STATEMENT);
        stmt.execute(DbConstants.CREATE_METADATA_STATEMENT);
        stmt.execute(DbConstants.CREATE_NODES_STATEMENT);
        stmt.execute(DbConstants.CREATE_WAYNODES_STATEMENT);

        this.pStmtCatMap = this.conn.prepareStatement(DbConstants.INSERT_CATEGORY_MAP_STATEMENT);
        this.pStmtData = this.conn.prepareStatement(DbConstants.INSERT_DATA_STATEMENT);
        this.pStmtIndex = this.conn.prepareStatement(DbConstants.INSERT_INDEX_STATEMENT);

        this.pStmtNodesC = this.conn.prepareStatement(DbConstants.INSERT_NODES_STATEMENT);
        this.pStmtNodesR = this.conn.prepareStatement(DbConstants.FIND_NODES_STATEMENT);
        this.pStmtWayNodesR = this.conn.prepareStatement(DbConstants.FIND_WAYNODES_BY_ID_STATEMENT);

        // Insert categories
        PreparedStatement pStmt = this.conn.prepareStatement(DbConstants.INSERT_CATEGORIES_STATEMENT);
        PoiCategory root = this.categoryManager.getRootCategory();
        pStmt.setLong(1, root.getID());
        pStmt.setString(2, root.getTitle());
        pStmt.setNull(3, 0);
        pStmt.addBatch();

        Stack<PoiCategory> children = new Stack<>();
        children.push(root);
        while (!children.isEmpty()) {
            for (PoiCategory c : children.pop().getChildren()) {
                pStmt.setLong(1, c.getID());
                pStmt.setString(2, c.getTitle());
                pStmt.setInt(3, c.getParent().getID());
                pStmt.addBatch();
                children.push(c);
            }
        }
        pStmt.executeBatch();
        this.conn.commit();
    }
12995
protected void createTable(){
        sqlManager.executeUpdate(
                new StringSqlResource(String.format("CREATE TABLE %s (VERSION NUMERIC NOT NULL)", tableName)));

        sqlManager.executeUpdate(
                new StringSqlResource(String.format("INSERT INTO %s (0))", tableName)));
    }
451532
public function setupDatabaseTables()
    {
        $logger = $this->getLogger();
        $database = $this->getDatabase();

        $databaseHandle = $database->getDatabaseConnection();
        $tableDefinition = $database->getTableDefinition();

        $tables = array_keys($tableDefinition);
        foreach ($tables as $tableName) {
            $logger->writeln('<info>Table "' . $tableName . '"</info>');

            $statement = $databaseHandle->prepare('SHOW TABLES LIKE :table');
            $statement->bindParam(':table', $tableName, \PDO::PARAM_STR);
            $statement->execute();

            if ($statement->rowCount() == 1) {
                $logger->writeln('<info>=> Exists. Skip it</info>');
                continue;
            }

            // Table does not exists. Try to create it
            $createTableResult = $databaseHandle->query($tableDefinition[$tableName]);

            if ($createTableResult === false) {
                $databaseError = $databaseHandle->errorInfo();
                $message = 'Table "%s" could not be created. %s (%s)';
                $message = sprintf($message, $tableName, $databaseError[2], $databaseError[1]);
                throw new \Exception($message, 1398100879);

            } else {
                $logger->writeln('<info>Not exists. Created</info>');
            }
        }

        return true;
    }
518986
protected function generateLayout()
    {
        if ($this->group === null) {
            throw new Exception('Group is not set.');
        }
        
        $request = $this->framework->getRequest();
        
        $accessLevelSelectorItems = $this->accessLevelHelper->transformAccessLevels(
            $this->accessLevelManager->getAccessLevels(),
            $request->getSession()->getUser(),
            $this->group
        );
        
        $rawPermissionsForUuid = $this->accessControlManager->getPermissionsRawForUuid($this->group->getUuid());
        if ($rawPermissionsForUuid === false) {
            $rawPermissionsForUuid = array();
        }
        
        $page = new Page(
            array(
                new Form('edit-group', $request->getFullRoute(), 'post', array(
                    new ErrorBox(
                        'edit-group-errors'
                    ),
                    new Tabs(
                        array(
                            new Tab(
                                array(
                                    new Row(
                                        array(
                                            new Column(array(
                                                new Group(
                                                    'required-data',
                                                    $this->translate('Required data', '\\Zepi\\Web\\AccessControl'),
                                                    array(
                                                        new Text(
                                                            'groupname',
                                                            $this->translate('Group name', '\\Zepi\\Web\\AccessControl'),
                                                            true,
                                                            $this->group->getName(),
                                                            $this->translate('The group name must be unique. Only one group can use a group name.', '\\Zepi\\Web\\AccessControl')
                                                        ),
                                                    ),
                                                    1
                                                )
                                            ), array('col-md-6')),
                                            new Column(array(
                                                new Group(
                                                    'optional-data',
                                                    $this->translate('Optional data', '\\Zepi\\Web\\AccessControl'),
                                                    array(
                                                        new Textarea(
                                                            'description',
                                                            $this->translate('Description', '\\Zepi\\Web\\AccessControl'),
                                                            false,
                                                                $this->group->getMetaData('description')
                                                        ),
                                                    ),
                                                    2
                                                )
                                            ), array('col-md-6')),
                                        )
                                    ),
                                ),
                                array(),
                                'group-tab',
                                $this->translate('Group informations', '\\Zepi\\Web\\AccessControl')
                            ),
                            new Tab(
                                array(
                                    new Selector(
                                        'access-levels',
                                        $this->translate('Access Level Selector', '\\Zepi\\Web\\AccessControl'),
                                        false,
                                        $rawPermissionsForUuid,
                                        $accessLevelSelectorItems,
                                        $this->translate('Available Access Levels', '\\Zepi\\Web\\AccessControl'),
                                        $this->translate('Granted Access Levels', '\\Zepi\\Web\\AccessControl'),
                                        '\\Zepi\\Web\\AccessControl\\Templates\\Form\\Snippet\\AccessLevel'
                                    ),
                                ),
                                array(),
                                'access-tab',
                                $this->translate('Permissions', '\\Zepi\\Web\\AccessControl')
                            )
                        )        
                    ),
                    new Row(
                        array(
                            new Column(array(
                                new ButtonGroup(
                                    'buttons-left',
                                    array(
                                        new Button(
                                            'back',
                                            $this->translate('Back', '\\Zepi\\Web\\AccessControl'),
                                            array('btn-default'),
                                            '',
                                            'a',
                                            $request->getFullRoute('/administration/groups/')
                                        )
                                    ),
                                    1000,
                                    array('text-left')
                                )
                            ), array('col-md-4')),
                            new Column(array(
                                new ButtonGroup(
                                    'buttons',
                                    array(
                                        new Submit(
                                            'submit',
                                            $this->translate('Save', '\\Zepi\\Web\\AccessControl'), 
                                            array('btn-large', 'btn-primary'),
                                            'mdi mdi-save'
                                        )
                                    ),
                                    1000
                                )
                            ), array('col-md-4'))
                        )
                    )
                ))
            )
        );
        
        return $page;
    }
536479
public void process(Connection connection, String directory) throws Exception
   {
      connection.setAutoCommit(true);

      //
      // Retrieve meta data about the connection
      //
      DatabaseMetaData dmd = connection.getMetaData();

      String[] types =
      {
         "TABLE"
      };

      FileWriter fw = new FileWriter(directory);
      PrintWriter pw = new PrintWriter(fw);

      pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
      pw.println();
      pw.println("<database>");

      ResultSet tables = dmd.getTables(null, null, null, types);
      while (tables.next() == true)
      {
         processTable(pw, connection, tables.getString("TABLE_NAME"));
      }

      pw.println("</database>");

      pw.close();

      tables.close();
   }
951252
private void createTables() {
        this.db.execSQL(DbConstants.DROP_METADATA_STATEMENT);
        this.db.execSQL(DbConstants.DROP_INDEX_STATEMENT);
        this.db.execSQL(DbConstants.DROP_CATEGORY_MAP_STATEMENT);
        this.db.execSQL(DbConstants.DROP_DATA_STATEMENT);
        this.db.execSQL(DbConstants.DROP_CATEGORIES_STATEMENT);

        this.db.execSQL(DbConstants.CREATE_CATEGORIES_STATEMENT);
        this.db.execSQL(DbConstants.CREATE_DATA_STATEMENT);
        this.db.execSQL(DbConstants.CREATE_CATEGORY_MAP_STATEMENT);
        this.db.execSQL(DbConstants.CREATE_INDEX_STATEMENT);
        this.db.execSQL(DbConstants.CREATE_METADATA_STATEMENT);
    }