1
2
3
4
5
6 package uk.ac.ebi.intenz.tools.release.helper;
7
8 import uk.ac.ebi.intenz.tools.release.helper.EnzymeEntryHelper;
9 import uk.ac.ebi.intenz.domain.reference.Book;
10 import uk.ac.ebi.intenz.domain.reference.Journal;
11 import uk.ac.ebi.intenz.domain.reference.Patent;
12 import uk.ac.ebi.intenz.domain.reference.Reference;
13 import uk.ac.ebi.xchars.SpecialCharacters;
14 import uk.ac.ebi.xchars.domain.EncodingType;
15
16
17
18
19
20
21
22
23
24
25
26
27 public class EnzymeReferenceHelper {
28
29
30
31
32
33
34
35
36
37
38 public static String referenceToIntEnzTextXML (Reference reference, int number, SpecialCharacters encoding) {
39 StringBuffer buffer = new StringBuffer();
40 buffer.append(referenceXML(reference, number, encoding));
41 if ( reference instanceof Book ) {
42 Book book = (Book) reference;
43 buffer.append(bookXML(book, encoding));
44 } else if ( reference instanceof Journal ) {
45 Journal journal = (Journal) reference;
46 buffer.append(journalXML(journal, encoding));
47 } else if ( reference instanceof Patent ) {
48 Patent patent = (Patent) reference;
49 buffer.append(patentXML(patent, encoding));
50 }
51 return buffer.toString();
52 }
53
54
55
56
57
58
59
60
61
62
63 private static String referenceXML (Reference reference, int number, SpecialCharacters encoding) {
64 StringBuffer xmlStringBuffer = new StringBuffer();
65
66 xmlStringBuffer.append("<number>");
67 xmlStringBuffer.append(number + ".");
68 xmlStringBuffer.append("</number>");
69 xmlStringBuffer.append("<authors>");
70 xmlStringBuffer.append(EnzymeEntryHelper.removeFormatting(encoding.xml2Display(reference.getAuthors())));
71 xmlStringBuffer.append("</authors>");
72
73 xmlStringBuffer.append("<authors>");
74 xmlStringBuffer.append(EnzymeEntryHelper.
75 removeFormatting(encoding.xml2Display(reference.getAuthors(), EncodingType.SWISSPROT_CODE)));
76 xmlStringBuffer.append("</authors>");
77
78 xmlStringBuffer.append("<title>");
79 xmlStringBuffer.append(EnzymeEntryHelper.removeFormatting(encoding.xml2Display(reference.getTitle())));
80 xmlStringBuffer.append("</title>");
81
82 xmlStringBuffer.append("<title>");
83 xmlStringBuffer.append(EnzymeEntryHelper.removeFormatting(encoding.xml2Display(reference.getTitle(), EncodingType.SWISSPROT_CODE)));
84 xmlStringBuffer.append("</title>");
85
86 xmlStringBuffer.append("<year>");
87 xmlStringBuffer.append(reference.getYear());
88 xmlStringBuffer.append("</year>");
89
90 return xmlStringBuffer.toString();
91 }
92
93 private static String bookXML (Book book, SpecialCharacters encoding) {
94 StringBuffer xmlStringBuffer = new StringBuffer();
95 xmlStringBuffer.append("<pubName>");
96 xmlStringBuffer.append(book.getPubName());
97 xmlStringBuffer.append("</pubName>");
98 xmlStringBuffer.append("<patent_no>");
99 xmlStringBuffer.append("</patent_no>");
100 xmlStringBuffer.append("<first_page>");
101 xmlStringBuffer.append(book.getFirstPage());
102 xmlStringBuffer.append("</first_page>");
103 xmlStringBuffer.append("<last_page>");
104 xmlStringBuffer.append(book.getLastPage());
105 xmlStringBuffer.append("</last_page>");
106 xmlStringBuffer.append("<edition>");
107 xmlStringBuffer.append(EnzymeEntryHelper.removeFormatting(encoding.xml2Display(book.getEdition(false))));
108 xmlStringBuffer.append("</edition>");
109
110 xmlStringBuffer.append("<edition>");
111 xmlStringBuffer.append(EnzymeEntryHelper.
112 removeFormatting(encoding.xml2Display(book.getEdition(false), EncodingType.SWISSPROT_CODE)));
113 xmlStringBuffer.append("</edition>");
114
115 xmlStringBuffer.append("<editor>");
116 xmlStringBuffer.append(EnzymeEntryHelper.removeFormatting(encoding.xml2Display(book.getEditor(false))));
117 xmlStringBuffer.append("</editor>");
118
119 xmlStringBuffer.append("<editor>");
120 xmlStringBuffer.append(EnzymeEntryHelper.
121 removeFormatting(encoding.xml2Display(book.getEditor(false), EncodingType.SWISSPROT_CODE)));
122 xmlStringBuffer.append("</editor>");
123
124 xmlStringBuffer.append("<volume>");
125 xmlStringBuffer.append(book.getVolume());
126 xmlStringBuffer.append("</volume>");
127 xmlStringBuffer.append("<pub_place>");
128 xmlStringBuffer.append(EnzymeEntryHelper.removeFormatting(encoding.xml2Display(book.getPublisherPlace())));
129 xmlStringBuffer.append("</pub_place>");
130
131 xmlStringBuffer.append("<pub_place>");
132 xmlStringBuffer.append(EnzymeEntryHelper.
133 removeFormatting(encoding.xml2Display(book.getPublisherPlace(), EncodingType.SWISSPROT_CODE)));
134 xmlStringBuffer.append("</pub_place>");
135
136 xmlStringBuffer.append("<pub_company>");
137 xmlStringBuffer.append(EnzymeEntryHelper.removeFormatting(encoding.xml2Display(book.getPublisher())));
138 xmlStringBuffer.append("</pub_company>");
139
140 xmlStringBuffer.append("<pub_company>");
141 xmlStringBuffer.append(EnzymeEntryHelper.removeFormatting(encoding.xml2Display(book.getPublisher(), EncodingType.SWISSPROT_CODE)));
142 xmlStringBuffer.append("</pub_company>");
143
144 xmlStringBuffer.append("<pub_med>");
145 xmlStringBuffer.append("</pub_med>");
146 xmlStringBuffer.append("<medline>");
147 xmlStringBuffer.append("</medline>");
148
149 return xmlStringBuffer.toString();
150 }
151
152 private static String journalXML (Journal journal, SpecialCharacters encoding) {
153 StringBuffer xmlStringBuffer = new StringBuffer();
154 xmlStringBuffer.append("<pubName>");
155 xmlStringBuffer.append(journal.getPubName());
156 xmlStringBuffer.append("</pubName>");
157 xmlStringBuffer.append("<patent_no>");
158 xmlStringBuffer.append("</patent_no>");
159 xmlStringBuffer.append("<first_page>");
160 xmlStringBuffer.append(journal.getFirstPage());
161 xmlStringBuffer.append("</first_page>");
162 xmlStringBuffer.append("<last_page>");
163 xmlStringBuffer.append(journal.getLastPage());
164 xmlStringBuffer.append("</last_page>");
165 xmlStringBuffer.append("<edition>");
166 xmlStringBuffer.append("</edition>");
167 xmlStringBuffer.append("<editor>");
168 xmlStringBuffer.append("</editor>");
169 xmlStringBuffer.append("<volume>");
170 xmlStringBuffer.append("</volume>");
171 xmlStringBuffer.append("<pub_place>");
172 xmlStringBuffer.append("</pub_place>");
173 xmlStringBuffer.append("<pub_company>");
174 xmlStringBuffer.append("</pub_company>");
175 xmlStringBuffer.append("<pub_med>");
176 xmlStringBuffer.append(journal.getPubMedId());
177 xmlStringBuffer.append("</pub_med>");
178 xmlStringBuffer.append("<medline>");
179 xmlStringBuffer.append(journal.getMedlineId());
180 xmlStringBuffer.append("</medline>");
181 return xmlStringBuffer.toString();
182 }
183
184 private static String patentXML (Patent patent, SpecialCharacters encoding) {
185 StringBuffer xmlStringBuffer = new StringBuffer();
186 xmlStringBuffer.append("<issue>");
187 xmlStringBuffer.append("</issue>");
188 xmlStringBuffer.append("<patent_no>");
189 xmlStringBuffer.append(patent.getPatentNumber());
190 xmlStringBuffer.append("</patent_no>");
191 xmlStringBuffer.append("<first_page>");
192 xmlStringBuffer.append("</first_page>");
193 xmlStringBuffer.append("<last_page>");
194 xmlStringBuffer.append("</last_page>");
195 xmlStringBuffer.append("<edition>");
196 xmlStringBuffer.append("</edition>");
197 xmlStringBuffer.append("<editor>");
198 xmlStringBuffer.append("</editor>");
199 xmlStringBuffer.append("<volume>");
200 xmlStringBuffer.append("</volume>");
201 xmlStringBuffer.append("<pub_place>");
202 xmlStringBuffer.append("</pub_place>");
203 xmlStringBuffer.append("<pub_company>");
204 xmlStringBuffer.append("</pub_company>");
205 xmlStringBuffer.append("<pub_med>");
206 xmlStringBuffer.append("</pub_med>");
207 xmlStringBuffer.append("<medline>");
208 xmlStringBuffer.append("</medline>");
209 return xmlStringBuffer.toString();
210 }
211
212 }