This repository has been archived by the owner on Sep 10, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Redesigned support for databases
- Loading branch information
Julien Jomier
committed
Mar 23, 2011
1 parent
c0ea6ac
commit c27681c
Showing
54 changed files
with
1,802 additions
and
1,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
/** | ||
* AppModelCassandra | ||
* Global model methods | ||
*/ | ||
class AppModelCassandra extends MIDASDatabaseCassandra | ||
{ | ||
|
||
} // end class AppModelCassandra | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
/** | ||
* GlobalModelPdo | ||
* Global model methods | ||
*/ | ||
class AppModelPdo extends MIDASDatabasePdo | ||
{ | ||
|
||
|
||
} | ||
?> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* \class FeedModel | ||
* \brief Cassandra Model | ||
*/ | ||
class CommunityModel extends MIDASCommunityModel | ||
{ | ||
|
||
|
||
} // end class CommunityModel | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* \class FeedModel | ||
* \brief Cassandra Model | ||
*/ | ||
class FeedModel extends MIDASFeedModel | ||
{ | ||
|
||
|
||
} // end class | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* \class Feedpolicygroup | ||
* \brief Cassandra Model | ||
*/ | ||
class FeedpolicygroupModel extends MIDASFeedpolicygroupModel | ||
{ | ||
|
||
|
||
} // end class | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* \class Feedpolicyuser | ||
* \brief Cassandra Model | ||
*/ | ||
class FeedpolicyuserModel extends MIDASFeedpolicyuserModel | ||
{ | ||
|
||
|
||
} // end class | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/** | ||
* \class FolderModel | ||
* \brief Cassandra Model | ||
*/ | ||
class FolderModel extends MIDASFolderModel | ||
{ | ||
/** Create a folder */ | ||
function createFolder($name,$description,$parent) | ||
{ | ||
if(!$parent instanceof FolderDao&&!is_numeric($parent)) | ||
{ | ||
throw new Zend_Exception("Should be a folder."); | ||
} | ||
if(!is_string($name)||!is_string($description)) | ||
{ | ||
throw new Zend_Exception("Should be a string."); | ||
} | ||
$this->loadDaoClass('FolderDao'); | ||
$folder=new FolderDao(); | ||
$folder->setName($name); | ||
$folder->setDescription($description); | ||
$folder->setDate(date('c')); | ||
if($parent instanceof FolderDao) | ||
{ | ||
$parentId=$parent->getFolderId(); | ||
} | ||
else | ||
{ | ||
$parentId=$parent; | ||
} | ||
$folder->setParentId($parentId); | ||
$this->save($folder); | ||
return $folder; | ||
} | ||
|
||
/** Custom save function*/ | ||
public function save($folder) | ||
{ | ||
if(!$folder instanceof FolderDao) | ||
{ | ||
throw new Zend_Exception("Should be a folder."); | ||
} | ||
if($folder->getParentId()<=0) | ||
{ | ||
$rightParent=0; | ||
} | ||
else | ||
{ | ||
$parentFolder=$folder->getParent(); | ||
$rightParent=$parentFolder->getRightIndice(); | ||
} | ||
$data = array(); | ||
foreach($this->_mainData as $key => $var) | ||
{ | ||
if(isset($folder->$key)) | ||
{ | ||
$data[$key] = $folder->$key; | ||
} | ||
if($key=='right_indice') | ||
{ | ||
$folder->$key=$rightParent+1; | ||
$data[$key]=$rightParent+1; | ||
} | ||
if($key=='left_indice') | ||
{ | ||
$data[$key]=$rightParent; | ||
} | ||
} | ||
|
||
if(isset($data['folder_id'])) | ||
{ | ||
$key = $data['folder_id']; | ||
unset($data['folder_id']); | ||
unset($data['left_indice']); | ||
unset($data['right_indice']); | ||
|
||
$db = Zend_Registry::get('dbAdapter'); | ||
$column_family->insert($key,$data); | ||
return $key; | ||
} | ||
else | ||
{ | ||
/*$this->_db->update('folder', array('right_indice'=> new Zend_Db_Expr('2 + right_indice')), | ||
array('right_indice >= ?'=>$rightParent)); | ||
$this->_db->update('folder', array('left_indice'=> new Zend_Db_Expr('2 + left_indice')), | ||
array('left_indice >= ?'=>$rightParent)); | ||
$insertedid = $this->insert($data); | ||
*/ | ||
$db = Zend_Registry::get('dbAdapter'); | ||
$column_family = new ColumnFamily($db, 'folder'); | ||
|
||
$uuid = CassandraUtil::uuid1(); | ||
$column_family->insert($uuid,$data); | ||
|
||
$folder->folder_id = bin2hex($uuid); | ||
$folder->saved=true; | ||
return true; | ||
} | ||
} // end method save | ||
|
||
|
||
} // end class FolderModel | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* \class Folderpolicygroup | ||
* \brief Cassandra Model | ||
*/ | ||
class FolderpolicygroupModel extends MIDASFolderpolicygroupModel | ||
{ | ||
|
||
} // end class | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* \class Folderpolicyuser | ||
* \brief Cassandra Model | ||
*/ | ||
class FolderpolicyuserModel extends MIDASFolderpolicyuserModel | ||
{ | ||
|
||
} // end class | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* \class GroupModel | ||
* \brief Cassandra Model | ||
*/ | ||
class GroupModel extends MIDASGroupModel | ||
{ | ||
|
||
} // end class | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* \class UserModel | ||
* \brief Cassandra Model | ||
*/ | ||
class UserModel extends MIDASUserModel | ||
{ | ||
/** Get a user by email */ | ||
function getByEmail($email) | ||
{ | ||
// We get from the table emailuser | ||
try | ||
{ | ||
$emailuser = new ColumnFamily($this->database->getDB(), 'emailuser'); | ||
$userid = $emailuser->get($email); | ||
|
||
//$dao= $this->initDao('User',); | ||
} | ||
catch(cassandra_NotFoundException $e) | ||
{ | ||
return false; | ||
} | ||
catch(Exception $e) | ||
{ | ||
throw new Zend_Exception($e); | ||
} | ||
|
||
return $dao; | ||
} // end getByEmail() | ||
|
||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.