/** * @expectedException RackTablesError */ public function testUpdateLocationCircularReference() { // set A as the parent of B, and B as the parent of C commitLinkEntities('location', self::$locationa_id, 'location', self::$locationb_id); commitLinkEntities('location', self::$locationb_id, 'location', self::$locationc_id); // reversing the link between B and C should fail commitUpdateEntityLink('location', self::$locationb_id, 'location', self::$locationc_id, 'location', self::$locationc_id, 'location', self::$locationb_id); }
function updateRow() { assertUIntArg('row_id'); assertUIntArg('location_id', TRUE); assertStringArg('name'); commitUpdateObject($_REQUEST['row_id'], $_REQUEST['name'], NULL, NULL, NULL, NULL); global $pageno; if ($pageno == 'row') { updateObjectAttributes($_REQUEST['row_id']); } $rowData = spotEntity('row', $_REQUEST['row_id']); // location_id was submitted, but no link exists - create it if ($_REQUEST['location_id'] > 0 && !$rowData['location_id']) { commitLinkEntities('location', $_REQUEST['location_id'], 'row', $_REQUEST['row_id']); } // location_id was submitted, but it doesn't match the existing link - update it if ($_REQUEST['location_id'] > 0 && $_REQUEST['location_id'] != $rowData['location_id']) { commitUpdateEntityLink('location', $rowData['location_id'], 'row', $_REQUEST['row_id'], 'location', $_REQUEST['location_id'], 'row', $_REQUEST['row_id']); } // no parent_id was submitted, but a link exists - delete it if ($_REQUEST['location_id'] == 0 && $rowData['location_id']) { commitUnlinkEntities('location', $rowData['location_id'], 'row', $_REQUEST['row_id']); } showFuncMessage(__FUNCTION__, 'OK', array($_REQUEST['name'])); }
function addVmToParent($vms, $newmachine) { $search_for_child = "select id from RackObject WHERE name REGEXP '^ *{$vms}\\\\.'"; unset($result); $result = usePreparedSelectBlade($search_for_child); $resultarray = $result->fetchAll(PDO::FETCH_ASSOC); $child = $resultarray[0]['id']; if (!empty($child)) { //make sure the association doesn't exist already or deal with it $current_container = "SELECT parent_entity_id from EntityLink WHERE child_entity_id = {$child}"; unset($result); $result = usePreparedSelectBlade($current_container); $resultarray = $result->fetchAll(PDO::FETCH_ASSOC); $current_parent = $resultarray[0]['parent_entity_id']; if ($current_parent != $newmachine && !empty($current_parent)) { commitUpdateEntityLink('object', $current_parent, 'object', $child, 'object', $newmachine, 'object', $child); } else { if (empty($current_parent)) { commitLinkEntities('object', $newmachine, 'object', $child); } } } else { echo "WARNING: The {$vms} VM does not exist for this Parent \n"; } }