1 package uk.ac.ebi.intenz.tools.release.helper;
2
3 import uk.ac.ebi.intenz.domain.enzyme.EnzymeClass;
4 import uk.ac.ebi.xchars.SpecialCharacters;
5 import uk.ac.ebi.xchars.domain.EncodingType;
6
7
8
9
10
11
12
13 public class EnzymeClassHelper {
14
15
16
17 private EnzymeClassHelper() {}
18
19 public static String toXML(EnzymeClass enzymeClass, SpecialCharacters encoding) {
20 StringBuffer xmlStringBuffer = new StringBuffer();
21
22 xmlStringBuffer.append("<enzyme>");
23
24 xmlStringBuffer.append("<ec>");
25 xmlStringBuffer.append("EC " + enzymeClass.getEc().toString());
26 xmlStringBuffer.append("</ec>");
27
28 xmlStringBuffer.append("<deleted_text>");
29 xmlStringBuffer.append("</deleted_text>");
30
31 xmlStringBuffer.append("<common_name>");
32 if (!enzymeClass.getName().equals("")) {
33 xmlStringBuffer.append(encoding.xml2Display(removeFormatting(enzymeClass.getName())));
34 }
35 xmlStringBuffer.append("</common_name>");
36
37 if (!enzymeClass.getName().equals("")) {
38 xmlStringBuffer.append("<common_name>");
39 xmlStringBuffer.append(encoding.xml2Display(removeFormatting(enzymeClass.getName()), EncodingType.SWISSPROT_CODE));
40 xmlStringBuffer.append("</common_name>");
41 }
42 xmlStringBuffer.append("<description>");
43 if (!enzymeClass.getDescription().equals("")) {
44 xmlStringBuffer.append(encoding.xml2Display(removeFormatting(enzymeClass.getDescription())));
45 }
46 xmlStringBuffer.append("</description>");
47
48 if (!enzymeClass.getDescription().equals("")) {
49 xmlStringBuffer.append("<description>");
50 xmlStringBuffer.append(encoding.xml2Display(removeFormatting(enzymeClass.getDescription()), EncodingType.SWISSPROT_CODE));
51 xmlStringBuffer.append("</description>");
52 }
53
54 xmlStringBuffer.append("<reactions>");
55 xmlStringBuffer.append("</reactions>");
56
57 xmlStringBuffer.append("<syst_name>");
58 xmlStringBuffer.append("</syst_name>");
59
60 xmlStringBuffer.append("<synonyms>");
61 xmlStringBuffer.append("</synonyms>");
62
63 xmlStringBuffer.append("<comments>");
64 xmlStringBuffer.append("</comments>");
65
66 xmlStringBuffer.append("<links>");
67 xmlStringBuffer.append("</links>");
68
69 xmlStringBuffer.append("<references>");
70 xmlStringBuffer.append("<reference>");
71 xmlStringBuffer.append("<reference>");
72 xmlStringBuffer.append("<number>");
73 xmlStringBuffer.append("</number>");
74 xmlStringBuffer.append("<authors>");
75 xmlStringBuffer.append("</auhors>");
76 xmlStringBuffer.append("<title>");
77 xmlStringBuffer.append("</title>");
78 xmlStringBuffer.append("<year>");
79 xmlStringBuffer.append("</year>");
80 xmlStringBuffer.append("<issue>");
81 xmlStringBuffer.append("</issue>");
82 xmlStringBuffer.append("<patent_no>");
83 xmlStringBuffer.append("</patent_no>");
84 xmlStringBuffer.append("<first_page>");
85 xmlStringBuffer.append("</first_page>");
86 xmlStringBuffer.append("<last_page>");
87 xmlStringBuffer.append("</last_page>");
88 xmlStringBuffer.append("<edition>");
89 xmlStringBuffer.append("</edition>");
90 xmlStringBuffer.append("<editor>");
91 xmlStringBuffer.append("</editor>");
92 xmlStringBuffer.append("<volume>");
93 xmlStringBuffer.append("</volume>");
94 xmlStringBuffer.append("<pub_place>");
95 xmlStringBuffer.append("</pub_place>");
96 xmlStringBuffer.append("<pub_company>");
97 xmlStringBuffer.append("</pub_company>");
98 xmlStringBuffer.append("<pub_med>");
99 xmlStringBuffer.append("</pub_med>");
100 xmlStringBuffer.append("<medline>");
101 xmlStringBuffer.append("</medline>");
102 xmlStringBuffer.append("</reference>");
103 xmlStringBuffer.append("</reference>");
104 xmlStringBuffer.append("</references>");
105
106 xmlStringBuffer.append("<history>");
107 xmlStringBuffer.append("</history>");
108
109 xmlStringBuffer.append("</enzyme>");
110
111 return xmlStringBuffer.toString();
112 }
113
114 private static String removeFormatting(String text) {
115 text = text.replaceAll("\\<small\\>", "");
116 text = text.replaceAll("\\<\\/small\\>", "");
117 text = text.replaceAll("\\<b\\>", "");
118 text = text.replaceAll("\\<\\/b\\>", "");
119 text = text.replaceAll("\\<i\\>", "");
120 text = text.replaceAll("\\<\\/i\\>", "");
121 return text;
122 }
123 }