SuperX-Kernmodul
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

104 lines
4.2 KiB

package de.superx.servlet;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Hashtable;
import javax.swing.tree.DefaultTreeModel;
import org.apache.log4j.*;
import de.superx.common.AbstractSicht;
import de.superx.common.DBServletException;
import de.superx.common.FieldContainer;
import de.superx.common.SelectableItemNode;
import de.superx.common.SelectableItemTree;
import de.superx.common.Sichten;
import de.superx.common.SuperX_el;
import de.superx.common.SxResultSet;
import de.superx.util.SqlStringUtils;
import freemarker.template.TemplateException;
/**
* Implementation einer Sicht im Servlet-Container wird dank Ajax nicht mehr
* benötigt
*
*/
public class SichtServlet extends AbstractSicht {
private static final long serialVersionUID = 1L;
public SichtServlet(Sichten sichten, Object id, String name) {
super(sichten, id, name);
}
/**
* Used for cloning
*
* @param id
* @param name
* @param model
*/
private SichtServlet(Sichten sichten, Object id, String name, DefaultTreeModel model) {
super(sichten, id, name, model);
}
@Override
protected SxResultSet readFromDb(String sql) throws SQLException, DBServletException, TemplateException, IOException {
HashMap map = new HashMap();
map.putAll(user.getBasicMap());
String select_string = SxPools.get(mandantenID).getTemplateProcessor().process(map, null,
"Sicht " + this.getName() + this.getId() + " " + this.getName_intern() + ") einlesen", sql,
null, SxPools.get(mandantenID).getRepository(), SxPools.get(mandantenID).getSqlDialect());
Logger.getLogger("superx_" + mandantenID).log(Level.TRACE, "Aktualisieren der Sicht: " + this.getName() + " (" + getId() + ") mit SQL " + select_string);
SuperX_el el = ServletUtils.executeALL_el(null, null, "Sicht " + this.getName() + " (" + this.getId() + this.getName_intern() + ") per " + select_string, select_string,
getMandantenID(), true);
return el.getResultSet();
}
@Override
public boolean isCachedVersionInPool() {
return SxPools.get(mandantenID).getFieldElementCache().containsEntry("sicht_" + getName_intern());
}
@Override
public void addCachedNodes(SelectableItemNode root) {
Logger.getLogger("superx_" + mandantenID).log(Level.DEBUG, "Aktualisieren der Sicht: " + this.getName() + " (" + getId() + ") aus gecachten Eintraegen");
cloneNodes(SxPools.get(mandantenID).getFieldElementCache().getSichtRoot("sicht_" + getName_intern()), root);
// wird ggfs. für alt.Hier gebraucht
selectableItemCollection.clear();
selectableItemCollection.addAll(SxPools.get(mandantenID).getFieldElementCache().getSichtColl("sicht_coll" + getName_intern()));
}
@Override
protected String getSqlDialect() {
return SxPools.get(mandantenID).getSqlDialect();
}
@Override
public Object clone() throws CloneNotSupportedException {
SelectableItemTree st = (SelectableItemTree) super.clone();
SichtServlet cl = new SichtServlet(sichten, getId(), getName(), (DefaultTreeModel) st.getModel());
finishClone(cl);
return cl;
}
@Override
public String dynamicSichtGenerateSql(Hashtable formular, String sql) {
return SqlStringUtils.generateSQL(SxPools.get(mandantenID).getDatabaseAbbr(), formular, sql);
}
@Override
public String dynmicSichtFMParsing(HashMap map, FieldContainer individualFields, String sql) throws TemplateException, IOException, SQLException {
sql = SxPools.get(mandantenID).getTemplateProcessor().process(map, null, "Feld " + getName() + " (" + getId() + ") Sicht " + getName_intern() + " " + sql, sql,
individualFields, SxPools.get(mandantenID).getRepository(), SxPools.get(mandantenID).getSqlDialect());
return sql;
}
}
// Created on 06.12.2004 at 13:18:38