Go to the documentation of this file.00001
00010 #include "DQMServices/ClientConfig/interface/QTestStatusChecker.h"
00011 #include "DQMServices/Core/interface/MonitorElement.h"
00012 #include <iostream>
00013
00014 QTestStatusChecker::QTestStatusChecker(){
00015
00016 }
00017
00018 QTestStatusChecker::~QTestStatusChecker(){
00019 }
00020
00021 std::pair<std::string,std::string> QTestStatusChecker::checkGlobalStatus(DQMStore * bei){
00022 std::pair<std::string,std::string> statement;
00023 int status= bei->getStatus();
00024 switch(status){
00025 case dqm::qstatus::ERROR:
00026 statement.first ="Errors detected in quality tests";
00027 statement.second="red";
00028 break;
00029 case dqm::qstatus::WARNING:
00030 statement.first ="Warnings detected in quality tests";
00031 statement.second="orange";
00032 break;
00033 case dqm::qstatus::OTHER:
00034 statement.first="Some tests did not run";
00035 statement.second="black";
00036 break;
00037 default:
00038 statement.first="No problems detected in quality tests ";
00039 statement.second="green";
00040 }
00041
00042 return statement;
00043 }
00044
00045 std::map< std::string, std::vector<std::string> > QTestStatusChecker::checkDetailedStatus(DQMStore * bei){
00046
00047 std::vector<std::string> allPathNames=this->fullPathNames(bei);
00048 detailedWarnings.clear();
00049
00050 this->processAlarms(allPathNames,bei);
00051 return detailedWarnings;
00052 }
00053
00054
00055 void QTestStatusChecker::processAlarms(std::vector<std::string> allPathNames, DQMStore * bei){
00056
00057 for(std::vector<std::string>::iterator fullMePath=allPathNames.begin();fullMePath!=allPathNames.end(); ++fullMePath ){
00058
00059 MonitorElement * me=0;
00060 me= bei->get(*fullMePath);
00061
00062 if(me){
00063 std::vector<QReport *> report;
00064 std::string colour;
00065
00066 if (me->hasError()){
00067 colour="red";
00068 report= me->getQErrors();
00069 }
00070 if( me->hasWarning()){
00071 colour="orange";
00072 report= me->getQWarnings();
00073 }
00074 if(me->hasOtherReport()){
00075 colour="black";
00076 report= me->getQOthers();
00077 }
00078 for(std::vector<QReport *>::iterator itr=report.begin(); itr!=report.end();++itr ){
00079 std::string text= (*fullMePath) + (*itr)->getMessage();
00080 std::vector<std::string> messageList;
00081
00082 if( detailedWarnings.find(colour) == detailedWarnings.end()){
00083
00084 messageList.push_back(text);
00085 detailedWarnings[colour]=messageList;
00086
00087 }else{
00088
00089 messageList=detailedWarnings[colour];
00090 messageList.push_back(text);
00091 detailedWarnings[colour]=messageList;
00092
00093 }
00094 }
00095
00096 }
00097 }
00098
00099 }
00100
00101
00102 std::vector<std::string> QTestStatusChecker::fullPathNames(DQMStore * bei){
00103
00104
00105 std::vector<std::string> contents;
00106 std::vector<std::string> contentVec;
00107 bei->getContents(contentVec);
00108 for (std::vector<std::string>::iterator it = contentVec.begin();
00109 it != contentVec.end(); it++) {
00110
00111 std::string::size_type dirCharNumber = it->find( ":", 0 );
00112 std::string dirName=it->substr(0 , dirCharNumber);
00113 dirName+= "/";
00114 std::string meCollectionName=it->substr(dirCharNumber+1);
00115
00116 std::string reminingNames=meCollectionName;
00117 bool anotherME=true;
00118 while(anotherME){
00119 if(reminingNames.find(",") == std::string::npos) anotherME =false;
00120 std::string::size_type singleMeNameCharNumber= reminingNames.find( ",", 0 );
00121 std::string singleMeName=reminingNames.substr(0 , singleMeNameCharNumber );
00122 std::string fullpath=dirName + singleMeName;
00123 contents.push_back(fullpath);
00124 reminingNames=reminingNames.substr(singleMeNameCharNumber+1);
00125 }
00126 }
00127
00128 return contents;
00129
00130 }