1 package uk.ac.ebi.intenz.domain.enzyme;
2
3 import java.util.ArrayList;
4 import java.util.Iterator;
5 import java.util.List;
6 import java.util.Set;
7 import java.util.SortedSet;
8 import java.util.TreeSet;
9
10 import uk.ac.ebi.biobabel.util.collections.OperatorSet;
11 import uk.ac.ebi.intenz.domain.constants.EnzymeNameTypeConstant;
12 import uk.ac.ebi.intenz.domain.constants.EnzymeSourceConstant;
13 import uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant;
14 import uk.ac.ebi.intenz.domain.constants.Status;
15 import uk.ac.ebi.intenz.domain.constants.View;
16 import uk.ac.ebi.intenz.domain.constants.XrefDatabaseConstant;
17 import uk.ac.ebi.intenz.domain.exceptions.EnzymeNameException;
18 import uk.ac.ebi.intenz.domain.exceptions.EnzymeReactionException;
19 import uk.ac.ebi.intenz.domain.exceptions.EnzymeReferenceException;
20 import uk.ac.ebi.intenz.domain.history.HistoryGraph;
21 import uk.ac.ebi.intenz.domain.history.HistoryNode;
22 import uk.ac.ebi.intenz.domain.reference.Reference;
23 import uk.ac.ebi.rhea.domain.Reaction;
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 public class EnzymeEntry {
40
41
42
43
44 private Long id;
45
46
47
48
49 private EnzymeCommissionNumber ec;
50
51
52
53
54 private String className;
55
56
57
58
59 private String subclassName;
60
61
62
63
64 private String subSubclassName;
65
66
67
68
69 private List<EnzymeName> commonNames;
70
71
72
73
74 private EnzymeName systematicName;
75
76
77
78
79 private List<EnzymeName> synonyms;
80
81
82
83
84
85 private List<Reaction> reactions;
86
87
88
89
90 private EnzymaticReactions enzymaticReactions;
91
92
93
94
95 private Set<Object> cofactors;
96
97
98
99
100 private SortedSet<EnzymeLink> links;
101
102
103
104
105 private List<EnzymeComment> comments;
106
107
108
109
110 private List<Reference> references;
111
112
113
114
115 private String note;
116
117
118
119
120 private HistoryGraph historyGraph;
121
122
123
124
125 private Status status;
126
127
128
129
130 private EnzymeSourceConstant source;
131
132
133
134
135 private boolean isActive;
136
137
138
139
140 private boolean isGhost;
141
142
143
144
145
146 @SuppressWarnings("unchecked")
147 public EnzymeEntry() {
148 id = new Long(-1);
149 ec = EnzymeCommissionNumber.UNDEF;
150 className = "";
151 subclassName = "";
152 subSubclassName = "";
153 commonNames = new ArrayList<EnzymeName>();
154 systematicName = EnzymeName.UNDEF;
155 reactions = new ArrayList<Reaction>();
156 cofactors = new OperatorSet();
157 synonyms = new ArrayList<EnzymeName>();
158 links = new TreeSet<EnzymeLink>();
159 comments = new ArrayList<EnzymeComment>();
160 references = new ArrayList<Reference>();
161 note = "";
162 HistoryNode currentNode = new HistoryNode();
163 currentNode.setEnzymeEntry(this);
164 historyGraph = new HistoryGraph(currentNode);
165 status = Status.SUGGESTED;
166 source = EnzymeSourceConstant.INTENZ;
167 isActive = true;
168 isGhost = false;
169 }
170
171
172
173
174
175
176
177
178
179
180 public void addReaction(Reaction reaction) {
181 if (reaction == null) throw new NullPointerException("Parameter 'reaction' must not be null.");
182 for (Iterator<Reaction> it = reactions.iterator(); it.hasNext();) {
183 Reaction storedReaction = it.next();
184 if (storedReaction.equals(reaction)) return;
185 }
186
187 reactions.add(reaction);
188 }
189
190
191
192
193
194
195
196 public void addEnzymaticReaction(Reaction reaction, String view,
197 boolean iubmb){
198 if (enzymaticReactions == null)
199 enzymaticReactions = new EnzymaticReactions();
200 enzymaticReactions.add(reaction, view, iubmb);
201 }
202
203
204
205
206
207
208
209
210
211
212 public void addCofactor(Cofactor cofactor) {
213 if (cofactor == null)
214 throw new NullPointerException("Parameter 'cofactor' must not be null.");
215 if (!cofactors.contains(cofactor))
216 cofactors.add(cofactor);
217 }
218
219
220
221
222
223 public void addCofactor(Object cofactor){
224 if (cofactor == null)
225 throw new NullPointerException("Parameter 'cofactor' must not be null.");
226 if (!(cofactor instanceof Cofactor) && !(cofactor instanceof OperatorSet))
227 throw new IllegalArgumentException("The cofactor class is " + cofactor.getClass());
228 cofactors.add(cofactor);
229 }
230
231
232
233
234
235
236
237
238 public void removeReaction(String equation) {
239 if (equation == null) throw new NullPointerException("Parameter 'equation' must not be null.");
240 for (Iterator<Reaction> it = reactions.iterator(); it.hasNext();) {
241 Reaction reaction = it.next();
242 if (reaction.getTextualRepresentation().equals(equation)) {
243 reactions.remove(reaction);
244 return;
245 }
246 }
247 }
248
249 public void removeEnzymaticReaction(Reaction reaction){
250 enzymaticReactions.removeReaction(reaction);
251 }
252
253
254
255
256
257
258
259
260 public void removeCofactor(String cofactorString) {
261 if (cofactorString == null) throw new NullPointerException("Parameter 'cofactorString' must not be null.");
262 for (Iterator<Object> it = cofactors.iterator(); it.hasNext();) {
263 Cofactor cofactor = (Cofactor) it.next();
264 if (cofactor.getCompound().getName().equals(cofactorString)) {
265 cofactors.remove(cofactor);
266 return;
267 }
268 }
269 }
270
271
272
273
274
275
276 public void removeCofactor(Cofactor cofactor){
277 if (cofactor == null)
278 throw new NullPointerException("Cannot remove a null cofactor");
279 cofactors.remove(cofactor);
280 }
281
282
283
284
285
286
287 public void removeCofactor(Object cofactor){
288 if (cofactor == null)
289 throw new NullPointerException("Cannot remove a null cofactor");
290 cofactors.remove(cofactor);
291 }
292
293
294
295
296
297
298
299 public void addSynonym(EnzymeName synonym) {
300 if (synonym == null) throw new NullPointerException("Parameter 'synonym' must not be null.");
301 synonyms.add(synonym);
302 }
303
304
305
306
307
308
309
310 public void removeSynonym(String synonym) {
311 if (synonym == null) throw new NullPointerException("Parameter 'synonym' must not be null.");
312 synonyms.remove(synonym);
313 }
314
315
316
317
318
319
320
321
322
323 public void addLink(EnzymeLink link) {
324 if (link == null) throw new NullPointerException("Parameter 'link' must not be null.");
325
326 if (!links.contains(link)) links.add(link);
327 }
328
329
330
331
332
333
334
335 public void removeLink(EnzymeLink link) {
336 if (link == null) throw new NullPointerException("Parameter 'link' must not be null.");
337 links.remove(link);
338 }
339
340
341
342
343
344
345
346 public void addReference(Reference reference) {
347 if (reference == null) throw new NullPointerException("Parameter 'reference' must not be null.");
348 for (Iterator<Reference> it = references.iterator(); it.hasNext();) {
349 Reference storedReference = it.next();
350 if (storedReference.equals(reference)) return;
351 }
352
353 references.add(reference);
354 }
355
356
357
358
359
360
361
362 public void removeReference(Reference reference) {
363 if (reference == null) throw new NullPointerException("Parameter 'reference' must not be null.");
364 for (Iterator<Reference> it = references.iterator(); it.hasNext();) {
365 Reference storedReference = it.next();
366 if (reference.equals(storedReference)) {
367 references.remove(storedReference);
368 return;
369 }
370 }
371 }
372
373
374
375
376
377
378
379 @Override
380 public boolean equals(Object o) {
381 if (this == o) return true;
382 if (!(o instanceof EnzymeEntry)) return false;
383
384 final EnzymeEntry enzymeEntry = (EnzymeEntry) o;
385
386 if (isActive != enzymeEntry.isActive) return false;
387 if (isGhost != enzymeEntry.isGhost) return false;
388 if (className != null ? !className.equals(enzymeEntry.className) : enzymeEntry.className != null) return false;
389 if (cofactors != null ? !cofactors.equals(enzymeEntry.cofactors) : enzymeEntry.cofactors != null) return false;
390 if (comments != null ? !comments.equals(enzymeEntry.comments) : enzymeEntry.comments != null) return false;
391 if (commonNames != null ? !commonNames.equals(enzymeEntry.commonNames) : enzymeEntry.commonNames != null) return false;
392 if (ec != null ? !ec.equals(enzymeEntry.ec) : enzymeEntry.ec != null) return false;
393 if (historyGraph != null ? !historyGraph.equals(enzymeEntry.historyGraph) : enzymeEntry.historyGraph != null) return false;
394 if (id != null ? !id.equals(enzymeEntry.id) : enzymeEntry.id != null) return false;
395 if (links != null ? !links.equals(enzymeEntry.links) : enzymeEntry.links != null) return false;
396 if (note != null ? !note.equals(enzymeEntry.note) : enzymeEntry.note != null) return false;
397
398 if (enzymaticReactions != null ?
399 !enzymaticReactions.equals(enzymeEntry.enzymaticReactions) :
400 enzymeEntry.enzymaticReactions != null) return false;
401 if (references != null ? !references.equals(enzymeEntry.references) : enzymeEntry.references != null) return false;
402 if (source != null ? !source.equals(enzymeEntry.source) : enzymeEntry.source != null) return false;
403 if (status != null ? !status.equals(enzymeEntry.status) : enzymeEntry.status != null) return false;
404 if (subSubclassName != null ? !subSubclassName.equals(enzymeEntry.subSubclassName) : enzymeEntry.subSubclassName !=
405 null)
406 return false;
407 if (subclassName != null ? !subclassName.equals(enzymeEntry.subclassName) : enzymeEntry.subclassName != null) return false;
408 if (synonyms != null ? !synonyms.equals(enzymeEntry.synonyms) : enzymeEntry.synonyms != null) return false;
409 if (systematicName != null ? !systematicName.equals(enzymeEntry.systematicName) : enzymeEntry.systematicName !=
410 null)
411 return false;
412
413 return true;
414 }
415
416
417
418
419
420
421 @Override
422 public int hashCode() {
423 int result;
424 result = (id != null ? id.hashCode() : 0);
425 result = 29 * result + (ec != null ? ec.hashCode() : 0);
426 result = 29 * result + (className != null ? className.hashCode() : 0);
427 result = 29 * result + (subclassName != null ? subclassName.hashCode() : 0);
428 result = 29 * result + (subSubclassName != null ? subSubclassName.hashCode() : 0);
429 result = 29 * result + (commonNames != null ? commonNames.hashCode() : 0);
430 result = 29 * result + (systematicName != null ? systematicName.hashCode() : 0);
431 result = 29 * result + (synonyms != null ? synonyms.hashCode() : 0);
432 result = 29 * result + (reactions != null ? reactions.hashCode() : 0);
433 result = 29 * result + (cofactors != null ? cofactors.hashCode() : 0);
434 result = 29 * result + (links != null ? links.hashCode() : 0);
435 result = 29 * result + (comments != null ? comments.hashCode() : 0);
436 result = 29 * result + (references != null ? references.hashCode() : 0);
437 result = 29 * result + (note != null ? note.hashCode() : 0);
438 result = 29 * result + (historyGraph != null ? historyGraph.hashCode() : 0);
439 result = 29 * result + (status != null ? status.hashCode() : 0);
440 result = 29 * result + (source != null ? source.hashCode() : 0);
441 result = 29 * result + (isActive ? 1 : 0);
442 result = 29 * result + (isGhost ? 1 : 0);
443 return result;
444 }
445
446
447
448 public Long getId() {
449 return id;
450 }
451
452 public void setId(Long id) {
453 this.id = id;
454 }
455
456 public EnzymeCommissionNumber getEc() {
457 return ec;
458 }
459
460
461
462
463
464
465
466 public void setEc(EnzymeCommissionNumber ec) {
467 if (ec == null) throw new NullPointerException("Parameter 'ec' must not be null.");
468 this.ec = ec;
469 }
470
471 public String getClassName() {
472 return className;
473 }
474
475
476
477
478
479
480
481
482 public void setClassName(String className) {
483 if (className == null) throw new NullPointerException("Parameter 'className' must not be null.");
484 if (className.equals("")) throw new IllegalArgumentException("Parameter 'className' must not be empty.");
485 this.className = className;
486 }
487
488 public String getSubclassName() {
489 return subclassName;
490 }
491
492
493
494
495
496
497
498
499 public void setSubclassName(String subclassName) {
500 if (subclassName == null) throw new NullPointerException("Parameter 'subclassName' must not be null.");
501 if (subclassName.equals("")) throw new IllegalArgumentException("Parameter 'subclassName' must not be empty.");
502 this.subclassName = subclassName;
503 }
504
505 public String getSubSubclassName() {
506 return subSubclassName;
507 }
508
509
510
511
512
513
514
515 public void setSubSubclassName(String subSubclassName) {
516 if (subSubclassName == null) throw new NullPointerException("Parameter 'subSubclassName' must not be null.");
517 this.subSubclassName = subSubclassName;
518 }
519
520 public List<EnzymeName> getCommonNames() {
521 return commonNames;
522 }
523
524
525
526
527 public EnzymeName getCommonName(){
528 return getCommonName(null);
529 }
530
531
532
533
534
535
536
537
538
539
540
541 public EnzymeName getCommonName(EnzymeViewConstant view) {
542 if (view == null) view = EnzymeViewConstant.INTENZ;
543 if (view != EnzymeViewConstant.INTENZ && view != EnzymeViewConstant.IUBMB && view != EnzymeViewConstant.SIB)
544 throw new IllegalArgumentException("Parameter 'view' must be either 'EnzymeViewConstant.INTENZ', 'EnzymeViewConstant.IUBMB' or 'EnzymeViewConstant.SIB'");
545 if (commonNames == null || commonNames.size() == 0) return EnzymeName.UNDEF;
546 for (int iii = 0; iii < commonNames.size(); iii++) {
547 EnzymeName enzymeName = commonNames.get(iii);
548 if (view.toString().equals(EnzymeViewConstant.INTENZ.toString()) &&
549 EnzymeViewConstant.isInIntEnzView(enzymeName.getView().toString()))
550 return enzymeName;
551 if (view.toString().equals(EnzymeViewConstant.IUBMB.toString()) &&
552 EnzymeViewConstant.isInIUBMBView(enzymeName.getView().toString()))
553 return enzymeName;
554 if (view.toString().equals(EnzymeViewConstant.SIB.toString()) &&
555 EnzymeViewConstant.isInSIBView(enzymeName.getView().toString()))
556 return enzymeName;
557 }
558 return commonNames.get(0);
559 }
560
561
562
563
564
565
566
567
568
569
570
571
572 public void setCommonNames(List<EnzymeName> commonNames) throws EnzymeNameException {
573 if (commonNames == null) throw new NullPointerException("Parameter 'commonNames' must not be null.");
574 if (commonNames.size() > 2)
575 throw new EnzymeNameException("At most two common names can be part of this list.");
576 for (int iii = 0; iii < commonNames.size(); iii++) {
577 EnzymeName enzymeName = commonNames.get(iii);
578 if (enzymeName.getType() != EnzymeNameTypeConstant.COMMON_NAME)
579 throw new EnzymeNameException("The name's type " +
580 "must be of type 'uk.ac.ebi.intenz.domain.constants.EnzymeNameTypeConstant.COMMON_NAME'.");
581 if (enzymeName.getName().equals("")) commonNames.remove(iii--);
582 }
583 if (commonNames.size() < 1)
584 throw new EnzymeNameException("At least one common name must be part of this list.");
585
586 this.commonNames = commonNames;
587 }
588
589
590
591
592
593
594
595
596
597
598 public void addCommonName(EnzymeName commonName) throws EnzymeNameException {
599 if (commonName == null) throw new NullPointerException("Parameter 'commonName' must not be null.");
600 if (commonNames.size() == 2) throw new EnzymeNameException("The list of common names already contains two common names.");
601 if (commonName.getName().equals("")) return;
602 commonNames.add(commonName);
603 }
604
605 public EnzymeName getSystematicName() {
606 return systematicName;
607 }
608
609
610
611
612
613
614
615 public void setSystematicName(EnzymeName systematicName) {
616 if (systematicName == null) throw new NullPointerException("Parameter 'systematicName' must not be null.");
617 this.systematicName = systematicName;
618 }
619
620
621 public List<Reaction> getReactions() {
622 return reactions;
623 }
624
625
626
627
628
629
630
631
632
633
634
635
636 public List<Reaction> getReactions(EnzymeViewConstant view) {
637 return getReactions(view.toString());
638 }
639
640 public List<Reaction> getReactions(String view){
641 View theView = View.valueOf(view);
642 return getReactions(theView);
643 }
644
645 public List<Reaction> getReactions(View view){
646 return enzymaticReactions.getReactions(view);
647 }
648
649
650
651
652
653
654
655
656 public EnzymaticReactions getEnzymaticReactions(View view){
657 return enzymaticReactions.forView(view);
658 }
659
660
661
662
663
664
665
666
667
668 public void setReactions(List<Reaction> reactions) throws EnzymeReactionException {
669 if (reactions == null) throw new NullPointerException("Parameter 'reactions' must not be null.");
670 if (reactions.isEmpty())
671 throw new EnzymeReactionException("At least one reaction must be part of this list.");
672 for (int iii = 0; iii < reactions.size(); iii++) {
673 Reaction reaction = reactions.get(iii);
674 if (reaction.getTextualRepresentation().equals("")) reactions.remove(iii--);
675 }
676 this.reactions = reactions;
677 }
678
679 public EnzymaticReactions getEnzymaticReactions(){
680 return enzymaticReactions;
681 }
682
683 public void setEnzymaticReactions(EnzymaticReactions enzymaticReactions) {
684 this.enzymaticReactions = enzymaticReactions;
685 }
686
687 public Set<Object> getCofactors() {
688 return cofactors;
689 }
690
691 public void setCofactors(Set<Object> cofactors) {
692 this.cofactors = cofactors;
693 }
694
695 public List<EnzymeName> getSynonyms() {
696 return synonyms;
697 }
698
699 public List<EnzymeName> getSynonyms(String view){
700 View theView = View.valueOf(view);
701 return getSynonyms(theView);
702 }
703
704 public List<EnzymeName> getSynonyms(View theView){
705 if (synonyms == null) return new ArrayList<EnzymeName>();
706 if (synonyms.size() == 0) return synonyms;
707 boolean isInView = false;
708 List<EnzymeName> names = new ArrayList<EnzymeName>();
709 for (EnzymeName name : synonyms){
710 switch (theView) {
711 case INTENZ:
712 isInView = name.getView().isInIntEnzView();
713 break;
714 case IUBMB:
715 isInView = name.getView().isInIUBMBView();
716 break;
717 case SIB:
718 isInView = name.getView().isInSIBView();
719 break;
720 }
721 if (isInView) names.add(name);
722 }
723 return names;
724 }
725
726
727
728
729
730
731
732
733
734
735
736
737 public List<EnzymeName> getSynonyms(EnzymeViewConstant view) {
738 return getSynonyms(view.toString());
739 }
740
741
742
743
744
745
746
747 public void setSynonyms(List<EnzymeName> synonyms) {
748 if (synonyms == null) throw new NullPointerException("Parameter 'synonyms' must not be null.");
749 this.synonyms = synonyms;
750 }
751
752 public List<EnzymeComment> getComments() {
753 return comments;
754 }
755
756 public List<EnzymeComment> getComments(String view){
757 View theView = View.valueOf(view);
758 return getComments(theView);
759 }
760
761 public List<EnzymeComment> getComments(View theView){
762 if (comments == null) return new ArrayList<EnzymeComment>();
763 if (comments.size() == 0) return comments;
764 boolean isInView = false;
765 List<EnzymeComment> commentsInView = new ArrayList<EnzymeComment>();
766 for (EnzymeComment comment : comments){
767 switch (theView) {
768 case INTENZ:
769 isInView = comment.getView().isInIntEnzView();
770 break;
771 case IUBMB:
772 isInView = comment.getView().isInIUBMBView();
773 break;
774 case SIB:
775 isInView = comment.getView().isInSIBView();
776 break;
777 }
778 if (isInView) commentsInView.add(comment);
779 }
780 return commentsInView;
781 }
782
783
784
785
786
787
788
789
790
791
792
793
794 public List<EnzymeComment> getComments(EnzymeViewConstant view) {
795 if (view == null) throw new NullPointerException("Parameter 'view' must not be null.");
796 if (view != EnzymeViewConstant.INTENZ && view != EnzymeViewConstant.IUBMB && view != EnzymeViewConstant.SIB)
797 throw new IllegalArgumentException("Parameter 'view' must be either 'EnzymeViewConstant.INTENZ', 'EnzymeViewConstant.IUBMB' or 'EnzymeViewConstant.SIB'");
798 if (comments == null) return new ArrayList<EnzymeComment>();
799 if (comments.size() == 0) return comments;
800 List<EnzymeComment> groupedComments = new ArrayList<EnzymeComment>();
801 for (int iii = 0; iii < comments.size(); iii++) {
802 EnzymeComment comment = comments.get(iii);
803 if (view.toString().equals(EnzymeViewConstant.INTENZ.toString()) &&
804 EnzymeViewConstant.isInIntEnzView(comment.getView().toString())) {
805 groupedComments.add(comment);
806 continue;
807 }
808 if (view.toString().equals(EnzymeViewConstant.IUBMB.toString()) &&
809 EnzymeViewConstant.isInIUBMBView(comment.getView().toString())) {
810 groupedComments.add(comment);
811 continue;
812 }
813 if (view.toString().equals(EnzymeViewConstant.SIB.toString()) &&
814 EnzymeViewConstant.isInSIBView(comment.getView().toString())) {
815 groupedComments.add(comment);
816 continue;
817 }
818 }
819 return groupedComments;
820 }
821
822
823
824
825
826
827
828 public void setComments(List<EnzymeComment> comments) {
829 if (comments == null) throw new NullPointerException("Parameter 'comments' must not be null.");
830 this.comments = comments;
831 }
832
833 public SortedSet<EnzymeLink> getLinks() {
834 return links;
835 }
836
837 public SortedSet<EnzymeLink> getLinks(String view){
838 View theView = View.valueOf(view);
839 return getLinks(theView);
840 }
841
842
843
844
845
846 public SortedSet<EnzymeLink> getCasNumbers(){
847 SortedSet<EnzymeLink> cas = new TreeSet<EnzymeLink>();
848 for (EnzymeLink link : links){
849 if (link.getXrefDatabaseConstant().equals(XrefDatabaseConstant.CAS)){
850 cas.add(link);
851 }
852 }
853 return cas;
854 }
855
856 public SortedSet<EnzymeLink> getUniProtLinks(){
857 SortedSet<EnzymeLink> uniProtLinks = new TreeSet<EnzymeLink>();
858 for (EnzymeLink link : links){
859 if (link.getXrefDatabaseConstant().equals(XrefDatabaseConstant.SWISSPROT))
860 uniProtLinks.add(link);
861 }
862 return uniProtLinks;
863 }
864
865
866
867
868
869
870
871
872
873
874
875
876 public SortedSet<EnzymeLink> getLinks(View theView){
877 boolean isInView = false;
878 SortedSet<EnzymeLink> linksInView = new TreeSet<EnzymeLink>();
879 for (EnzymeLink link : links){
880 if (link.getXrefDatabaseConstant().equals(XrefDatabaseConstant.CAS) ||
881 link.getXrefDatabaseConstant().equals(XrefDatabaseConstant.SWISSPROT))
882 continue;
883 switch (theView) {
884 case INTENZ:
885 isInView = link.getView().isInIntEnzView();
886 break;
887 case IUBMB:
888 isInView = link.getView().isInIUBMBView();
889 break;
890 case SIB:
891 isInView = link.getView().isInSIBView();
892 break;
893 }
894 if (isInView) linksInView.add(link);
895 }
896
897 if (status.equals(Status.PRELIMINARY)){
898 if (theView == View.INTENZ)
899 linksInView.add(EnzymeLink.EXPASY);
900 } else {
901 switch (theView) {
902 case INTENZ:
903 linksInView.add(EnzymeLink.CSA);
904 linksInView.add(EnzymeLink.NC_IUBMB);
905 linksInView.add(EnzymeLink.UNIPATHWAY);
906 linksInView.add(EnzymeLink.EXPLORENZ);
907 linksInView.add(EnzymeLink.METACYC);
908 case IUBMB:
909 linksInView.add(EnzymeLink.PDB);
910 linksInView.add(EnzymeLink.BRENDA);
911 linksInView.add(EnzymeLink.EXPASY);
912 linksInView.add(EnzymeLink.KEGG);
913 break;
914 }
915 }
916 return linksInView;
917 }
918
919
920
921
922
923
924
925 public SortedSet<EnzymeLink> getLinks(EnzymeViewConstant view) {
926 if (view == null) throw new NullPointerException("Parameter 'view' must not be null.");
927 if (view != EnzymeViewConstant.INTENZ && view != EnzymeViewConstant.IUBMB && view != EnzymeViewConstant.SIB)
928 throw new IllegalArgumentException("Parameter 'view' must be either 'EnzymeViewConstant.INTENZ', 'EnzymeViewConstant.IUBMB' or 'EnzymeViewConstant.SIB'");
929 if (links == null) return new TreeSet<EnzymeLink>();
930 if (links.size() == 0) return links;
931 SortedSet<EnzymeLink> groupedLinks = new TreeSet<EnzymeLink>();
932 for (Iterator<EnzymeLink> it = links.iterator(); it.hasNext();) {
933 EnzymeLink link = it.next();
934 if (view.toString().equals(EnzymeViewConstant.INTENZ.toString()) &&
935 EnzymeViewConstant.isInIntEnzView(link.getView().toString())) {
936 groupedLinks.add(link);
937 continue;
938 }
939 if (view.toString().equals(EnzymeViewConstant.IUBMB.toString()) &&
940 EnzymeViewConstant.isInIUBMBView(link.getView().toString())) {
941 groupedLinks.add(link);
942 continue;
943 }
944 if (view.toString().equals(EnzymeViewConstant.SIB.toString()) &&
945 EnzymeViewConstant.isInSIBView(link.getView().toString())) {
946 groupedLinks.add(link);
947 continue;
948 }
949 }
950 return groupedLinks;
951 }
952
953
954
955
956
957
958
959 public void setLinks(SortedSet<EnzymeLink> links) {
960 if (links == null) throw new NullPointerException("Parameter 'links' must not be null.");
961 this.links = links;
962 }
963
964 public List<Reference> getReferences() {
965 return references;
966 }
967
968
969
970
971
972
973
974 public void setReferences(List<Reference> references) throws EnzymeReferenceException {
975 if (references == null) throw new NullPointerException("Parameter 'references' must not be null.");
976 if (references.size() < 1)
977 throw new EnzymeReferenceException("At least one reference must be part of this list.");
978 this.references = references;
979 }
980
981 public String getNote() {
982 return note;
983 }
984
985
986
987
988
989
990
991 public void setNote(String note) {
992 if (note == null) throw new NullPointerException("Parameter 'note' must not be null.");
993 this.note = note;
994 }
995
996 public HistoryGraph getHistory() {
997 return historyGraph;
998 }
999
1000
1001
1002
1003
1004
1005
1006 public void setHistory(HistoryGraph historyGraph) {
1007 if (historyGraph == null) throw new NullPointerException("Parameter 'historyGraph' must not be null.");
1008 this.historyGraph = historyGraph;
1009 }
1010
1011 public Status getStatus() {
1012 return status;
1013 }
1014
1015
1016
1017
1018
1019
1020
1021 public void setStatus(Status status) {
1022 if (status == null) throw new NullPointerException("Parameter 'status' must not be null.");
1023 this.status = status;
1024 }
1025
1026 public EnzymeSourceConstant getSource() {
1027 return source;
1028 }
1029
1030
1031
1032
1033
1034
1035
1036 public void setSource(EnzymeSourceConstant source) {
1037 if (source == null) throw new NullPointerException("Parameter 'source' must not be null.");
1038 this.source = source;
1039 }
1040
1041 public boolean isActive() {
1042 return isActive;
1043 }
1044
1045 public void setActive(boolean active) {
1046 this.isActive = active;
1047 }
1048
1049 public boolean isGhost() {
1050 return isGhost;
1051 }
1052
1053 public void setGhost(boolean ghost) {
1054 isGhost = ghost;
1055 }
1056
1057 public boolean hasNames() {
1058 if (commonNames != null && commonNames.size() > 0) return true;
1059 if (synonyms != null && synonyms.size() > 0) return true;
1060 if (systematicName != null && !systematicName.getName().equals("")) return true;
1061 return false;
1062 }
1063
1064
1065
1066 }