本文整理汇总了Java中fr.opensagres.xdocreport.template.IContext类的典型用法代码示例。如果您正苦于以下问题:Java IContext类的具体用法?Java IContext怎么用?Java IContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IContext类属于fr.opensagres.xdocreport.template包,在下文中一共展示了IContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preprocessTemplate
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
/**
* Charge les templates
*/
public void preprocessTemplate() {
try {
logger.info("Generation du report");
// InputStream in = getClass().getResourceAsStream("/template/"+ConstanteUtils.TEMPLATE_DOSSIER+ConstanteUtils.TEMPLATE_EXTENSION);
InputStream in = MethodUtils.getXDocReportTemplate(ConstanteUtils.TEMPLATE_DOSSIER, null, null);
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(in, TemplateEngineKind.Velocity);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Options options = Options.getTo(ConverterTypeTo.PDF).via(ConverterTypeVia.XWPF);
IContext context = report.createContext();
report.convert(context, options, out);
out.close();
in.close();
} catch (IOException | XDocReportException e) {
logger.error("Erreur a la generation du report", e);
}
}
示例2: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
public void populateContext( IContext context, IXDocReport report, HttpServletRequest request )
{
String name = request.getParameter( "name" );
Project project = new Project( name );
context.put( "project", project );
int nbDevelopers = 0;
try
{
nbDevelopers = Integer.parseInt( request.getParameter( "nbDevelopers" ) );
}
catch ( Throwable e )
{
}
List<Developer> developers = new ArrayList<Developer>( nbDevelopers );
for ( int i = 0; i < nbDevelopers; i++ )
{
developers.add( new Developer( "Name" + i, "LastName" + i, "Mail" + i ) );
}
context.put( "developers", developers );
}
示例3: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
@Override
protected void populateContext( IContext context, IXDocReport report, HttpServletRequest request )
{
Boolean defaultReport = report.getData( DEFAULT_REPORT_KEY );
if ( defaultReport != null && defaultReport.booleanValue() == false )
{
MetaDataModel dataModelForm = report.getData( DATA_MODEL_REPORT_KEY );
if ( dataModelForm != null )
{
dataModelForm.populateContext( context, request );
}
}
else
{
super.populateContext( context, report, request );
}
}
示例4: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
public void populateContext( IContext context, IXDocReport report, HttpServletRequest request )
{
MetaDataModel dataModelForm = report.getData( DATA_MODEL_REPORT_KEY );
if ( dataModelForm == null )
{
// If report was not already loaded (default report) , create
// default data model
dataModelForm = getMetaDataModel();
if ( dataModelForm != null )
{
// It's a default report, store the data model in the report
report.setData( DATA_MODEL_REPORT_KEY, dataModelForm );
}
}
if ( dataModelForm != null )
{
dataModelForm.populateContext( context, request );
}
}
示例5: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
@Override
protected void populateContext( IContext context, String reportId, HttpServletRequest req )
throws XDocReportException
{
String project = req.getParameter( "project" );
context.put( "project", project );
String url = req.getParameter( "url" );
context.put( "url", url );
String comments_html = req.getParameter( "comments_html" );
context.put( "comments_html", comments_html );
String comments_gwiki = req.getParameter( "comments_gwiki" );
context.put( "comments_gwiki", comments_gwiki );
String comments_mediawiki = req.getParameter( "comments_mediawiki" );
context.put( "comments_mediawiki", comments_mediawiki );
}
示例6: generatePdfAsByteArray
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
public synchronized byte[] generatePdfAsByteArray(Resource resource, Map<String, Object> contextMap) throws PDFGenerationException {
try {
final IXDocReport report = xDocReportRegistry.loadReport(resource.getInputStream(), TemplateEngineKind.Freemarker);
final IContext context = report.createContext();
context.putMap(contextMap);
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final Options options = Options.getTo(PDF).via(XWPF);
report.convert(context, options, byteArrayOutputStream);
return byteArrayOutputStream.toByteArray();
} catch (IOException | XDocReportException e) {
throw new PDFGenerationException(e);
}
}
示例7: export
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
public byte[] export(InputStream template, Map<String, Object> arguments) {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(template, TemplateEngineKind.Velocity);
IContext context = report.createContext(arguments);
report.process(context, out);
return out.toByteArray();
} catch (XDocReportException | IOException ex) {
throw new GeneralException(ex);
}
}
示例8: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
@Override
protected void populateContext( IContext context, String reportId, HttpServletRequest request )
throws XDocReportException
{
if ( ODT_PROJECT_WITH_VELOCITY_LIST.equals( reportId ) || DOCX_PROJECT_WITH_VELOCITY_LIST.equals( reportId ) )
{
String name = request.getParameter( "name" );
Project project = new Project( name );
context.put( "project", project );
int nbDevelopers = 0;
try
{
nbDevelopers = Integer.parseInt( request.getParameter( "nbDevelopers" ) );
}
catch ( Throwable e )
{
}
List<Developer> developers = new ArrayList<Developer>( nbDevelopers );
for ( int i = 0; i < nbDevelopers; i++ )
{
developers.add( new Developer( "Name" + i, "LastName" + i, "Mail" + i ) );
}
context.put( "developers", developers );
}
else
{
throw new XDocReportNotFoundException( reportId );
}
}
示例9: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
@Override
protected void populateContext( IContext context, String reportId, HttpServletRequest req )
throws XDocReportException
{
if ( reportId.equals( ODT_HELLO_WORD_WITH_VELOCITY ) )
{
// reportId = ODTHelloWorldWithVelocity, prepare context with name
String name = req.getParameter( "name" );
context.put( "name", name );
}
else
{
throw new XDocReportNotFoundException( reportId );
}
}
示例10: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
@Override
public void populateContext( IContext context, HttpServletRequest request )
{
List<DynamicBean> dataModelList = new ArrayList<DynamicBean>();
for ( MetaDataModelSimpleField field : fields )
{
String name = field.getName();
String[] values = request.getParameterValues( name );
if ( values != null )
{
for ( int i = 0; i < values.length; i++ )
{
DynamicBean bean = null;
if ( dataModelList.size() >= i + 1 )
{
bean = dataModelList.get( i );
}
else
{
bean = new DynamicBean();
dataModelList.add( bean );
}
String value = values[i];
String key = name.substring( super.getName().length() + 1, name.length() );
bean.setValue( key.split( "[.]" ), value, 0 );
}
}
}
context.put( super.getName(), dataModelList );
}
示例11: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
public void populateContext( IContext context, HttpServletRequest request )
{
for ( MetaDataModelField field : super.getFields() )
{
field.populateContext( context, request );
}
}
示例12: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
public void populateContext( IContext context, HttpServletRequest request )
{
String value = request.getParameter( super.getName() );
if ( value != null )
{
context.put( super.getName(), value );
}
}
示例13: generateDocumentFromTemplate
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
private static void generateDocumentFromTemplate(
TemplateModel templateModel, OutputStream out)
throws XDocReportException, IOException {
InputStream in = null;
try {
in = templateModel.getTemplateFile().getInputStream();
IXDocReport report = null;
if (TemplateType.VELOCITY.equals(templateModel.getTemplateType())) {
report = XDocReportRegistry.getRegistry().loadReport(in,
TemplateEngineKind.Velocity);
} else {
report = XDocReportRegistry.getRegistry().loadReport(in,
TemplateEngineKind.Freemarker);
}
IContext context = report.createContext();
context.put(templateModel.getInTemplateDesignation(), templateModel);
if (templateModel.getPostProcessor() != null) {
ByteArrayOutputStream tempOutputStream = new ByteArrayOutputStream();
report.process(context, tempOutputStream);
InputStream tempInputStream = new ByteArrayInputStream(
tempOutputStream.toByteArray());
ODSProcessor.transformODS(tempInputStream, out,
templateModel.getPostProcessor());
} else {
report.process(context, out);
}
} finally {
IOUtils.closeQuietly(in);
}
}
示例14: generateLettre
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
/**
* @param templateLettre
* @param data
* @param fichierSignature
* @return l'inputstram de la lettre
*/
public InputStream generateLettre(final String templateLettre, final ExportLettreCandidat data,
final InputStream fichierSignature) {
InputStream template = MethodUtils.getXDocReportTemplate(templateLettre, i18nController.getLangueCandidat(),
cacheController.getLangueDefault().getCodLangue());
if (template == null) {
return null;
}
ByteArrayInOutStream out = new ByteArrayInOutStream();
try {
/* Ajout date et heure */
data.setDateHeure(formatterDateTime.format(LocalDateTime.now()));
data.setDate(formatterDate.format(LocalDateTime.now()));
/* Generation du template */
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(template, TemplateEngineKind.Velocity);
/* Variables */
IContext context = report.createContext();
context.put("data", data);
/* Pour l'image */
FieldsMetadata metadata = new FieldsMetadata();
if (fichierSignature != null) {
metadata.addFieldAsImage("imageSignature");
IImageProvider originalSizeLogo = new ByteArrayImageProvider(fichierSignature, true);
context.put("imageSignature", originalSizeLogo);
} else {
/* Si pas de fichier, on supprime l'image */
metadata.addFieldAsImage("imageSignature", NullImageBehaviour.RemoveImageTemplate);
}
report.setFieldsMetadata(metadata);
/* On vérifie si on affiche le tableau de signataire */
if (data.getLibelleSignature().equals("") && fichierSignature == null) {
context.put("showSignataire", false);
} else {
context.put("showSignataire", true);
}
/* Transformation en pdf */
Options options = Options.getTo(ConverterTypeTo.PDF).via(ConverterTypeVia.XWPF);
report.convert(context, options, out);
return signaturePdfManager.signPdf(out);
} catch (Exception e) {
// probleme de taille de signature XDocConverterException + StackOverflowError
if (e.getClass() != null && e instanceof XDocConverterException && e.getCause() != null
&& e.getCause() instanceof StackOverflowError) {
Notification.show(applicationContext.getMessage("candidature.lettre.download.sign.error", null,
UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
} else {
Notification.show(applicationContext.getMessage("candidature.lettre.download.error", null,
UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
logger.error("erreur a la création de la lettre", e);
}
return null;
} finally {
// fermeture des fichiers
MethodUtils.closeRessource(fichierSignature);
MethodUtils.closeRessource(template);
MethodUtils.closeRessource(out);
}
}
示例15: populateContext
import fr.opensagres.xdocreport.template.IContext; //导入依赖的package包/类
public void populateContext( IContext context, IXDocReport report, HttpServletRequest request )
{
String name = request.getParameter( "name" );
context.put( "name", name );
}