Skip to content

Commit

Permalink
Improve comment syntax in sample data deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rowan04 authored and gregcorbett committed Nov 29, 2023
1 parent e6e053d commit ae84cac
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 57 deletions.
6 changes: 3 additions & 3 deletions lib/Doctrine/deploy/AddCertificationStatuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

require_once __DIR__ . "/../bootstrap.php";
require_once __DIR__ . "/AddUtils.php";
/* AddNGIs.php: Loads a list of cert statuses from an XML file and
* inserts them into the doctrine prototype.
* XML format is the xml input format of the cert status seed data
/* AddCertificationStatuses.php: Loads a list of cert statuses from
* an XML file and inserts them into the doctrine prototype.
* XML format is the xml input format of the cert status seed data.
*/
$certStatsFileName = __DIR__ . "/" . $GLOBALS['dataDir'] .
"/CertificationStatuses.xml";
Expand Down
18 changes: 10 additions & 8 deletions lib/Doctrine/deploy/AddDowntimes.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@
// Hack: the above SEs appear twice with the same service type. (nightmare)
// However in most cases both SEs share the same downtimes...

// AddDowntimes.php: Loads a list of downtimes from an
// AddDowntimes.php: Loads a list of downtimes from an
// XML file and inserts them into the doctrine prototype.
// XML format is the output from get_service_endpoints PI query.
//
// XML format is the output from get_downtime PI query.


$allDowntimes = array();
Expand All @@ -57,14 +56,17 @@
$downtime = null;
// See if we've already entered a downtime with this prom ID
if (isset($allDowntimes[$promId])) {
// load $downtime from db by $promId rather than loading from global
// Load $downtime from db by $promId rather than loading from global
// array. This assumes xml ID attribute (without 'G0' appended) is
// the same as xml PRIMARY_KEY attribute.
//
// $downtime = $entityManager->createQuery("select d FROM Downtime " .
// "d WHERE d.primaryKey = ?1")
// ->setParameter(1, (string) $promId.'G0')
// ->getResult();
// ->setParameter(
// 1,
// (string) $promId.'G0'
// )
// ->getResult();
$downtime = $allDowntimes[$promId];
}

Expand All @@ -78,7 +80,7 @@
);

// There are some edge cases where findSEs returns
// more than one SE (see the comment at the top of this file)
// more than one SE (see the comment at the top of this file).
// However if the downtime isn't yet created we always
// link to the first SE found.
if (!isset($services[0])) {
Expand Down Expand Up @@ -141,7 +143,7 @@
// Check whether this exception is caused by a known issue
// with duplicate SEs (see comment at the top of the file).
// Issue is known if two SEs are found and the hostname is
// a known duplicate
// a known duplicate.
$twoSes = false;
if (count($services) == 2) {
$twoSes = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/deploy/AddInfrastructures.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_once __DIR__ . "/../bootstrap.php";
require_once __DIR__ . "/AddUtils.php";

/* AddNGIs.php: Loads a list of infrastructures from an XML file and
/* AddInfrastructures.php: Loads a list of infrastructures from an XML file and
* inserts them into the doctrine prototype.
* XML format is the xml input production status format.
*/
Expand Down
15 changes: 9 additions & 6 deletions lib/Doctrine/deploy/AddNGIRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@
continue;
}

// get roletype entity
// Get roletype entity
$dql = "SELECT rt FROM RoleType rt WHERE rt.name = :roleType";
$roleTypes = $entityManager->createQuery($dql)
->setParameter(
':roleType',
(string) $role->USER_ROLE
)
->getResult();

// /* Error checking: ensure each role type refers to exactly
// * one role type*/
// * one role type */
if (count($roleTypes) !== 1) {
throw new Exception(count($roleTypes) . " role types found " .
"with name: " . $role->USER_ROLE);
Expand Down Expand Up @@ -59,8 +60,8 @@
$doctrineUser = $doctrineUser;
}

// Check for invalid NGIs and skip
// typically these are decomissioned ROCs
// Check for invalid NGIs and skip.
// Typically these are decomissioned ROCs.
if (
$role->ON_ENTITY == 'GridIreland'
|| $role->ON_ENTITY == 'NGS'
Expand All @@ -71,7 +72,7 @@
continue;
}

// get ngi entity
// Get ngi entity
$ngiName = (string) $role->ON_ENTITY;
$dql = "SELECT n FROM NGI n WHERE n.name = :ngi";
$ngis = $entityManager->createQuery($dql)
Expand All @@ -80,6 +81,7 @@
$ngiName
)
->getResult();

