| 1 | |
package org.codeforamerica.open311.facade.data; |
| 2 | |
|
| 3 | |
import java.io.Serializable; |
| 4 | |
|
| 5 | |
import org.codeforamerica.open311.facade.exceptions.APIWrapperException; |
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
public class Service implements Serializable { |
| 14 | |
private static final long serialVersionUID = 1124990264010718071L; |
| 15 | |
private String serviceCode; |
| 16 | |
private String serviceName; |
| 17 | |
private String description; |
| 18 | |
private Boolean metadata; |
| 19 | |
private Type type; |
| 20 | |
private String[] keywords; |
| 21 | |
private String group; |
| 22 | |
|
| 23 | |
public Service(String serviceCode, String serviceName, String description, |
| 24 | |
Boolean metadata, Type type, String[] keywords, String group) { |
| 25 | 13 | super(); |
| 26 | 13 | this.serviceCode = serviceCode; |
| 27 | 13 | this.serviceName = serviceName; |
| 28 | 13 | this.description = description; |
| 29 | 13 | this.metadata = metadata; |
| 30 | 13 | this.type = type; |
| 31 | 13 | this.keywords = keywords; |
| 32 | 13 | this.group = group; |
| 33 | 13 | } |
| 34 | |
|
| 35 | |
public String getServiceCode() { |
| 36 | 4 | return serviceCode; |
| 37 | |
} |
| 38 | |
|
| 39 | |
public String getServiceName() { |
| 40 | 3 | return serviceName; |
| 41 | |
} |
| 42 | |
|
| 43 | |
public String getDescription() { |
| 44 | 3 | return description; |
| 45 | |
} |
| 46 | |
|
| 47 | |
public Boolean hasMetadata() { |
| 48 | 3 | return metadata; |
| 49 | |
} |
| 50 | |
|
| 51 | |
public Type getType() { |
| 52 | 3 | return type; |
| 53 | |
} |
| 54 | |
|
| 55 | |
public String[] getKeywords() { |
| 56 | 3 | return keywords; |
| 57 | |
} |
| 58 | |
|
| 59 | |
public String getGroup() { |
| 60 | 3 | return group; |
| 61 | |
} |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
public ServiceDefinition getServiceDefinition() throws APIWrapperException { |
| 76 | 2 | return RelationshipManager.getInstance() |
| 77 | |
.getServiceDefinitionFromService(this); |
| 78 | |
} |
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | 5 | public static enum Type { |
| 85 | 1 | REALTIME, BATCH, BLACKBOX; |
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
public static Type getFromString(String type) { |
| 94 | 18 | type = type.toLowerCase(); |
| 95 | 18 | if (type.equals("realtime")) { |
| 96 | 12 | return REALTIME; |
| 97 | |
} |
| 98 | 6 | if (type.equals("batch")) { |
| 99 | 2 | return BATCH; |
| 100 | |
} |
| 101 | 4 | if (type.equals("blackbox")) { |
| 102 | 2 | return BLACKBOX; |
| 103 | |
} |
| 104 | 2 | return null; |
| 105 | |
} |
| 106 | |
} |
| 107 | |
|
| 108 | |
public String toString() { |
| 109 | 2 | return "[" + this.serviceCode + "] " + this.serviceName + " (" |
| 110 | |
+ this.description + ")"; |
| 111 | |
} |
| 112 | |
|
| 113 | |
} |