Switch to unified view

a/src/query/docseqdb.cpp b/src/query/docseqdb.cpp
...
...
28
DocSequenceDb::DocSequenceDb(RefCntr<Rcl::Query> q, const string &t, 
28
DocSequenceDb::DocSequenceDb(RefCntr<Rcl::Query> q, const string &t, 
29
                 RefCntr<Rcl::SearchData> sdata) 
29
                 RefCntr<Rcl::SearchData> sdata) 
30
    : DocSequence(t), m_q(q), m_sdata(sdata), m_fsdata(sdata),
30
    : DocSequence(t), m_q(q), m_sdata(sdata), m_fsdata(sdata),
31
      m_rescnt(-1), 
31
      m_rescnt(-1), 
32
      m_queryBuildAbstract(true),
32
      m_queryBuildAbstract(true),
33
      m_queryReplaceAbstract(false)
33
      m_queryReplaceAbstract(false),
34
      m_isFiltered(false),
35
      m_isSorted(false),
36
      m_needSetQuery(false)
34
{
37
{
35
}
38
}
36
39
37
DocSequenceDb::~DocSequenceDb() 
40
DocSequenceDb::~DocSequenceDb() 
38
{
41
{
...
...
55
    return m_fsdata->getDescription();
58
    return m_fsdata->getDescription();
56
}
59
}
57
60
58
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
61
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
59
{
62
{
63
    setQuery();
60
    if (sh) sh->erase();
64
    if (sh) sh->erase();
61
    return m_q->getDoc(num, doc);
65
    return m_q->getDoc(num, doc);
62
}
66
}
63
67
64
int DocSequenceDb::getResCnt()
68
int DocSequenceDb::getResCnt()
65
{
69
{
70
    setQuery();
66
    if (m_rescnt < 0) {
71
    if (m_rescnt < 0) {
67
    m_rescnt= m_q->getResCnt();
72
    m_rescnt= m_q->getResCnt();
68
    }
73
    }
69
    return m_rescnt;
74
    return m_rescnt;
70
}
75
}
71
76
72
string DocSequenceDb::getAbstract(Rcl::Doc &doc)
77
string DocSequenceDb::getAbstract(Rcl::Doc &doc)
73
{
78
{
79
    setQuery();
74
    if (!m_q->whatDb())
80
    if (!m_q->whatDb())
75
    return doc.meta[Rcl::Doc::keyabs];
81
    return doc.meta[Rcl::Doc::keyabs];
76
    string abstract;
82
    string abstract;
77
83
78
     if (m_queryBuildAbstract && (doc.syntabs || m_queryReplaceAbstract)) {
84
     if (m_queryBuildAbstract && (doc.syntabs || m_queryReplaceAbstract)) {
...
...
84
    return abstract.empty() ? doc.meta[Rcl::Doc::keyabs] : abstract;
90
    return abstract.empty() ? doc.meta[Rcl::Doc::keyabs] : abstract;
85
}
91
}
86
92
87
bool DocSequenceDb::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc) 
93
bool DocSequenceDb::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc) 
88
{
94
{
95
    setQuery();
89
    string udi;
96
    string udi;
90
    if (!FileInterner::getEnclosing(doc.url, doc.ipath, pdoc.url, pdoc.ipath,
97
    if (!FileInterner::getEnclosing(doc.url, doc.ipath, pdoc.url, pdoc.ipath,
91
                                    udi))
98
                                    udi))
92
        return false;
99
        return false;
93
    return m_q->whatDb()->getDoc(udi, pdoc);
100
    return m_q->whatDb()->getDoc(udi, pdoc);
94
}
101
}
95
102
96
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
103
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
97
{
104
{
105
    setQuery();
98
    return m_q->expand(doc);
106
    return m_q->expand(doc);
107
}
108
109
string DocSequenceDb::title()
110
{
111
    string qual;
112
    if (m_isFiltered && !m_isSorted)
113
  qual = string(" (") + o_filt_trans + string(")");
114
    else if (!m_isFiltered && m_isSorted)
115
  qual = string(" (") + o_sort_trans + string(")");
116
    else if (m_isFiltered && m_isSorted)
117
  qual = string(" (") + o_sort_trans + string(",") + o_filt_trans + string(")");
118
    return DocSequence::title() + qual;
99
}
119
}
100
120
101
bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs) 
121
bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs) 
102
{
122
{
103
    LOGDEB(("DocSequenceDb::setFiltSpec\n"));
123
    LOGDEB(("DocSequenceDb::setFiltSpec\n"));
...
...
112
        switch (fs.crits[i]) {
132
        switch (fs.crits[i]) {
113
        case DocSeqFiltSpec::DSFS_MIMETYPE:
133
        case DocSeqFiltSpec::DSFS_MIMETYPE:
114
        m_fsdata->addFiletype(fs.values[i]);
134
        m_fsdata->addFiletype(fs.values[i]);
115
        }
135
        }
116
    }
136
    }
137
  m_isFiltered = true;
117
    } else {
138
    } else {
118
    m_fsdata = m_sdata;
139
    m_fsdata = m_sdata;
140
  m_isFiltered = false;
119
    }
141
    }
120
    return m_q->setQuery(m_fsdata);
142
    m_needSetQuery = true;
143
    return true;
121
}
144
}
122
145
123
bool DocSequenceDb::setSortSpec(const DocSeqSortSpec &spec) 
146
bool DocSequenceDb::setSortSpec(const DocSeqSortSpec &spec) 
124
{
147
{
125
    LOGDEB(("DocSequenceDb::setSortSpec: fld [%s] %s\n", 
148
    LOGDEB(("DocSequenceDb::setSortSpec: fld [%s] %s\n", 
126
        spec.field.c_str(), spec.desc ? "desc" : "asc"));
149
        spec.field.c_str(), spec.desc ? "desc" : "asc"));
127
    if (spec.isNotNull()) {
150
    if (spec.isNotNull()) {
128
    m_q->setSortBy(spec.field, !spec.desc);
151
    m_q->setSortBy(spec.field, !spec.desc);
152
  m_isSorted = true;
129
    } else {
153
    } else {
130
    m_q->setSortBy(string(), true);
154
    m_q->setSortBy(string(), true);
155
  m_isSorted = false;
131
    }
156
    }
132
    return m_q->setQuery(m_fsdata);
157
    m_needSetQuery = true;
158
    return true;
133
}
159
}
134
160
135
bool DocSequenceDb::setQuery()
161
bool DocSequenceDb::setQuery()
136
{
162
{
163
    if (!m_needSetQuery)
164
  return true;
165
    m_rescnt = -1;
137
    return m_q->setQuery(m_fsdata);
166
    m_needSetQuery = !m_q->setQuery(m_fsdata);
167
    return !m_needSetQuery;
138
}
168
}