// /* Error checking: ensure each "ngi" refers to exactly
// * one ngi */
if (count($ngis) !== 1) {
Expand All @@ -91,7 +93,8 @@
$ngi = $ngi;
}

//check that the role is not a duplicate (v4 data contaisn duplicates)
// Check that the role is not a duplicate
// (v4 data contains duplicates)
$ExistingUserRoles = $doctrineUser->getRoles();
$thisIsADuplicateRole=false;
foreach ($ExistingUserRoles as $role) {
Expand Down
15 changes: 8 additions & 7 deletions lib/Doctrine/deploy/AddNGIs.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
$egiProject = $entityManager->getRepository('Project')
->findOneBy(array("name" => "EGI"));

//Find the EGI scope tag
// Find the EGI scope tag
$egiScope = $entityManager->getRepository('Scope')
->findOneBy(array("name" => "EGI"));

//Add Local Scope so specified NGI is not part of EGI project
// Add Local Scope so that the specified NGI is
// not part of the EGI project
$localScope = $entityManager->getRepository('Scope')
->findOneBy(array("name" => "Local"));

Expand Down Expand Up @@ -68,7 +69,7 @@
// '12-JAN-10 14.12.56.000000'
$cdateonString = (string) $value;

//convert to date time
// Convert to date time
$creationDate = DateTime::createFromFormat(
'd-M-y G.i.s.u',
$cdateonString,
Expand All @@ -94,19 +95,19 @@
//if ($cdateon == null) throw new Exception("CDATEON is null");
//$doctrineNgi->setCreationDate($cdateon);

// if the NGI has id 67518 (NGI_HU) do not add it to EGI Project
// If the NGI has id 67518 (NGI_HU) do not add it to EGI Project
if ($objectID == "67518") {
$doctrineNgi->addScope($localScope);
$entityManager->persist($doctrineNgi);
} else {
// add NGI to EGI project and give it EGI scope
// Add NGI to EGI project and give it EGI scope
$egiProject->addNgi($doctrineNgi);
$doctrineNgi->addScope($egiScope);
$entityManager->persist($doctrineNgi);
}

}

// don't need to merge egiProject
//$entityManager->merge($egiProject);
// Don't need to merge egiProject
// $entityManager->merge($egiProject);
$entityManager->flush();
7 changes: 4 additions & 3 deletions lib/Doctrine/deploy/AddProjectRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require_once __DIR__ . "/AddUtils.php";

/**
* AddEgiRoles.php: Loads a list of roles from the get_user PI
* AddProjectRoles.php: Loads a list of roles from the get_user PI
* query output (XML), finds what project entity the role is over,
* if the project entity refers to exactly one project the role is
* added to that project and inserted into the doctrine prototype.
Expand All @@ -28,16 +28,17 @@
continue;
}

// get roletype entity
// Get roletype entity
$dql = "SELECT rt FROM RoleType rt WHERE rt.name = :roleType";
$roleTypes = $entityManager->createQuery($dql)
->setParameter(
':roleType',
(string) $role->USER_ROLE
)
->getResult();

// /* Error checking: ensure each role type refers to exactly
// * one role type*/
// * one role type */
if (count($roleTypes) !== 1) {
throw new Exception(count($roleTypes) . " role types found " .
"with name: " . $role->USER_ROLE);
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/deploy/AddScopes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_once __DIR__ . "/../bootstrap.php";
require_once __DIR__ . "/AddUtils.php";

/* AddNGIs.php: Loads a list of scopes from an XML file and
/* AddScopes.php: Loads a list of scopes from an XML file and
* inserts them into the doctrine prototype.
* XML format is the xml input format for scope data
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/deploy/AddServiceEndpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

foreach ($ses as $xmlSe) {
$doctrineSe = new Service();
// get the hosting site entity
// Get the hosting site entity
$dql = "SELECT s from Site s WHERE s.shortName = ?1";
$parentSites = $entityManager->createQuery($dql)
->setParameter(
Expand All @@ -64,7 +64,7 @@

$doctrineSe->setParentSiteDoJoin($parentSite);

// get the hosting service type
// Get the hosting service type
$dql = "SELECT s from ServiceType s WHERE s.name = ?1";
$sts = $entityManager->createQuery($dql)
->setParameter(
Expand Down Expand Up @@ -117,7 +117,7 @@
" for SE " . $xmlSe->HOSTNAME);
}

//set creation date
// Set creation date
$creationDate = new \DateTime("now", new DateTimeZone('UTC'));


Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/deploy/AddServiceGroupRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
continue;
}

// get roletype entity
// Get roletype entity
$userRole = (string) $role->USER_ROLE;
$dql = "SELECT rt FROM RoleType rt WHERE rt.name = :roleType";
$roleTypes = $entityManager->createQuery($dql)
Expand Down Expand Up @@ -65,7 +65,7 @@
// Set $doctrineUser as the first and only user in the users array
$doctrineUser = $users[0];

// get serviceGroup entity
// Get serviceGroup entity
$sgName = (string) $role->ON_ENTITY;
$dql = "SELECT sg FROM ServiceGroup sg WHERE " .
"sg.name = :service_group";
Expand Down
18 changes: 10 additions & 8 deletions lib/Doctrine/deploy/AddSiteRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require_once __DIR__ . "/AddUtils.php";

/**
* AddNGIs.php: Loads a list of Site roles from an XML file and
* AddSiteRoles.php: Loads a list of Site roles from an XML file and
* inserts them into the doctrine prototype.
* XML format is the output from get_user_doctrine PI query.
*/
Expand All @@ -24,15 +24,15 @@
continue;
}

// Find the role type
// get the roletype entity
// Find the role type and get the roletype entity
$dql = "SELECT rt FROM RoleType rt WHERE rt.name = ?1";
$roleTypes = $entityManager->createQuery($dql)
->setParameter(
1,
(string) $role->USER_ROLE
)
->getResult();

// /* Error checking: ensure each role type refers to exactly
// * one role type */
if (count($roleTypes) !== 1) {
Expand Down Expand Up @@ -73,21 +73,22 @@
throw new Exception("Not a doctrine user");
}

// Check for invalid sites and skip adding this role
// typically these sites don't have an NGI,
// country or production status
// Check for invalid sites and skip adding this role.
// Typically these sites don't have an NGI,
// country or production status.
if (isBad((string) $role->ON_ENTITY)) {
continue;
}

// get the site entity
// Get the site entity
$dql = "SELECT s FROM Site s WHERE s.shortName = ?1";
$sites = $entityManager->createQuery($dql)
->setParameter(
1,
(string) $role->ON_ENTITY
)
->getResult();

// /* Error checking: ensure each "site" refers to exactly
// * one site */
if (count($sites) !== 1) {
Expand All @@ -103,7 +104,8 @@
throw new Exception("Not a doctrine site");
}

//check that the role is not a duplicate (v4 data contaisn duplicates)
// Check that the role is not a duplicate
// (v4 data contains duplicates)
$ExistingUserRoles = $doctrineUser->getRoles();
$thisIsADuplicateRole=false;
foreach ($ExistingUserRoles as $role) {
Expand Down
Loading

0 comments on commit ae84cac

Please sign in to comment.