+++ /dev/null
-package compbio.ws.server;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-import java.util.TreeSet;\r
-\r
-import javax.xml.bind.annotation.XmlAccessType;\r
-import javax.xml.bind.annotation.XmlAccessorType;\r
-\r
-import compbio.ws.client.Services;\r
-\r
-/**\r
- * Class that splits {@link Services} to categories. Services themselves have no\r
- * knowledge which category they belongs to.\r
- * \r
- * This class is responsible for initialization of all the categories (done\r
- * statically) and holds the category names as constrains.\r
- * \r
- * Two categories considered equals if their names are equals.\r
- * \r
- * @author pvtroshin\r
- * @version 1.0 September 2011\r
- */\r
-@XmlAccessorType(XmlAccessType.FIELD)\r
-public class Category {\r
- /*\r
- * TODO refactor initialization and constrains into separate classes if\r
- * further complexity is expected.\r
- */\r
-\r
- /**\r
- * All of the Category names\r
- */\r
- public static final String CATEGORY_ALIGNMENT = "Alignment";\r
- public static final String CATEGORY_DISORDER = "Protein Disorder";\r
- public static final String CATEGORY_CONSERVATION = "Conservation";\r
-\r
- String name;\r
- Set<Services> services;\r
-\r
- private Category(String name, Set<Services> services) {\r
- this.name = name;\r
- this.services = services;\r
- }\r
-\r
- private Category() {\r
- // Default constructor for JAXB\r
- }\r
-\r
- Set<Services> getServices() {\r
- return new TreeSet<Services>(services);\r
- }\r
-\r
- public static Set<Category> getCategories() {\r
- return init();\r
- }\r
-\r
- private static Set<Category> init() {\r
- Set<Services> align_services = new HashSet<Services>();\r
- align_services.add(Services.ClustalOWS);\r
- align_services.add(Services.ClustalWS);\r
- align_services.add(Services.MafftWS);\r
- align_services.add(Services.MuscleWS);\r
- align_services.add(Services.ProbconsWS);\r
- align_services.add(Services.TcoffeeWS);\r
- Category alignment = new Category(CATEGORY_ALIGNMENT, align_services);\r
-\r
- Set<Services> disorder_services = new HashSet<Services>();\r
- align_services.add(Services.DisemblWS);\r
- align_services.add(Services.GlobPlotWS);\r
- align_services.add(Services.IUPredWS);\r
- align_services.add(Services.JronnWS);\r
-\r
- Category disorder = new Category(CATEGORY_DISORDER, disorder_services);\r
- Set<Services> conservation_services = new HashSet<Services>();\r
- align_services.add(Services.AAConWS);\r
-\r
- Category conservation = new Category(CATEGORY_CONSERVATION,\r
- conservation_services);\r
-\r
- Set<Category> categories = new HashSet<Category>();\r
- categories.add(alignment);\r
- categories.add(disorder);\r
- categories.add(conservation);\r
-\r
- return categories;\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- final int prime = 31;\r
- int result = 1;\r
- result = prime * result + ((name == null) ? 0 : name.hashCode());\r
- return result;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (this == obj)\r
- return true;\r
- if (obj == null)\r
- return false;\r
- if (getClass() != obj.getClass())\r
- return false;\r
- Category other = (Category) obj;\r
- if (name == null) {\r
- if (other.name != null)\r
- return false;\r
- } else if (!name.equals(other.name))\r
- return false;\r
- return true;\r
- }\r
-\r
-}\r