|
|
@ -37,6 +37,8 @@ import org.apache.velocity.VelocityContext; |
|
|
|
import org.springframework.beans.BeansException; |
|
|
|
import org.springframework.context.ApplicationContext; |
|
|
|
|
|
|
|
import com.bstek.ureport.cache.DefaultMemoryReportDefinitionCache; |
|
|
|
import com.bstek.ureport.cache.ReportDefinitionCache; |
|
|
|
import com.bstek.ureport.console.RenderPageServletAction; |
|
|
|
import com.bstek.ureport.console.exception.ReportDesignException; |
|
|
|
import com.bstek.ureport.definition.ReportDefinition; |
|
|
@ -56,6 +58,7 @@ import com.bstek.ureport.provider.report.ReportProvider; |
|
|
|
public class DesignerServletAction extends RenderPageServletAction { |
|
|
|
private ReportRender reportRender; |
|
|
|
private ReportParser reportParser; |
|
|
|
private ReportDefinitionCache reportDefinitionCache; |
|
|
|
private List<ReportProvider> reportProviders=new ArrayList<ReportProvider>(); |
|
|
|
@Override |
|
|
|
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { |
|
|
@ -176,6 +179,10 @@ public class DesignerServletAction extends RenderPageServletAction { |
|
|
|
throw new ReportDesignException("File ["+file+"] not found available report provider."); |
|
|
|
} |
|
|
|
targetReportProvider.saveReport(file, content); |
|
|
|
InputStream inputStream=IOUtils.toInputStream(content,"utf-8"); |
|
|
|
ReportDefinition reportDef=reportParser.parse(inputStream, file); |
|
|
|
reportDefinitionCache.cacheReportDefinition(file, reportDef); |
|
|
|
IOUtils.closeQuietly(inputStream); |
|
|
|
} |
|
|
|
|
|
|
|
public void loadReportProviders(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { |
|
|
@ -200,6 +207,12 @@ public class DesignerServletAction extends RenderPageServletAction { |
|
|
|
} |
|
|
|
reportProviders.add(provider); |
|
|
|
} |
|
|
|
Collection<ReportDefinitionCache> reportCaches=applicationContext.getBeansOfType(ReportDefinitionCache.class).values(); |
|
|
|
if(reportCaches.size()==0){ |
|
|
|
reportDefinitionCache=new DefaultMemoryReportDefinitionCache(); |
|
|
|
}else{ |
|
|
|
reportDefinitionCache=reportCaches.iterator().next(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|