Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove commented code from site service +minor #237

Merged
merged 1 commit into from Jul 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
74 changes: 10 additions & 64 deletions lib/Gocdb_Services/Site.php
Expand Up @@ -236,13 +236,6 @@ function editSite(\Site $site, $newValues, \User $user = null) {
foreach($scopes as $s) {
$site->removeScope($s);
}
// foreach($scopeIdsToApply as $scopeId){
// $dql = "SELECT s FROM Scope s WHERE s.id = ?1";
// $scope = $this->em->createQuery($dql)
// ->setParameter(1, $scopeId)
// ->getSingleResult();
// $site->addScope($scope);
// }

// Link the requested scopes to the site
foreach($selectedScopesToApply as $scope){
Expand Down Expand Up @@ -312,13 +305,6 @@ function editSite(\Site $site, $newValues, \User $user = null) {
->getSingleResult();
$site->setCountry($country);

// deprecated
// $dql = "SELECT t FROM Timezone t WHERE t.name = ?1";
// $timezone = $this->em->createQuery($dql)
// ->setParameter(1, $newValues['Timezone'])
// ->getSingleResult();
// $site->setTimezone($timezone);

$this->em->merge($site);
$this->em->flush();
$this->em->getConnection()->commit();
Expand Down Expand Up @@ -368,33 +354,25 @@ private function validate($site_data, $type) {

/**
* Return all {@see \Site}s that satisfy the specfied filter parameters.
* <p>
*
* $filterParams defines an associative array of optional parameters for
* filtering the sites. The supported Key => Value pairs include:
* <ul>
* <li>'sitename' => String site name</li>
* <li>'roc' => String name of parent NGI/ROC</li>
* <li>'country' => String country name</li>
* <li>'certification_status' => String certification status value e.g. 'Certified'</li>
* <li>'exclude_certification_status' => String exclude sites with this certification status</li>
* <li>'production_status' => String site production status value</li>
* <li>'scope' => 'String,comma,sep,list,of,scopes,e.g.,egi,wlcg'</li>
* <li>'scope_match' => String 'any' or 'all' </li>
* <li>'extensions' => String extensions expression to filter custom key=value pairs</li>
* <ul>
* 'sitename' => String site name
* 'roc' => String name of parent NGI/ROC
* 'country' => String country name
* 'certification_status' => String certification status value e.g. 'Certified'
* 'exclude_certification_status' => String exclude sites with this certification status
* 'production_status' => String site production status value
* 'scope' => 'String,comma,sep,list,of,scopes,e.g.,egi,wlcg'
* 'scope_match' => String 'any' or 'all'
* 'extensions' => String extensions expression to filter custom key=value pairs
*
* @param array $filterParams
* @return array Site array
*/
public function getSitesFilterByParams($filterParams){
require_once __DIR__.'/PI/GetSite.php';
$getSite = new GetSite($this->em);
//$params = array('sitename' => 'GRIDOPS-GOCDB');
//$params = array('scope' => 'EGI,DAVE', 'sitename' => 'GRIDOPS-GOCDB');
//$params = array('scope' => 'EGI,Local', 'scope_match' => 'any', 'exclude_certification_status' => 'Closed');
//$params = array('scope' => 'EGI,Local', 'scope_match' => 'all');
//$params = array('scope' => 'EGI,DAVE', 'scope_match' => 'all');
//$params = array('extensions' => '(aaa=123)(dave=\(someVal with parethesis\))(test=test)');
$getSite->validateParameters($filterParams);
$getSite->createQuery();
$sites = $getSite->executeQuery();
Expand Down Expand Up @@ -583,20 +561,6 @@ public function getCountries() {
return $countries;
}

/**
* Return all timezones in the DB
* @return Array an array of Timezone objects
*/
// public function getTimezones() {
// $dql = "SELECT t from Timezone t
// ORDER BY t.name";
// $timezones = $this->em
// ->createQuery($dql)
// ->getResult();
// return $timezones;
// }


/**
* Returns the downtimes linked to a site.
* @param integer $id Site ID
Expand Down Expand Up @@ -741,8 +705,6 @@ public function addSite($values, \User $user =null) {
// flush synchronizes the in-memory state of managed objects with the database
// but we can still rollback
$this->em->flush();
//$this->em->getConnection()->commit();
//$this->em->getConnection()->beginTransaction();
$site = new \Site();
$site->setPrimaryKey($pk->getId() . "G0");
$site->setOfficialName($values['Site']['OFFICIAL_NAME']);
Expand Down Expand Up @@ -812,13 +774,6 @@ public function addSite($values, \User $user =null) {


// Set the scopes
// foreach($allSelectedScopeIds as $scopeId){
// $dql = "SELECT s FROM Scope s WHERE s.id = :id";
// $scope = $this->em->createQuery($dql)
// ->setParameter('id', $scopeId)
// ->getSingleResult();
// $site->addScope($scope);
// }
foreach($selectedScopesToApply as $scope){
$site->addScope($scope);
}
Expand All @@ -830,22 +785,13 @@ public function addSite($values, \User $user =null) {
->getSingleResult();
$site->setCountry($country);

// deprecated - don't use the lookup DB entity
// $dql = "SELECT t FROM Timezone t WHERE t.id = :id";
// $timezone = $this->em->createQuery($dql)
// ->setParameter('id', $values['Timezone'])
// ->getSingleResult();
// $site->setTimezone($timezone);

$this->em->persist($site);
// flush synchronizes the in-memory state of managed objects with the database
// but we can still rollback
$this->em->flush();
$this->em->getConnection()->commit();
} catch(\Exception $ex){
$this->em->getConnection()->rollback();
//$this->em->remove($pk);
//$this->em->flush();
$this->em->close();
throw $ex;
}
Expand Down