/** * uSort compare method * * * @param Comparable $activityA * @param Comparable $activityB * * @return '1' if $activityB > $activityA, -1 if $activityB is lower, 0 if equals */ public static function compare(Comparable $cerrA, Comparable $cerrB) { if ($cerrA->severity < $cerrB->severity) { if (self::$logger->isDebugEnabled()) { self::$logger->debug("ConsistencyError2.compare FALSE (" . $cerrA->bugId . '-' . $cerrA->getLiteralSeverity() . " < " . $cerrB->bugId . '-' . $cerrB->getLiteralSeverity() . ")"); } return 1; } else { if ($cerrA->severity > $cerrB->severity) { if (self::$logger->isDebugEnabled()) { self::$logger->debug("ConsistencyError2.compare TRUE (" . $cerrA->bugId . '-' . $cerrA->getLiteralSeverity() . " > " . $cerrB->bugId . '-' . $cerrB->getLiteralSeverity() . ")"); } return -1; } } if (0 == $cerrA->userId) { return 1; } else { if (0 == $cerrB->userId) { return -1; } } if ($cerrA->bugId > $cerrB->bugId) { if (self::$logger->isDebugEnabled()) { self::$logger->debug("ConsistencyError2.compare FALSE (" . $cerrA->bugId . " > " . $cerrB->bugId . ")"); } return 1; } else { if (self::$logger->isDebugEnabled()) { self::$logger->debug("ConsistencyError2.compare TRUE (" . $cerrA->bugId . " < " . $cerrB->bugId . ")"); } return -1; } return 0; }
public static function sortDuckArrays(Comparable $duck1, Comparable $duck2) { return $duck1->compareTo($duck2); }
/** * Sort by asc * @param Issue $issueA * @param Issue $issueB * @return int 1 if $issueB is higher priority, -1 if $issueB is lower, 0 if equals */ public static function compare(Comparable $issueA, Comparable $issueB) { // if IssueB constrains IssueA, then IssueB is higher priority $AconstrainsList = $issueA->getRelationships(); $AconstrainsList = $AconstrainsList['' . Constants::$relationship_constrains]; $BconstrainsList = $issueB->getRelationships(); $BconstrainsList = $BconstrainsList['' . Constants::$relationship_constrains]; if (in_array($issueA->bugId, $BconstrainsList)) { // B constrains A #if (self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId < $issueB->bugId (B constrains A)"); #} return 1; } else { if (in_array($issueB->bugId, $AconstrainsList)) { // A constrains B #if (self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId > $issueB->bugId (A constrains B)"); #} return -1; } } // Tasks currently open are higher priority if ($issueB->currentStatus == Constants::$status_open && $issueA->currentStatus != Constants::$status_open) { #if (self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId < $issueB->bugId (status_openned)"); #} return 1; } else { if ($issueA->currentStatus == Constants::$status_open && $issueB->currentStatus != Constants::$status_open) { #if (self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId > $issueB->bugId (status_openned)"); #} return -1; } } // the one that has NO deadLine is lower priority if (NULL == $issueA->getDeadLine() && NULL != $issueB->getDeadLine()) { #if (self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId < $issueB->bugId (A no deadline)"); #} return 1; } else { if (NULL != $issueA->getDeadLine() && NULL == $issueB->getDeadLine()) { #if (self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId > $issueB->bugId (B no deadline)"); #} return -1; } } // the soonest deadLine has priority if ($issueA->getDeadLine() > $issueB->getDeadLine()) { #if (self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId < $issueB->bugId (deadline)"); #} return 1; } else { if ($issueA->getDeadLine() < $issueB->getDeadLine()) { #if (self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId > $issueB->bugId (deadline)"); #} return -1; } } // Tasks in feedback are lower priority if ($issueA->currentStatus == Constants::$status_feedback && $issueB->currentStatus != Constants::$status_feedback) { #if(self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId < $issueB->bugId (status_feedback)"); #} return 1; } else { if ($issueB->currentStatus == Constants::$status_feedback && $issueA->currentStatus != Constants::$status_feedback) { #if(self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId > $issueB->bugId (status_feedback)"); #} return -1; } } // if same deadLine, check priority attribute if ($issueA->priority < $issueB->priority) { #if(self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId < $issueB->bugId (priority attr)"); #} return 1; } else { if ($issueA->priority > $issueB->priority) { #if(self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId > $issueB->bugId (priority attr)"); #} return -1; } } // if same deadLine, same priority: check severity attribute if ($issueA->severity < $issueB->severity) { #if(self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId < $issueB->bugId (severity attr)"); #} return 1; } else { if ($issueA->severity > $issueB->severity) { #if(self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId > $issueB->bugId (severity attr)"); #} return -1; } } // if IssueA constrains nobody, and IssueB constrains IssueX, then IssueB is higher priority if (count($AconstrainsList) < count($BconstrainsList)) { // B constrains more people, so B is higher priority #if(self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId < $issueB->bugId (B constrains more people)"); #} return 1; } else { if (count($AconstrainsList) > count($BconstrainsList)) { // A constrains more people, so A is higher priority #if(self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId > $issueB->bugId (A constrains more people)"); #} return -1; } } #if(self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("no important diff found, so we compare the bugid : $issueA->bugId <=> $issueB->bugId"); #} // Lower if the bug id, higher is the priority if ($issueA->bugId > $issueB->bugId) { #if(self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId > $issueB->bugId (B was created first)"); #} return 1; } else { if ($issueA->bugId < $issueB->bugId) { #if(self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId < $issueB->bugId (A was created first)"); #} return -1; } } // same - same #if(self::$logger->isEnabledFor(LoggerLevel::getLevelTrace())) { # self::$logger->trace("compare $issueA->bugId = $issueB->bugId (A and B are equal ?!)"); #} return 0; }