1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.efaps.update.schema.program.staticsource;
22
23 import org.efaps.ci.CIAdminProgram;
24 import org.efaps.ci.CIType;
25 import org.efaps.db.Checkout;
26 import org.efaps.db.Instance;
27 import org.efaps.update.schema.program.staticsource.WikiCompiler.OneWiki;
28 import org.efaps.util.EFapsException;
29 import org.efaps.wikiutil.export.html.WEMHtml;
30 import org.efaps.wikiutil.parser.gwiki.GWikiParser;
31 import org.efaps.wikiutil.parser.gwiki.javacc.ParseException;
32
33
34
35
36
37
38
39 public class WikiCompiler
40 extends AbstractStaticSourceCompiler<OneWiki>
41 {
42
43
44
45
46 @Override
47 protected CIType getClassName4Type()
48 {
49 return CIAdminProgram.Wiki;
50 }
51
52
53
54
55 @Override
56 protected CIType getClassName4Type2Type()
57 {
58 return CIAdminProgram.Wiki2Wiki;
59 }
60
61
62
63
64 @Override
65 protected CIType getClassName4TypeCompiled()
66 {
67 return CIAdminProgram.WikiCompiled;
68 }
69
70
71
72
73 @Override
74 protected String getCompiledString(final Instance _instance)
75 throws EFapsException
76 {
77 final Checkout checkout = new Checkout(_instance);
78 final WEMHtml wemhtml = new WEMHtml();
79 try {
80 GWikiParser.parse(wemhtml, checkout.execute(), "UTF-8");
81 } catch (final ParseException e) {
82 throw new EFapsException(WikiCompiler.class, "ParseException", e);
83 }
84 return wemhtml.getHtml();
85 }
86
87
88
89
90 @Override
91 protected OneWiki getNewSource(final String _name,
92 final Instance _instance)
93 {
94 return new OneWiki(_name, _instance);
95 }
96
97
98
99
100
101 public static class OneWiki
102 extends AbstractStaticSourceCompiler.AbstractSource
103 {
104
105
106
107
108
109 public OneWiki(final String _name,
110 final Instance _instance)
111 {
112 super(_name, _instance);
113 }
114 }
115 }