|
a/src/query/docseqdb.cpp |
|
b/src/query/docseqdb.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.7 2008-09-29 08:59:20 dockes Exp $ (C) 2005 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: docseqdb.cpp,v 1.8 2008-09-29 11:33:55 dockes Exp $ (C) 2005 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
20 |
#include <math.h>
|
20 |
#include <math.h>
|
21 |
#include <time.h>
|
21 |
#include <time.h>
|
22 |
|
22 |
|
23 |
#include "docseqdb.h"
|
23 |
#include "docseqdb.h"
|
24 |
#include "rcldb.h"
|
24 |
#include "rcldb.h"
|
|
|
25 |
#include "debuglog.h"
|
25 |
|
26 |
|
26 |
DocSequenceDb::DocSequenceDb(RefCntr<Rcl::Query> q, const string &t,
|
27 |
DocSequenceDb::DocSequenceDb(RefCntr<Rcl::Query> q, const string &t,
|
27 |
RefCntr<Rcl::SearchData> sdata)
|
28 |
RefCntr<Rcl::SearchData> sdata)
|
28 |
: DocSequence(t), m_q(q), m_sdata(sdata), m_rescnt(-1)
|
29 |
: DocSequence(t), m_q(q), m_sdata(sdata), m_rescnt(-1), m_filt(false)
|
29 |
{
|
30 |
{
|
30 |
}
|
31 |
}
|
31 |
|
32 |
|
32 |
DocSequenceDb::~DocSequenceDb()
|
33 |
DocSequenceDb::~DocSequenceDb()
|
33 |
{
|
34 |
{
|
|
... |
|
... |
35 |
|
36 |
|
36 |
bool DocSequenceDb::getTerms(vector<string>& terms,
|
37 |
bool DocSequenceDb::getTerms(vector<string>& terms,
|
37 |
vector<vector<string> >& groups,
|
38 |
vector<vector<string> >& groups,
|
38 |
vector<int>& gslks)
|
39 |
vector<int>& gslks)
|
39 |
{
|
40 |
{
|
40 |
return m_sdata->getTerms(terms, groups, gslks);
|
41 |
return m_fsdata->getTerms(terms, groups, gslks);
|
41 |
}
|
42 |
}
|
42 |
|
43 |
|
43 |
string DocSequenceDb::getDescription()
|
44 |
string DocSequenceDb::getDescription()
|
44 |
{
|
45 |
{
|
45 |
return m_sdata->getDescription();
|
46 |
return m_fsdata->getDescription();
|
46 |
}
|
47 |
}
|
47 |
|
48 |
|
48 |
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
|
49 |
bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
|
49 |
{
|
50 |
{
|
50 |
if (sh) sh->erase();
|
51 |
if (sh) sh->erase();
|
|
... |
|
... |
71 |
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
|
72 |
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
|
72 |
{
|
73 |
{
|
73 |
return m_q->expand(doc);
|
74 |
return m_q->expand(doc);
|
74 |
}
|
75 |
}
|
75 |
|
76 |
|
|
|
77 |
bool DocSequenceDb::setFiltSpec(DocSeqFiltSpec &fs)
|
|
|
78 |
{
|
|
|
79 |
if (!fs.isNotNull()) {
|
|
|
80 |
m_fsdata = m_sdata;
|
|
|
81 |
m_filt = false;
|
|
|
82 |
return m_q->setQuery(m_sdata);
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
// We build a search spec by adding a filtering layer to the base one.
|
|
|
86 |
m_fsdata = RefCntr<Rcl::SearchData>(new Rcl::SearchData(Rcl::SCLT_AND));
|
|
|
87 |
Rcl::SearchDataClauseSub *cl =
|
|
|
88 |
new Rcl::SearchDataClauseSub(Rcl::SCLT_SUB, m_sdata);
|
|
|
89 |
m_fsdata->addClause(cl);
|
|
|
90 |
|
|
|
91 |
for (unsigned int i = 0; i < fs.crits.size(); i++) {
|
|
|
92 |
switch (fs.crits[i]) {
|
|
|
93 |
case DocSeqFiltSpec::DSFS_MIMETYPE:
|
|
|
94 |
m_fsdata->addFiletype(fs.values[i]);
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
m_filt = true;
|
|
|
98 |
return m_q->setQuery(m_fsdata);
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
// Need a way to access the translations for filtered ...
|
|
|
102 |
string DocSequenceDb::title()
|
|
|
103 |
{
|
|
|
104 |
LOGDEB(("DOcSequenceDb::title()\n"));
|
|
|
105 |
return m_filt ? DocSequence::title() + " (filtered)" : DocSequence::title();
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
// TBDone
|
|
|
109 |
bool DocSequenceDb::setSortSpec(DocSeqSortSpec &sortspec)
|
|
|
110 |
{
|
|
|
111 |
return true;
|
|
|
112 |
}
|