View Javadoc

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