import java.io.*;
import java.sql.*;
import java.util.*;
+import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import mir.misc.*;
import mir.entity.*;
import mir.storage.*;
-import mir.servlet.ServletModuleException;
import mircoders.entity.*;
import mircoders.storage.*;
public class ServletModuleLinksImcs extends ServletModule
{
+ private ModuleLanguage languageModule;
+
// Singelton / Kontruktor
private static ServletModuleLinksImcs instance = new ServletModuleLinksImcs();
public static ServletModule getInstance() { return instance; }
try {
mainModule = new ModuleLinksImcs(DatabaseLinksImcs.getInstance());
+ languageModule = new ModuleLanguage(DatabaseLanguage.getInstance());
} catch (StorageObjectException e) {
theLog.printDebugInfo("ServletModuleLinksImcs konnte nicht initialisiert werden");
}
throws ServletModuleException {
try {
SimpleHash modelRoot = new SimpleHash();
- EntityList theList;
+ EntityList theParentList;
+ EntityList theLanguageList;
int offset = 0;
- theList = mainModule.getByWhereClause("to_parent_id=NULL", offset);
+ theParentList = mainModule.getByWhereClause("to_parent_id=NULL", "title", offset, 1000);
+ theLanguageList = languageModule.getByWhereClause(null, "name", 0);
+
modelRoot.put("new", "1");
- modelRoot.put("imcsparentlist",HTMLTemplateProcessor.makeSimpleList(theList));
+ modelRoot.put("parentlist",HTMLTemplateProcessor.makeSimpleList(theParentList));
+ modelRoot.put("languagelist",HTMLTemplateProcessor.makeSimpleList(theLanguageList));
- if (theList == null || theList.getCount() == 0 || theList.getCount()>1){
+ if (theParentList == null || theParentList.getCount() == 0 || theParentList.getCount()>1){
HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateObjektString, modelRoot, res.getWriter());
-
} else {
deliver(req, res, modelRoot, templateObjektString);
}
throws ServletModuleException {
try {
- theLog.printDebugInfo("-- links_imcs_list: list");
+ SimpleHash modelRoot = new SimpleHash();
EntityList theParentList;
EntityList theImcsList;
- SimpleHash modelRoot = new SimpleHash();
+ EntityList theLanguageList;
String offsetParam = req.getParameter("offset");
- String where ="";
- int offset=0;
- PrintWriter out = res.getWriter();
+ String where = "";
+ String offset = "";
+ PrintWriter out = res.getWriter();
+
+ // Parameter auswerten
+ String query_text = req.getParameter("query_text");
+ modelRoot.put("query_text",query_text);
+ if (query_text!=null) modelRoot.put("query_text_encoded",URLEncoder.encode(query_text));
+ String query_field = req.getParameter("query_field");
+ modelRoot.put("query_field",query_field);
+ String parent = req.getParameter("to_parent_id");
+ modelRoot.put("to_parent_id",parent);
+ String language = req.getParameter("to_language");
+ modelRoot.put("to_language",language);
+ modelRoot.put("language", getLanguage(req));
+
+ String whereClause=""; boolean isFirst=true;
+ if (query_text!=null && !query_text.equalsIgnoreCase("")) {
+ whereClause += "lower("+query_field+") like lower('%"+query_text+"%')"; isFirst=false;}
+ if (parent != null && !parent.equals("")) {
+ if (isFirst==false) whereClause+=" and ";
+ whereClause += "to_parent_id='"+parent+"'";
+ isFirst=false;
+ }
+ if (language != null && !language.equals("")) {
+ if (isFirst==false) whereClause+=" and ";
+ whereClause += "to_language='"+language+"'";
+ isFirst=false;
+ }
// hier offsetcode bearbeiten
if (offsetParam != null && !offsetParam.equals("")){
- offset = Integer.parseInt(offsetParam);
+ offset = offsetParam;
}
if (req.getParameter("next") != null){
- offset=Integer.parseInt(req.getParameter("nextoffset"));
+ offset= req.getParameter("nextoffset");
} else {
if (req.getParameter("prev") != null){
- offset = Integer.parseInt(req.getParameter("prevoffset"));
+ offset = req.getParameter("prevoffset");
}
}
- theParentList = mainModule.getByWhereClause("to_parent_id=NULL", offset);
- theImcsList = mainModule.getByWhereClause(null, offset);
+
+ if (offset==null || offset.equals("")) offset="0";
+ modelRoot.put("offset",(new Integer(offset)).toString());
+
+ theParentList = mainModule.getByWhereClause("to_parent_id=NULL", "title", 0, 1000);
+ theImcsList = mainModule.getByWhereClause(whereClause, "title", (new Integer(offset)).intValue());
+ theLanguageList = languageModule.getByWhereClause(null, "name", 0);
modelRoot.put("parentlist",HTMLTemplateProcessor.makeSimpleList(theParentList));
modelRoot.put("imcslist",HTMLTemplateProcessor.makeSimpleList(theImcsList));
+ modelRoot.put("languagelist",HTMLTemplateProcessor.makeSimpleList(theLanguageList));
+ modelRoot.put("count", (new Integer(theImcsList.getCount())).toString());
+ modelRoot.put("from", (new Integer(theImcsList.getFrom())).toString());
+ modelRoot.put("to", (new Integer(theImcsList.getTo())).toString());
+ if (theImcsList.hasNextBatch())
+ modelRoot.put("next", (new Integer(theImcsList.getNextBatch())).toString());
+ if (theImcsList.hasPrevBatch())
+ modelRoot.put("prev", (new Integer(theImcsList.getPrevBatch())).toString());
+
HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, modelRoot, res.getWriter());
} catch (Exception e) {
public void edit(HttpServletRequest req, HttpServletResponse res)
throws ServletModuleException {
try {
+
SimpleHash modelRoot = new SimpleHash();
EntityList parentList;
- EntityList parentNamesList;
+ EntityList theLanguageList;
int offset = 0;
String idParam = req.getParameter("id");
String where = "";
- parentList = mainModule.getByWhereClause("to_parent_id=NULL", offset);
-
- modelRoot.put("imcsparentlist",HTMLTemplateProcessor.makeSimpleList(parentList));
- modelRoot.put("entity", HTMLTemplateProcessor.makeSimpleHash(mainModule.getById(idParam)));
-
+ parentList = mainModule.getByWhereClause("to_parent_id=NULL", "title", offset, 1000);
+ theLanguageList = languageModule.getByWhereClause(null, "name", 0);
+ modelRoot.put("parentlist",HTMLTemplateProcessor.makeSimpleList(parentList));
+ modelRoot.put("languagelist",HTMLTemplateProcessor.makeSimpleList(theLanguageList));
+ modelRoot.put("entity", mainModule.getById(idParam));
deliver(req, res, modelRoot, templateObjektString);
} catch(ModuleException e) {
}
}
- public void update(HttpServletRequest req, HttpServletResponse res)
- throws ServletModuleException {
- try {
- String idParam = req.getParameter("id");
- HashMap withValues = getIntersectingValues(req, mainModule.getStorageObject());
- String id = mainModule.set(withValues);
- //theLog.printInfo("Showing Entity with id: " + id);
- //edit(req,res);
- String whereParam = req.getParameter("where");
- String orderParam = req.getParameter("order");
- if ((whereParam!=null && !whereParam.equals("")) || (orderParam!=null && !orderParam.equals(""))){
- //theLog.printDebugInfo("update to list");
- list(req,res);
- } else {
- edit(req, res);
- }
- //list(req,res);
- } catch (Exception e) {
- throw new ServletModuleException(e.toString());
- }
- }
-
}