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

Commit 94b9fdc

Browse files
author
Julien Jomier
committed
ENH: Improving database support
1 parent 6423d04 commit 94b9fdc

13 files changed

+85
-50
lines changed

core/models/pdo/FeedModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ function createFeed($userDao,$type,$ressource,$communityDao=null)
247247
throw new Zend_Exception("Unable to defined the type of feed");
248248
break;
249249
}
250-
$this->database->save($feed);
250+
$this->save($feed);
251251

252252
if($communityDao instanceof CommunityDao)
253253
{
@@ -269,7 +269,7 @@ function addCommunity($feed,$community)
269269
{
270270
throw new Zend_Exception("Should be an feed.");
271271
}
272-
$this->link('communities',$feed,$community);
272+
$this->database->link('communities',$feed,$community);
273273
} // end addCommunity
274274

275275
/** Delete Dao

core/models/pdo/FeedpolicygroupModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public function createPolicy($group, $feed, $policy)
2727
}
2828
if($this->getPolicy($group,$feed) !== false)
2929
{
30-
$this->database->delete($this->getPolicy($group,$feed));
30+
$this->delete($this->getPolicy($group,$feed));
3131
}
3232
$this->loadDaoClass('FeedpolicygroupDao');
3333
$policyGroupDao=new FeedpolicygroupDao();
3434
$policyGroupDao->setGroupId($group->getGroupId());
3535
$policyGroupDao->setFeedId($feed->getFeedId());
3636
$policyGroupDao->setPolicy($policy);
37-
$this->database->save($policyGroupDao);
37+
$this->save($policyGroupDao);
3838
return $policyGroupDao;
3939
}
4040

core/models/pdo/FeedpolicyuserModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function createPolicy($user, $feed, $policy)
3434
$policyUser->setUserId($user->getUserId());
3535
$policyUser->setFeedId($feed->getFeedId());
3636
$policyUser->setPolicy($policy);
37-
$this->database->save($policyUser);
37+
$this->save($policyUser);
3838
return $policyUser;
3939
}
4040

core/models/pdo/FolderModel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function delete($folder)
173173
array('left_indice >= ?'=>$leftIndice));
174174
$this->database->getDB()->update('folder', array('right_indice'=> new Zend_Db_Expr('right_indice - 2')),
175175
array('right_indice >= ?'=>$leftIndice));
176-
$this->database->delete( $folder);
176+
$this->delete( $folder);
177177
unset($folder->folder_id);
178178
$folder->saved=false;
179179
return true;
@@ -292,7 +292,7 @@ function createFolder($name,$description,$parent)
292292
$parentId=$parent;
293293
}
294294
$folder->setParentId($parentId);
295-
$this->database->save($folder);
295+
$this->save($folder);
296296
return $folder;
297297
}
298298

@@ -601,7 +601,7 @@ function addItem($folder,$item)
601601
{
602602
throw new Zend_Exception("Should be an item.");
603603
}
604-
$this->link('items',$folder,$item);
604+
$this->database->link('items',$folder,$item);
605605
} // end function addItem
606606

607607
/** Return an item by its name

core/models/pdo/FolderpolicygroupModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function createPolicy($group, $folder, $policy)
3434
$policyGroupDao->setGroupId($group->getGroupId());
3535
$policyGroupDao->setFolderId($folder->getFolderId());
3636
$policyGroupDao->setPolicy($policy);
37-
$this->database->save($policyGroupDao);
37+
$this->save($policyGroupDao);
3838
return $policyGroupDao;
3939
}
4040

core/models/pdo/ItemKeywordModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function insertKeyword($keyword)
111111
else
112112
{
113113
$keyword->setRelevance(1);
114-
$return = parent::save($keyword);
114+
$return = $this->save($keyword);
115115
}
116116
unset($row);
117117
return $return;

core/models/pdo/ItemModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ function addKeyword($itemdao,$keyworddao)
222222
{
223223
throw new Zend_Exception("Second argument should be a keyword");
224224
}
225-
$this->link('keywords',$itemdao,$keyworddao);
225+
$this->database->link('keywords',$itemdao,$keyworddao);
226226
} // end addKeyword
227227

228228
} // end class

core/models/pdo/ItempolicyuserModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public function createPolicy($user, $item, $policy)
2727
}
2828
if($this->getPolicy($user,$item) !== false)
2929
{
30-
$this->database->delete($this->getPolicy($user,$item));
30+
$this->delete($this->getPolicy($user,$item));
3131
}
3232
$this->loadDaoClass('ItempolicyuserDao');
3333
$policyUser=new ItempolicyuserDao();
3434
$policyUser->setUserId($user->getUserId());
3535
$policyUser->setItemId($item->getItemId());
3636
$policyUser->setPolicy($policy);
37-
$this->database->save($policyUser);
37+
$this->save($policyUser);
3838
return $policyUser;
3939
}
4040

library/MIDAS/models/MIDASDatabaseCassandra.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function getDB()
3636
return $this->_db;
3737
}
3838

39-
/**
39+
/**
4040
* @method public getValues($key)
4141
* Get all the value of a model
4242
* @param $key
@@ -61,5 +61,31 @@ public function getValues($key)
6161
}
6262
} // end method getValues;
6363

64+
/**
65+
* @method public save($dao)
66+
* Saves a DAO from the database
67+
* @param $dao
68+
* @return true/false
69+
*/
70+
public function save($dao)
71+
{
72+
73+
} // end function save
74+
75+
/**
76+
* @method public delete($dao)
77+
* Delete a DAO from the database
78+
* @param $dao
79+
* @return true/false
80+
*/
81+
public function delete($dao)
82+
{
83+
84+
85+
} // end function delete
86+
87+
88+
89+
6490
} // end class MIDASDatabaseCassandra
6591
?>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22
interface MIDASDatabaseInterface
33
{
4-
4+
public function save($dao);
5+
public function delete($dao);
56

67
} // end interface
78
?>

0 commit comments

Comments
 (0)