int intEndParam = intEnd.intValue();
int categoryID = intCategoryID.intValue();
String strOriginal = strSearch;
int beginIndex = 0;
KnowledgebaseList kblist = new KnowledgebaseList();
kblist.setSortMember(strSortMem);
Vector vec = new Vector();
CVDal cvdl = new CVDal(dataSource);
Collection colList = null;
try
{
if (customerViewFlag)
{
cvdl.setSqlQueryToNull();
String str = "select 'KBELEMENT' as Catkb,kb.kbid ID,kb.title Name, " + "kb.created DateCreated,kb.updated DateUpdated,kb.category " + "from knowledgebase kb where category=? and kb.publishToCustomerView='YES' union " + "select 'CATEGORY' as Catkb,cat.catid ID,cat.title Name, "
+ "cat.created DateCreated,cat.Modified DateUpdated,cat.parent " + "from individual indv,category cat where cat.parent=? and cat.publishToCustomerView='YES' ;";
cvdl.setSqlQuery(str);
cvdl.setInt(1, categoryID);
cvdl.setInt(2, categoryID);
colList = cvdl.executeQuery();
cvdl.clearParameters();
} else {
if (strSearch != null && strSearch.startsWith("ADVANCE:"))
{
strSearch = strSearch.substring(8);
String str = "create TEMPORARY TABLE kblistSearch " + strSearch;
cvdl.setSqlQueryToNull();
cvdl.setSqlQuery(str);
cvdl.executeUpdate();
cvdl.clearParameters();
String strQuery = "";
String sortType = "ASC";
if (charSort == 'A')
{
sortType = "ASC";
} else {
sortType = "DESC";
}
strQuery = "SELECT 'KBELEMENT' AS Catkb, kb.kbid AS ID, kb.title AS Name, " + "kb.created AS DateCreated, kb.updated AS DateUpdated, kb.category " + "FROM knowledgebase kb, kblistSearch kbsearch WHERE kbsearch.kbid=kb.kbid " + "ORDER BY '" + strSortMem + "' " + sortType;
cvdl.setSqlQueryToNull();
cvdl.setSqlQuery(strQuery);
colList = cvdl.executeQuery();
cvdl.clearParameters();
cvdl.setSqlQueryToNull();
cvdl.setSqlQuery("DROP TABLE kblistSearch");
cvdl.executeUpdate();
} else {
String sortType = "ASC";
if (charSort != 'A')
{
sortType = "DESC";
}
cvdl.setDynamicQuery("kb.allkb", sortType, strSortMem);
cvdl.setInt(1, categoryID);
cvdl.setInt(2, userID);
cvdl.setInt(3, categoryID);
cvdl.setInt(4, categoryID);
cvdl.setInt(5, userID);
cvdl.setInt(6, categoryID);
colList = cvdl.executeQuery();
cvdl.clearParameters();
}
}
} catch (Exception e) {
logger.debug(" [Exception] SupportListEJB.getKnowledgebaseList " + e);
} finally {
cvdl.destroy();
cvdl = null;
}
Iterator it = colList.iterator();
int i = 0;
if (colList.size() > 0)
{
while (it.hasNext())
{
i++;
HashMap hm = (HashMap)it.next();
int kbElementID = ((Long)hm.get("ID")).intValue();
try
{
IntMember intKbElementID = new IntMember("ID", kbElementID, 10, "", 'T', false, 10);
StringMember strName = new StringMember("Name", (String)hm.get("Name"), 10, "", 'T', true);
StringMember strCatKB = new StringMember("CatKB", (String)hm.get("Catkb"), 10, "", 'T', false);
Timestamp dtCreated = null;
Timestamp dtUpdated = null;
DateMember dmCreated = null;
DateMember dmUpdated = null;
String timezoneid = "EST";
if ((hm.get("DateCreated") != null))
{
dtCreated = (Timestamp)hm.get("DateCreated");
dmCreated = new DateMember("DateCreated", dtCreated, 10, "", 'T', false, 1, timezoneid);
} else {
dmCreated = new DateMember("DateCreated", null, 10, "", 'T', false, 1, timezoneid);
}
if ((hm.get("DateUpdated") != null))
{
dtUpdated = (Timestamp)hm.get("DateUpdated");
dmUpdated = new DateMember("DateUpdated", dtUpdated, 10, "", 'T', false, 1, timezoneid);
} else {
dmUpdated = new DateMember("DateUpdated", null, 10, "", 'T', false, 1, timezoneid);
}
KnowledgebaseListElement kblistElement = new KnowledgebaseListElement(kbElementID);
kblistElement.put("CatKBID", intKbElementID);
kblistElement.put("Name", strName);
kblistElement.put("DateCreated", dmCreated);
kblistElement.put("DateUpdated", dmUpdated);
kblistElement.put("CatKB", strCatKB);
StringBuffer stringbuffer = new StringBuffer("00000000000");
stringbuffer.setLength(11);
String s3 = (new Integer(i)).toString();
stringbuffer.replace(stringbuffer.length() - s3.length(), stringbuffer.length(), s3);
String s4 = stringbuffer.toString();
kblist.put(s4, kblistElement);
} catch (Exception e) {
logger.debug(" [Exception] SupportListEJB.getKnowldegebaseList " + e);
e.printStackTrace();
}
}
}
Vector rootPath = getCategoryRootPath(userID, categoryID);
kblist.setCustomerViewFlag(customerViewFlag);
kblist.setCategoryStructure(rootPath);
kblist.setTotalNoOfRecords(kblist.size());
kblist.setListType("Knowledgebase");
kblist.setBeginIndex(beginIndex);
kblist.setEndIndex(kblist.size());
return (kblist);
}