Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Fix bad spelling mistakes in database schema and standardize plurals
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Nov 20, 2014
1 parent b8d8de3 commit f181b0a
Show file tree
Hide file tree
Showing 22 changed files with 342 additions and 259 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.

-- MySQL core database, version 3.2.17
-- MySQL core database, version 3.2.18

CREATE TABLE IF NOT EXISTS `activedownload` (
`activedownload_id` bigint(20) NOT NULL AUTO_INCREMENT,
Expand Down Expand Up @@ -73,7 +73,7 @@ CREATE TABLE IF NOT EXISTS `feed` (
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`user_id` bigint(20) NOT NULL,
`type` tinyint(4) NOT NULL,
`ressource` varchar(255) NOT NULL,
`resource` varchar(255) NOT NULL,
PRIMARY KEY (`feed_id`)
) DEFAULT CHARSET=utf8;

Expand Down Expand Up @@ -101,8 +101,8 @@ CREATE TABLE IF NOT EXISTS `feedpolicyuser` (

CREATE TABLE IF NOT EXISTS `folder` (
`folder_id` bigint(20) NOT NULL AUTO_INCREMENT,
`left_indice` bigint(20) NOT NULL,
`right_indice` bigint(20) NOT NULL,
`left_index` bigint(20) NOT NULL,
`right_index` bigint(20) NOT NULL,
`parent_id` bigint(20) NOT NULL DEFAULT '0',
`name` varchar(255) NOT NULL,
`description` text NOT NULL,
Expand All @@ -114,8 +114,8 @@ CREATE TABLE IF NOT EXISTS `folder` (
`date_creation` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`folder_id`),
KEY (`parent_id`),
KEY (`left_indice`),
KEY (`right_indice`)
KEY (`left_index`),
KEY (`right_index`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `folderpolicygroup` (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.

-- PostgreSQL core database, version 3.2.17
-- PostgreSQL core database, version 3.2.18

SET client_encoding = 'UTF8';
SET default_with_oids = FALSE;
Expand Down Expand Up @@ -70,7 +70,7 @@ CREATE TABLE IF NOT EXISTS "feed" (
"date" timestamp without time zone NOT NULL,
"user_id" bigint NOT NULL,
"type" integer NOT NULL,
"ressource" character varying(256) NOT NULL
"resource" character varying(256) NOT NULL
);

CREATE TABLE IF NOT EXISTS "feed2community" (
Expand All @@ -97,8 +97,8 @@ CREATE TABLE IF NOT EXISTS "feedpolicyuser" (

CREATE TABLE IF NOT EXISTS "folder" (
"folder_id" serial PRIMARY KEY,
"left_indice" bigint NOT NULL,
"right_indice" bigint NOT NULL,
"left_index" bigint NOT NULL,
"right_index" bigint NOT NULL,
"parent_id" bigint DEFAULT 0::bigint NOT NULL,
"name" character varying(256) NOT NULL,
"description" text NOT NULL,
Expand All @@ -110,9 +110,9 @@ CREATE TABLE IF NOT EXISTS "folder" (
"date_creation" timestamp without time zone
);

CREATE INDEX "folder_idx_left_indice" ON "folder" ("left_indice");
CREATE INDEX "folder_idx_left_index" ON "folder" ("left_index");
CREATE INDEX "folder_idx_parent_id" ON "folder" ("parent_id");
CREATE INDEX "folder_idx_right_indice" ON "folder" ("right_indice");
CREATE INDEX "folder_idx_right_index" ON "folder" ("right_index");

CREATE TABLE IF NOT EXISTS "folderpolicygroup" (
"id" serial PRIMARY KEY,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.

-- SQLite core database, version 3.2.17
-- SQLite core database, version 3.2.18

CREATE TABLE IF NOT EXISTS "activedownload" (
"activedownload_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
Expand Down Expand Up @@ -67,7 +67,7 @@ CREATE TABLE IF NOT EXISTS "feed" (
"date" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
"user_id" INTEGER NOT NULL,
"type" INTEGER NOT NULL,
"ressource" TEXT NOT NULL
"resource" TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS "feed2community" (
Expand All @@ -94,8 +94,8 @@ CREATE TABLE IF NOT EXISTS "feedpolicyuser" (

CREATE TABLE IF NOT EXISTS "folder" (
"folder_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"left_indice" INTEGER NOT NULL,
"right_indice" INTEGER NOT NULL,
"left_index" INTEGER NOT NULL,
"right_index" INTEGER NOT NULL,
"parent_id" INTEGER NOT NULL DEFAULT 0,
"name" TEXT NOT NULL,
"description" TEXT NOT NULL,
Expand All @@ -107,9 +107,9 @@ CREATE TABLE IF NOT EXISTS "folder" (
"date_creation" TEXT NOT NULL DEFAULT '0000-00-00 00:00:00'
);

CREATE INDEX IF NOT EXISTS "folder_left_indice_idx" ON "folder" ("left_indice");
CREATE INDEX IF NOT EXISTS "folder_left_index_idx" ON "folder" ("left_index");
CREATE INDEX IF NOT EXISTS "folder_parent_id_idx" ON "folder" ("parent_id");
CREATE INDEX IF NOT EXISTS "folder_right_indice_idx" ON "folder" ("right_indice");
CREATE INDEX IF NOT EXISTS "folder_right_index_idx" ON "folder" ("right_index");

CREATE TABLE IF NOT EXISTS "folderpolicygroup" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
Expand Down
48 changes: 48 additions & 0 deletions core/database/upgrade/3.2.18.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
All rights reserved.
More information http://www.kitware.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/

/** Upgrade the core to version 3.2.18. */
class Upgrade_3_2_18 extends MIDASUpgrade
{

/** Upgrade a MySQL database. */
public function mysql()
{
$this->db->query("ALTER TABLE `folder` DROP KEY `left_indice`;");
$this->db->query("ALTER TABLE `folder` DROP KEY `right_indice`;");
$this->db->query("ALTER TABLE `folder` CHANGE `left_indice` `left_index` bigint(20) NOT NULL;");
$this->db->query("ALTER TABLE `folder` CHANGE `right_indice` `right_index` bigint(20) NOT NULL;");
$this->db->query("ALTER TABLE `folder` ADD KEY (`left_index`);");
$this->db->query("ALTER TABLE `folder` ADD KEY (`right_index`);");
$this->db->query("ALTER TABLE `feed` CHANGE `ressource` `resource` varchar(255) NOT NULL;");
}

/** Upgrade a PostgreSQL database. */
public function pgsql()
{
$this->db->query("DROP INDEX IF EXISTS folder_idx_left_indice;");
$this->db->query("DROP INDEX IF EXISTS folder_idx_right_indice;");
$this->db->query("ALTER TABLE folder RENAME left_indice TO left_index;");
$this->db->query("ALTER TABLE folder RENAME right_indice TO right_index;");
$this->db->query("CREATE INDEX folder_idx_left_index ON folder (left_index);");
$this->db->query("CREATE INDEX folder_idx_right_index ON folder (right_index);");
$this->db->query("ALTER TABLE feed RENAME ressource TO resource;");
}
}
50 changes: 25 additions & 25 deletions core/models/base/FeedModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct()
'date' => array('type' => MIDAS_DATA),
'user_id' => array('type' => MIDAS_DATA),
'type' => array('type' => MIDAS_DATA),
'ressource' => array('type' => MIDAS_DATA),
'resource' => array('type' => MIDAS_DATA),
'communities' => array(
'type' => MIDAS_MANY_TO_MANY,
'model' => 'Community',
Expand Down Expand Up @@ -109,11 +109,11 @@ public function getFeedsByCommunity($loggedUserDao, $communityDao, $policy = 0,
*
* @return FeedDao
*/
public function createFeed($userDao, $type, $ressource, $communityDao = null)
public function createFeed($userDao, $type, $resource, $communityDao = null)
{
if (!$userDao instanceof UserDao && !is_numeric($type) && !is_object($ressource)
if (!$userDao instanceof UserDao && !is_numeric($type) && !is_object($resource)
) {
throw new Zend_Exception("Error in parameters, userdao, type, and ressource.");
throw new Zend_Exception("Error in parameters, userdao, type, and resource.");
}
$feed = MidasLoader::newDao('FeedDao');
$feed->setUserId($userDao->getKey());
Expand All @@ -122,51 +122,51 @@ public function createFeed($userDao, $type, $ressource, $communityDao = null)
switch ($type) {
case MIDAS_FEED_CREATE_COMMUNITY:
case MIDAS_FEED_UPDATE_COMMUNITY:
if (!$ressource instanceof CommunityDao) {
throw new Zend_Exception("Error in parameter ressource, expecting CommunityDao, type:".$type);
if (!$resource instanceof CommunityDao) {
throw new Zend_Exception("Error in parameter resource, expecting CommunityDao, type:".$type);
}
$feed->setRessource($ressource->getKey());
$feed->setResource($resource->getKey());
break;
case MIDAS_FEED_COMMUNITY_INVITATION:
if (!$ressource instanceof CommunityInvitationDao) {
if (!$resource instanceof CommunityInvitationDao) {
throw new Zend_Exception(
"Error in parameter ressource, expecting CommunityInvitationDao, type:".$type
"Error in parameter resource, expecting CommunityInvitationDao, type:".$type
);
}
$feed->setRessource($ressource->getKey());
$feed->setResource($resource->getKey());
break;
case MIDAS_FEED_CREATE_FOLDER:
if (!$ressource instanceof FolderDao) {
throw new Zend_Exception("Error in parameter ressource, expecting FolderDao, type:".$type);
if (!$resource instanceof FolderDao) {
throw new Zend_Exception("Error in parameter resource, expecting FolderDao, type:".$type);
}
$feed->setRessource($ressource->getKey());
$feed->setResource($resource->getKey());
break;
case MIDAS_FEED_CREATE_LINK_ITEM:
case MIDAS_FEED_CREATE_ITEM:
if (!$ressource instanceof ItemDao) {
throw new Zend_Exception("Error in parameter ressource, expecting ItemDao, type:".$type);
if (!$resource instanceof ItemDao) {
throw new Zend_Exception("Error in parameter resource, expecting ItemDao, type:".$type);
}
$feed->setRessource($ressource->getKey());
$feed->setResource($resource->getKey());
break;
case MIDAS_FEED_CREATE_REVISION:
if (!$ressource instanceof ItemRevisionDao) {
throw new Zend_Exception("Error in parameter ressource, expecting ItemRevisionDao, type:".$type);
if (!$resource instanceof ItemRevisionDao) {
throw new Zend_Exception("Error in parameter resource, expecting ItemRevisionDao, type:".$type);
}
$feed->setRessource($ressource->getKey());
$feed->setResource($resource->getKey());
break;
case MIDAS_FEED_CREATE_USER:
if (!$ressource instanceof UserDao) {
throw new Zend_Exception("Error in parameter ressource, expecting UserDao, type:".$type);
if (!$resource instanceof UserDao) {
throw new Zend_Exception("Error in parameter resource, expecting UserDao, type:".$type);
}
$feed->setRessource($ressource->getKey());
$feed->setResource($resource->getKey());
break;
case MIDAS_FEED_DELETE_COMMUNITY:
case MIDAS_FEED_DELETE_FOLDER:
case MIDAS_FEED_DELETE_ITEM:
if (!is_string($ressource)) {
throw new Zend_Exception("Error in parameter ressource, expecting string, type:".$type);
if (!is_string($resource)) {
throw new Zend_Exception("Error in parameter resource, expecting string, type:".$type);
}
$feed->setRessource($ressource);
$feed->setResource($resource);
break;
default:
throw new Zend_Exception("Unable to find an expected type of feed");
Expand Down
4 changes: 2 additions & 2 deletions core/models/base/FolderModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function __construct()

$this->_mainData = array(
'folder_id' => array('type' => MIDAS_DATA),
'left_indice' => array('type' => MIDAS_DATA),
'right_indice' => array('type' => MIDAS_DATA),
'left_index' => array('type' => MIDAS_DATA),
'right_index' => array('type' => MIDAS_DATA),
'parent_id' => array('type' => MIDAS_DATA),
'name' => array('type' => MIDAS_DATA),
'description' => array('type' => MIDAS_DATA),
Expand Down
35 changes: 13 additions & 22 deletions core/models/dao/FeedDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @method void setUserId(int $userId)
* @method int getType()
* @method void setType(int $type)
* @method void setResource(string $resource)
* @method array getCommunities()
* @method void setCommunities(array $communities)
* @method UserDao getUser()
Expand All @@ -47,7 +48,7 @@ class FeedDao extends AppDao
/**
* Return the resource.
*
* @return string
* @return mixed
* @throws Zend_Exception
*/
public function getResource()
Expand All @@ -59,32 +60,32 @@ public function getResource()
case MIDAS_FEED_UPDATE_COMMUNITY:
$model = MidasLoader::loadModel('Community');

return $model->load($this->ressource);
return $model->load($this->resource);
case MIDAS_FEED_COMMUNITY_INVITATION:
$model = MidasLoader::loadModel('CommunityInvitation');

return $model->load($this->ressource);
return $model->load($this->resource);
case MIDAS_FEED_CREATE_FOLDER:
$model = MidasLoader::loadModel('Folder');

return $model->load($this->ressource);
return $model->load($this->resource);
case MIDAS_FEED_CREATE_ITEM:
case MIDAS_FEED_CREATE_LINK_ITEM:
$model = MidasLoader::loadModel('Item');

return $model->load($this->ressource);
return $model->load($this->resource);
case MIDAS_FEED_CREATE_REVISION:
$model = MidasLoader::loadModel('ItemRevision');

return $model->load($this->ressource);
return $model->load($this->resource);
case MIDAS_FEED_CREATE_USER:
$model = MidasLoader::loadModel('User');

return $model->load($this->ressource);
return $model->load($this->resource);
case MIDAS_FEED_DELETE_COMMUNITY:
case MIDAS_FEED_DELETE_FOLDER:
case MIDAS_FEED_DELETE_ITEM:
return $this->ressource;
return $this->resource;
default:
throw new Zend_Exception('Unable to define the type of feed.');
}
Expand All @@ -93,8 +94,8 @@ public function getResource()
/**
* Return the resource.
*
* @deprecated
* @return string
* @deprecated since 3.3.0
* @return mixed
*/
public function getRessource()
{
Expand All @@ -104,18 +105,8 @@ public function getRessource()
/**
* Set the resource.
*
* @param $resource resource
*/
public function setResource($resource)
{
$this->ressource = $resource;
}

/**
* Set the resource.
*
* @deprecated
* @param $resource resource
* @deprecated since 3.3.0
* @param string $resource resource
*/
public function setRessource($resource)
{
Expand Down
Loading

0 comments on commit f181b0a

Please sign in to comment.