Changeset 3956

Show
Ignore:
Timestamp:
Sat Oct 8 11:48:38 2005
Author:
mugur
Message:

fixed ticket:1449 - Implement "List ArticleTopics"

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/campsite/implementation/parser/parser/parser.cpp

    r3710 r3956  
    52 52 using std::endl;  
    53 53  
    54   #define ROOT_STATEMENTS ST_PUBLICATION ", " ST_ISSUE ", " ST_SECTION ", "\  
    55   ST_ARTICLE ", " ST_LIST ", " ST_INCLUDE ", " ST_IF ", " ST_URLPARAMETERS ", "\  
    56   ST_FORMPARAMETERS ", " ST_PRINT ", " ST_DATE ", " ST_LOCAL ", "\  
    57   ST_SUBSCRIPTION ", " ST_EDIT ", " ST_SELECT ", " ST_USER ", " ST_SEARCH ", " ST_TOPIC  
    58    
    59   #define LISSUE_STATEMENTS ST_LIST ", " ST_SECTION ", " ST_ARTICLE ", "\  
    60   ST_URLPARAMETERS ", " ST_FORMPARAMETERS ", " ST_PRINT ST_DATE ", "\  
    61   ST_INCLUDE ", " ST_IF ", " ST_LOCAL ", " ST_SUBSCRIPTION ", " ST_EDIT\  
    62   ", " ST_SELECT ", " ST_USER ", " ST_SEARCH ", " ST_TOPIC  
    63    
    64   #define LSECTION_STATEMENTS ST_LIST ", " ST_ARTICLE ", " ST_URLPARAMETERS\  
    65   ", " ST_FORMPARAMETERS ", " ST_PRINT ST_DATE ", " ST_INCLUDE ", " ST_IF\  
    66   "," ST_LOCAL ", " ST_SUBSCRIPTION ", " ST_EDIT ", " ST_SELECT ", " ST_USER\  
    67   ", " ST_SEARCH ", " ST_TOPIC  
    68    
    69   #define LARTICLE_STATEMENTS ST_URLPARAMETERS ", " ST_FORMPARAMETERS ", "\  
    70   ST_PRINT ", " ST_DATE ", " ST_INCLUDE ", " ST_IF ", " ST_LOCAL ", "\  
    71   ST_SUBSCRIPTION ", " ST_EDIT ", " ST_SELECT ", " ST_USER ", " ST_SEARCH  
    72    
    73   #define LIST_STATEMENTS ST_ISSUE ", " ST_SECTION ", " ST_ARTICLE ", "\  
    74   ST_SEARCHRESULT  
      54 #define ROOT_STATEMENTS ST_LANGUAGE ", " ST_PUBLICATION ", " ST_ISSUE ", " ST_SECTION \  
      55 ", " ST_ARTICLE ", " ST_TOPIC ", " ST_INCLUDE ", " ST_IF ", " ST_LOCAL ", " ST_WITH \  
      56 ", " ST_LIST " " ST_ISSUE ", " ST_LIST " " ST_SECTION ", " ST_LIST " " ST_ARTICLE \  
      57 ", " ST_LIST " " ST_SEARCHRESULT ", " ST_LIST " " ST_SUBTITLE ", " ST_LIST " " ST_ARTICLETOPIC \  
      58 ", " ST_URLPARAMETERS ", " ST_URI ", " ST_URIPATH ", " ST_FORMPARAMETERS ", " ST_PRINT \  
      59 ", " ST_DATE ", " ST_SUBSCRIPTION ", " ST_EDIT ", " ST_SELECT ", " ST_USER ", " ST_SEARCH  
      60  
      61 #define LISSUE_STATEMENTS ST_SECTION ", " ST_ARTICLE ", " ST_TOPIC ", " ST_INCLUDE ", " ST_IF \  
      62 ", " ST_LOCAL ", " ST_WITH ", " ST_LIST " " ST_SECTION ", " ST_LIST " " ST_ARTICLE \  
      63 ", " ST_LIST " " ST_SEARCHRESULT ", " ST_LIST " " ST_SUBTITLE ", " ST_LIST " " ST_ARTICLETOPIC \  
      64 ", " ST_URLPARAMETERS ", " ST_URI ", " ST_URIPATH ", " ST_FORMPARAMETERS ", " ST_PRINT \  
      65 ", " ST_DATE ", " ST_SUBSCRIPTION ", " ST_EDIT ", " ST_SELECT ", " ST_USER ", " ST_SEARCH  
      66  
      67 #define LSECTION_STATEMENTS ST_ARTICLE ", " ST_TOPIC ", " ST_INCLUDE ", " ST_IF ", " ST_LOCAL \  
      68 ", " ST_WITH ", " ST_LIST " " ST_ARTICLE ", " ST_LIST " " ST_SEARCHRESULT \  
      69 ", " ST_LIST " " ST_SUBTITLE ", " ST_LIST " " ST_ARTICLETOPIC ", " ST_URLPARAMETERS \  
      70 ", " ST_URI ", " ST_URIPATH ", " ST_FORMPARAMETERS ", " ST_PRINT ", " ST_DATE \  
      71 ", " ST_SUBSCRIPTION ", " ST_EDIT ", " ST_SELECT ", " ST_USER ", " ST_SEARCH  
      72  
      73 #define LARTICLE_STATEMENTS ST_TOPIC ", " ST_INCLUDE ", " ST_IF ", " ST_LOCAL ", " ST_WITH \  
      74 ", " ST_LIST " " ST_ARTICLETOPIC ", " ST_URLPARAMETERS ", " ST_URI ", " ST_URIPATH \  
      75 ", " ST_FORMPARAMETERS ", " ST_PRINT ", " ST_DATE ", " ST_SUBSCRIPTION ", " ST_EDIT \  
      76 ", " ST_SELECT ", " ST_USER ", " ST_SEARCH  
    75 77  
    76 78 #define LV_ROOT 1  
     
    390 392 {  
    391 393     if (level & LV_LARTICLE || level & LV_LSUBTITLE)  
    392           return ST_SEARCH;  
      394         return ST_SEARCH ", " ST_ARTICLETOPIC;  
    392 394     else if (level & LV_LSECTION)  
    393           return ST_ARTICLE ", " ST_SEARCH;  
      395         return ST_ARTICLE ", " ST_SEARCH ", " ST_ARTICLETOPIC;  
    393 395     else if (level & LV_LISSUE)  
    394           return ST_SECTION ", " ST_ARTICLE ", " ST_SEARCH;  
      396         return ST_SECTION ", " ST_ARTICLE ", " ST_SEARCH ", " ST_ARTICLETOPIC;  
    394 396     else if (level & LV_ROOT)  
    395           return ST_ISSUE ", " ST_SECTION ", " ST_ARTICLE ", " ST_SEARCH;  
      397         return ST_ISSUE ", " ST_SECTION ", " ST_ARTICLE ", " ST_SEARCH ", " ST_ARTICLETOPIC;  
    395 397     else  
    396 398         return "";  
     
    1061 1063 inline int CParser::HList(CActionList& al, int level, int sublevel)  
    1062 1064 {  
    1063       if (level >= LV_LARTICLE)  
    1064           FatalPError(parse_err, PERR_WRONG_STATEMENT, MODE_PARSE,  
    1065                       LARTICLE_STATEMENTS, lex.prevLine(), lex.prevColumn());  
    1066 1065     lint lines = 0, columns = 0;  
    1067 1066     RequireAtom(l);  
     
    1085 1084         RequireAtom(l);  
    1086 1085     }  
    1087       // check for modifier (Issue, Section, Article, SearchResult, Subtitle)  
      1086     // check for modifier (Issue, Section, Article, SearchResult, Subtitle, ArticleTopic)  
    1087 1086     st = (const CStatement*)l->atom();  
      1087     if (level >= LV_LARTICLE && st->id() != CMS_ST_ARTICLETOPIC)  
      1088         FatalPError(parse_err, PERR_WRONG_STATEMENT, MODE_PARSE,  
      1089                     LARTICLE_STATEMENTS, lex.prevLine(), lex.prevColumn());  
    1088 1090     if (!CActList::validModifier(st->id()))  
    1089 1091     {  
    1113 1115     l = lex.getLexem();  
    1114 1116     DEBUGLexem("hlist1", l);  
    1115       while (mod != CMS_ST_SEARCHRESULT && mod != CMS_ST_SUBTITLE  
      1117     while (mod != CMS_ST_SEARCHRESULT && mod != CMS_ST_SUBTITLE && mod != CMS_ST_ARTICLETOPIC  
    1115 1117            && (l->res() == CMS_LEX_IDENTIFIER || (IsTopicStatement(l) && mod == CMS_ST_ARTICLE)))  
    1116 1118     {  
  • trunk/campsite/implementation/parser/parser/lex.cpp

    r2018 r3956  
    790 790     this->insert(pcoSt);  
    791 791  
      792     // ArticleTopic statement  
      793     pcoSt = new CStatement(CMS_ST_ARTICLETOPIC, ST_ARTICLETOPIC);  
      794  
      795     pcoCtx = new CStatementContext(CMS_CT_LIST);  
      796     pcoSt->insertCtx(pcoCtx);  
      797  
      798     this->insert(pcoSt);  
      799  
    792 800     CLOSE_TRY  
    793 801     CATCH(InvalidValue &rcoEx)  
  • trunk/campsite/implementation/parser/parser/actions.cpp

    r3878 r3956  
    581 581     insert(CMS_ST_SEARCHRESULT);  
    582 582     insert(CMS_ST_SUBTITLE);  
      583     insert(CMS_ST_ARTICLETOPIC);  
    583 584 }  
    584 585  
     
    826 827 {  
    827 828     CParameterList::iterator pl_i;  
    828       if (modifier != CMS_ST_SEARCHRESULT)  
      829     if (modifier != CMS_ST_SEARCHRESULT && modifier != CMS_ST_ARTICLETOPIC)  
    828 829     {  
    829 830         string table;  
     
    846 847             s += string(", Articles.ArticleOrder asc");  
    847 848     }  
    848       else // modifier == CMS_ST_SEARCHRESULT  
      849     if (modifier == CMS_ST_SEARCHRESULT)  
    848 849     {  
    849 850         s = " order by Articles.IdPublication asc, ArticleIndex.IdLanguage desc";  
     
    942 943             prefix = "Articles.";  
    943 944         }  
    944           else if (modifier == CMS_ST_SEARCHRESULT)  
      945         if (modifier == CMS_ST_SEARCHRESULT)  
    944 945         {  
    945 946             WriteSrcParam(where, lc, table);  
     
    951 952             }  
    952 953         }  
    953           else  
      954         if (modifier == CMS_ST_ISSUE || modifier == CMS_ST_SECTION)  
      955         {  
    954 956             WriteModParam(where, lc, table);  
      957         }  
      958         if (modifier == CMS_ST_ARTICLETOPIC)  
      959         {  
      960             stringstream buf;  
      961             buf << " where NrArticle = " << lc.Article();  
      962             where = buf.str();  
      963             table = "ArticleTopics";  
      964         }  
    955 965         if (modifier == CMS_ST_SEARCHRESULT && lc.SearchAnd())  
    956 966         {  
     
    961 971         WriteOrdParam(order);  
    962 972         WriteLimit(limit, lc);  
      973          
    963 974         if (modifier == CMS_ST_SEARCHRESULT)  
    964 975             fields = "select NrArticle, MAX(Articles.IdLanguage), Articles.IdPublication";  
    965           else if (modifier == CMS_ST_ARTICLE)  
      976         if (modifier == CMS_ST_ARTICLE)  
    965 976             fields = "select Number, MAX(Articles.IdLanguage), IdPublication";  
    966           else  
      977         if (modifier == CMS_ST_ISSUE || modifier == CMS_ST_SECTION || modifier == CMS_ST_SUBTITLE)  
    966 977             fields = "select Number, MAX(IdLanguage), IdPublication";  
      978         if (modifier == CMS_ST_ARTICLETOPIC)  
      979             fields = "select TopicId";  
      980          
    967 981         if (modifier == CMS_ST_ARTICLE || modifier == CMS_ST_SEARCHRESULT)  
    968 982             fields += ", Articles.NrIssue, Articles.NrSection";  
    969           else if (modifier == CMS_ST_SECTION)  
      983         if (modifier == CMS_ST_SECTION)  
    969 983             fields += ", NrIssue";  
    970           string grfield = (modifier == CMS_ST_SEARCHRESULT ? "NrArticle" : "Number");  
    971           string coQuery = fields + string(" from ") + table + where + " group by " + grfield  
    972                            + having + order + limit;  
      984         string group;  
      985         if (modifier == CMS_ST_SEARCHRESULT)  
      986         {  
      987             group = " group by NrArticle";  
      988         }  
      989         if (modifier == CMS_ST_ISSUE || modifier == CMS_ST_SECTION || modifier == CMS_ST_ARTICLE)  
      990         {  
      991             group = " group by Number";  
      992         }  
      993         string coQuery = fields + " from " + table + where + group + having + order + limit;  
    973 994         DEBUGAct("takeAction()", coQuery.c_str(), fs);  
    974 995         SQLQuery(&m_coSql, coQuery.c_str());  
    1010 1031             if ((row = mysql_fetch_row(*res)) == NULL)  
    1011 1032                 break;  
    1012               lc.SetLanguage(strtol(row[1], 0, 10));  
    1013               lc.SetPublication(strtol(row[2], 0, 10));  
    1014               if (modifier != CMS_ST_ISSUE)  
    1015                   lc.SetIssue(strtol(row[3], 0, 10));  
    1016               if (modifier == CMS_ST_ARTICLE || modifier == CMS_ST_SEARCHRESULT)  
    1017                   lc.SetSection(strtol(row[4], 0, 10));  
    1018               SetContext(lc, strtol(row[0], 0, 10));  
      1033             if (modifier != CMS_ST_ARTICLETOPIC)  
      1034             {  
      1035                 lc.SetLanguage(strtol(row[1], 0, 10));  
      1036                 lc.SetPublication(strtol(row[2], 0, 10));  
      1037                 if (modifier != CMS_ST_ISSUE)  
      1038                     lc.SetIssue(strtol(row[3], 0, 10));  
      1039                 if (modifier == CMS_ST_ARTICLE || modifier == CMS_ST_SEARCHRESULT)  
      1040                     lc.SetSection(strtol(row[4], 0, 10));  
      1041                 SetContext(lc, strtol(row[0], 0, 10));  
      1042             }  
      1043             else  
      1044             {  
      1045                 lc.SetTopic(strtol(row[0], 0, 10));  
      1046             }  
    1019 1047         }  
    1020 1048         else  
  • trunk/campsite/implementation/parser/parser/lex.h

    r1549 r3956  
    89 89 #define CMS_ST_URIPATH 42  
    90 90 #define CMS_ST_URI 43  
      91 #define CMS_ST_ARTICLETOPIC 44  
    91 92  
    92 93 // statement names  
    134 135 #define ST_URIPATH "URIPath"  
    135 136 #define ST_URI "URI"  
      137 #define ST_ARTICLETOPIC "ArticleTopic"  
    136 138  
    137 139 // The lexem returned by lex class