Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

release 1.2.0 update; added page caching; optimized cakephp performan…

…ce; advanced query features; new logo & layout
  • Loading branch information...
commit 57b5062684d0fd64d8d26c0f29757ff50ed43c0a 1 parent 1fbecaa
Johannes Goll authored
View
2  app/config/core.php
@@ -43,7 +43,7 @@
* In development mode, you need to click the flash message to continue.
*/
- Configure::write('debug', '0');
+ Configure::write('debug', '1');
/**
* Application wide charset encoding
View
26 app/controllers/components/solr.php
@@ -515,12 +515,36 @@ private function addLibraryDescriptions(&$facets) {
* @param string $value
* @return string
*/
- public function escape($value) {
+ private function escapeWord($value) {
//list taken from http://lucene.apache.org/java/docs/queryparsersyntax.html#Escaping%20Special%20Characters
$pattern = '/(\+|-|&&|\|\||!|\(|\)|\{|}|\[|]|\^|"|~|\*|\?|:|\\\)/';
$replace = '\\\$1';
return preg_replace($pattern, $replace, $value);
+ }
+
+ /**
+ * Escape a value meant to be contained in a phrase for special query characters
+ *
+ * @param string $value
+ * @return string
+ */
+ private function escapePhrase($value) {
+ $pattern = '/("|\\\)/';
+ $replace = '\\\$1';
+
+ return preg_replace($pattern, $replace, $value);
}
+
+ public function escape($value) {
+ if(str_word_count($value) >1) {
+ $value = $this->escapePhrase($value);
+ $value = "\"$value\"";
+ }
+ else {
+ $value = $this->escapeWord($value);
+ }
+ return $value;
+ }
}
?>
View
27 app/controllers/projects_controller.php
@@ -40,11 +40,9 @@ function index() {
$userGroup = $currentUser['UserGroup']['name'];
if($userGroup === ADMIN_USER_GROUP || $userGroup === INTERNAL_USER_GROUP) {
-
$this->paginate['Project'] = array(
'contain' => array('Population.id','Population.project_id','Library.id','Library.project_id'),
'order' => 'Project.id');
-
$this->set('projects', $this->paginate());
}
else {
@@ -134,6 +132,7 @@ function add() {
* @access public
*/
function edit($id = null) {
+ $this->loadModel('Projectmake test');
$this->loadModel('User');
if (!$id && empty($this->data)) {
@@ -198,12 +197,32 @@ function delete($id = null) {
* @param String $dataset dataset name
*/
function ftp($projectId,$dataset) {
+ $this->loadModel('Project');
+ $this->Project->contain('Library','Population');
if(defined('FTP_HOST') && defined('FTP_USERNAME') && defined('FTP_PASSWORD')) {
$fileName = "$dataset.tgz";
$filePath = "ftp://".FTP_USERNAME.":".FTP_PASSWORD."@".FTP_HOST."/$projectId/$fileName";
$this->set('ftpLink',$filePath);
- $this->set('project', $this->Project->read(null,$projectId));
}
+
+ //cache project view page
+ if (($project = Cache::read($projectId.'project')) === false) {
+ $project = $this->Project->read(null, $projectId);
+
+ if($project['Library']) {
+ foreach($project['Library'] as &$library) {
+ $library['count'] = number_format($this->Solr->count($library['name']));
+ }
+ }
+ if($project['Population']) {
+ foreach($project['Population'] as &$population) {
+ $population['count'] = number_format($this->Solr->count($population['name']));
+ }
+ }
+ Cache::write($projectId.'project', $project);
+ }
+
+ $this->set('project',$project);
$this->render('view');
}
@@ -216,7 +235,7 @@ function ftp($projectId,$dataset) {
//
// $this->autoRender=false;
//
-// $content = $this->Format->infoString($title,$selectedDatasets,$filter,null);
+// $content = $this->Format->infoString($ti$this->Project->contain('Library','Population');tle,$selectedDatasets,$filter,null);
// $content.= $this->Format->comparisonResultsToDownloadString($counts,$selectedDatasets,$option);
//
// $fileName = "jcvi_metagenomics_report_".time().'.txt';
View
10 app/controllers/search_controller.php
@@ -491,10 +491,6 @@ private function generateLuceneQuery($query,$field) {
$query = $this->Solr->escape($query);
$query = "com_name_txt:$query";
}
- elseif($field == 1 && count($queryParts) > 1) {
- $query = preg_replace('/[gG][oO]\:/i','GO\:',$query);
- }
-
//handle non-Lucene queries
else if(!in_array($firstField,$this->luceneFields) && $field != 1) {
@@ -506,9 +502,6 @@ private function generateLuceneQuery($query,$field) {
throw new ShortQueryException();
}
}
- else {
- $query = $this->Solr->escape($query);
- }
//translate selected field and query into a lucene query
switch($field) {
@@ -561,8 +554,9 @@ private function generateLuceneQuery($query,$field) {
case "kegg_id":
$this->loadModel('Pathway');
$searchByNameResults = $this->Pathway->getEnzymeQueryByKeggPathwayId($query);
- break;
+ break;
default:
+ $query = $this->Solr->escape($query);
$query = "$field:$query";
}
View
13 app/controllers/users_controller.php
@@ -98,7 +98,7 @@ function logout() {
$this->redirect('/dashboard');
}
- function register() {
+ function register() {
#get user credentials
$user = $this->Authsome->get();
@@ -150,8 +150,7 @@ function activatePassword() {
function changePassword() {
$this->loadModel('User');
- if ($this->data) {
-
+ if ($this->data) {
if ($this->User->changePassword($this->data)) {
$this->Session->setFlash("Your password has been changed.");
$this->redirect("/dashboard");
@@ -167,14 +166,16 @@ function changePassword() {
function editProjectUsers($projectId=null) {
$this->loadModel('User');
+
$currentUser = $this->Authsome->get();
$currentUserId = $currentUser['User']['id'];
if(!empty($this->data)) {
- $projectId = $this->data['Project']['id'];
-
+ $this->loadModel('Project');
$this->User->contain('ProjectsUser');
+ $projectId = $this->data['Project']['id'];
+
#delete all previous users except current user
$this->User->ProjectsUser->deleteAll(array('project_id'=>$projectId,'user_id !=' => $currentUserId));
@@ -188,7 +189,6 @@ function editProjectUsers($projectId=null) {
}
}
else {
-
$this->User->Project->contain('User');
#get all users except current user and admin for multi-user select box
@@ -238,6 +238,7 @@ function guestLogin(){
function login() {
+ $this->loadModel('User');
#account activation
if(isset($_GET["ident"])) {
#on success
View
6 app/models/project.php
@@ -179,7 +179,7 @@ public function isDatasetAdmin($dataset,$userId) {
#returns projects depending on permissions
public function findUserProjects() {
- $userProjects = array();
+
$currentUser = Authsome::get();
$currentUserId = $currentUser['User']['id'];
$userGroup = $currentUser['UserGroup']['name'];
@@ -200,10 +200,10 @@ public function findUserProjects() {
}
//return selective projects for external users
else if($userGroup === EXTERNAL_USER_GROUP) {
+ $userProjects = array();
$results = $this->query("SELECT distinct Project.id as id FROM projects as Project LEFT JOIN projects_users as pu on(Project.id=pu.project_id) WHERE pu.user_id = $currentUserId OR Project.user_id = $currentUserId OR Project.is_public=1");
- #debug("SELECT distinct Project.id as id FROM projects as Project LEFT JOIN projects_users as pu on(Project.id=pu.project_id) WHERE pu.user_id = $currentUserId OR Project.user_id = $currentUserId OR Project.is_public=1");
- #debug($results);
+
foreach($results as $result) {
$this->contain('Population.id','Population.project_id','Population.name','Population.has_apis',
View
2  app/views/search/index.ctp
@@ -33,7 +33,7 @@
<li><a href="/metarep/dashboard/index" title="Dashboard"><img src="/metarep/img/home.png" alt="Dashboard" class="home" /></a></li>
<li><?php echo $html->link('List Projects', "/projects/index");?></li>
<li><?php echo $html->link('View Project', "/projects/view/$projectId");?></li>
- <li><?php echo $html->link('Search Dataset', "/view/index/$dataset");?></li>
+ <li><?php echo $html->link('Search Dataset', "/search/index/$dataset");?></li>
</ul>
<?php
//read session variables
Please sign in to comment.
Something went wrong with that request. Please try again.