Search in sources :

Example 1 with OutputUtil

use of net.parostroj.timetable.output2.util.OutputUtil in project grafikon by jub77.

the class OutputWriter method createOutputs.

private List<OutputSettings> createOutputs(net.parostroj.timetable.model.Output modelOutput) throws OutputException {
    OutputTemplate template = modelOutput.getTemplate();
    List<OutputSettings> result = null;
    if (template.getScript() != null) {
        final List<OutputSettings> out = new ArrayList<>();
        Map<String, Object> binding = new HashMap<>();
        binding.put("diagram", diagram);
        binding.put("output", modelOutput);
        binding.put("log", scriptLog);
        binding.put("settings", new WrapperLogMap<>(modelOutput.getSettings().getAttributesMap(net.parostroj.timetable.model.Output.CATEGORY_SETTINGS), scriptLog, "settings"));
        binding.put("localization", new WrapperLogMap<>(template.getAttributes().getAttributesMap(OutputTemplate.CATEGORY_I18N), scriptLog, "localization"));
        binding.put("locale", modelOutput.getLocale() != null ? modelOutput.getLocale() : settings.getLocale());
        binding.put("key", getOutputKey(modelOutput));
        binding.put("selection", modelOutput.getSelection());
        binding.put("util", new OutputUtil());
        binding.put("outputs", new OutputCollector() {

            @Override
            public void add(String name, Map<String, Object> context) {
                out.add(new OutputSettings().setName(name).setContext(context));
            }

            @Override
            public void add(String name, Map<String, Object> context, String encoding) {
                out.add(new OutputSettings().setName(name).setContext(context).setEncoding(encoding));
            }

            @Override
            public OutputSettings create() {
                OutputSettings lSettings = new OutputSettings();
                out.add(lSettings);
                return lSettings;
            }
        });
        try {
            template.getScript().evaluateWithException(binding);
        } catch (GrafikonException e) {
            throw new OutputException("Error in script: " + e.getMessage(), e);
        }
        result = out;
    }
    return result;
}
Also used : OutputUtil(net.parostroj.timetable.output2.util.OutputUtil)

Example 2 with OutputUtil

use of net.parostroj.timetable.output2.util.OutputUtil in project grafikon by jub77.

the class OutputWriter method updateContext.

private Map<String, Object> updateContext(net.parostroj.timetable.model.Output modelOutput, OutputTemplate outputTemplate, Map<String, Object> context) {
    Map<String, Object> usedContext = context;
    if (usedContext == null)
        usedContext = new HashMap<>();
    usedContext.put("settings", new WrapperLogMap<>(modelOutput.getSettings().getAttributesMap(net.parostroj.timetable.model.Output.CATEGORY_SETTINGS), templateLog, "settings"));
    usedContext.put("localization", new WrapperLogMap<>(outputTemplate.getAttributes().getAttributesMap(OutputTemplate.CATEGORY_I18N), templateLog, "localization"));
    usedContext.put("selection", modelOutput.getSelection());
    usedContext.put("util", new OutputUtil());
    return usedContext;
}
Also used : OutputUtil(net.parostroj.timetable.output2.util.OutputUtil)

Aggregations

OutputUtil (net.parostroj.timetable.output2.util.OutputUtil)2