Add all needed infrastructure for MSAprobs and GLprobs
[jabaws.git] / webservices / compbio / data / msa / Category.java
1 /**\r
2  * Class that splits {@link Services} to categories. Services themselves have no\r
3  * knowledge which category they belongs to.\r
4  * \r
5  * This class is responsible for initialization of all the categories (done\r
6  * statically) and holds the category names as constrains.\r
7  * \r
8  * Two categories considered equals if their names are equals.\r
9  * \r
10  * @author pvtroshin\r
11  * @version 1.0 September 2011\r
12  */\r
13 \r
14 package compbio.data.msa;\r
15 \r
16 import java.util.HashSet;\r
17 import java.util.Set;\r
18 import java.util.TreeSet;\r
19 \r
20 import javax.xml.bind.annotation.XmlAccessType;\r
21 import javax.xml.bind.annotation.XmlAccessorType;\r
22 \r
23 import compbio.ws.client.Services;\r
24 \r
25 @XmlAccessorType(XmlAccessType.FIELD)\r
26 public class Category {\r
27         /*\r
28          * TODO refactor initialization and constrains into separate classes if\r
29          * further complexity is expected.\r
30          */\r
31 \r
32         /**\r
33          * All of the Category names\r
34          */\r
35         public static final String CATEGORY_ALIGNMENT = "Alignment";\r
36         public static final String CATEGORY_DISORDER = "Protein Disorder";\r
37         public static final String CATEGORY_CONSERVATION = "Conservation";\r
38         public static final String CATEGORY_PREDICTION = "Prediction";\r
39 \r
40         public String name;\r
41         Set<Services> services;\r
42 \r
43         private Category(String name, Set<Services> services) {\r
44                 this.name = name;\r
45                 this.services = services;\r
46         }\r
47 \r
48         private Category() {\r
49                 // Default constructor for JAXB\r
50         }\r
51 \r
52         public Set<Services> getServices() {\r
53                 return new TreeSet<Services>(services);\r
54         }\r
55 \r
56         public static Set<Category> getCategories() {\r
57                 return init();\r
58         }\r
59 \r
60         private static Set<Category> init() {\r
61                 Set<Services> align_services = new HashSet<Services>();\r
62                 align_services.add(Services.ClustalOWS);\r
63                 align_services.add(Services.ClustalWS);\r
64                 align_services.add(Services.MafftWS);\r
65                 align_services.add(Services.MuscleWS);\r
66                 align_services.add(Services.ProbconsWS);\r
67                 align_services.add(Services.MSAprobsWS);\r
68                 align_services.add(Services.GLprobsWS);\r
69                 align_services.add(Services.TcoffeeWS);\r
70                 Category alignment = new Category(CATEGORY_ALIGNMENT, align_services);\r
71 \r
72                 Set<Services> disorder_services = new HashSet<Services>();\r
73                 disorder_services.add(Services.DisemblWS);\r
74                 disorder_services.add(Services.GlobPlotWS);\r
75                 disorder_services.add(Services.IUPredWS);\r
76                 disorder_services.add(Services.JronnWS);\r
77                 Category disorder = new Category(CATEGORY_DISORDER, disorder_services);\r
78 \r
79                 Set<Services> conservation_services = new HashSet<Services>();\r
80                 conservation_services.add(Services.AAConWS);\r
81                 Category conservation = new Category(CATEGORY_CONSERVATION, conservation_services);\r
82 \r
83                 Set<Services> prediction_services = new HashSet<Services>();\r
84                 prediction_services.add(Services.JpredWS);\r
85                 prediction_services.add(Services.RNAalifoldWS);\r
86                 Category prediction = new Category(CATEGORY_PREDICTION, prediction_services);\r
87 \r
88                 Set<Category> categories = new HashSet<Category>();\r
89                 categories.add(alignment);\r
90                 categories.add(disorder);\r
91                 categories.add(conservation);\r
92                 categories.add(prediction);\r
93 \r
94                 return categories;\r
95         }\r
96 \r
97         @Override\r
98         public int hashCode() {\r
99                 final int prime = 31;\r
100                 int result = 1;\r
101                 result = prime * result + ((name == null) ? 0 : name.hashCode());\r
102                 return result;\r
103         }\r
104 \r
105         @Override\r
106         public boolean equals(Object obj) {\r
107                 if (this == obj)\r
108                         return true;\r
109                 if (obj == null)\r
110                         return false;\r
111                 if (getClass() != obj.getClass())\r
112                         return false;\r
113                 Category other = (Category) obj;\r
114                 if (name == null) {\r
115                         if (other.name != null)\r
116                                 return false;\r
117                 } else if (!name.equals(other.name))\r
118                         return false;\r
119                 return true;\r
120         }\r
121 \r
122 }\r