Changeset 54 in tmcsimulator for trunk/src/tmcsim/cadsimulator/Coordinator.java
- Timestamp:
- 03/14/2017 04:20:05 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/tmcsim/cadsimulator/Coordinator.java (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/cadsimulator/Coordinator.java
r44 r54 38 38 import tmcsim.client.cadclientgui.data.Incident; 39 39 import tmcsim.client.cadclientgui.data.IncidentEvent; 40 import tmcsim.client.cadclientgui.data.Unit; 40 41 import tmcsim.client.cadclientgui.enums.CADDataEnums.CARDFILE; 41 42 import tmcsim.client.cadclientgui.enums.CADDataEnums.EditCommand; … … 87 88 implements CoordinatorInterface 88 89 { 89 90 90 /** 91 91 * Error logger. … … 133 133 } 134 134 135 /** Dependency Injection for testing */ 136 void setCadData(CADData theData) 137 { 138 cadData = theData; 139 } 140 135 141 public void registerForCallback(CADClientInterface client) throws RemoteException 136 142 { … … 914 920 if (tag.equals(INC_TABLE.COMMENTS_NOTES)) 915 921 { 916 return cadData.getIncident(incidentId).getCommentsNotesTable(); 922 Incident myIncident = cadData.getIncident(incidentId); 923 if (myIncident == null) return new DefaultTableModel(); 924 return myIncident.getCommentsNotesTable(); 917 925 } 918 926 return null; … … 955 963 public Object getCadDataIncVal(INC_VAL tag, int incidentId) throws RemoteException 956 964 { 957 if (tag.equals(INC_VAL.LOG_NUM)) 958 { 959 return cadData.getIncident(incidentId).getLogNum(); 960 } 961 else if (tag.equals(INC_VAL.MASTER_INC)) 962 { 963 return cadData.getIncident(incidentId).getMasterInc(); 964 } 965 else if (tag.equals(INC_VAL.OAU)) 966 { 967 return cadData.getIncident(incidentId).getOau(); 968 } 969 else if (tag.equals(INC_VAL.P)) 970 { 971 return cadData.getIncident(incidentId).getP(); 972 } 973 else if (tag.equals(INC_VAL.DESCRIPTION)) 974 { 975 return cadData.getIncident(incidentId).getDescription(); 976 } 977 else if (tag.equals(INC_VAL.RP)) 978 { 979 return cadData.getIncident(incidentId).getRp(); 980 } 981 else if (tag.equals(INC_VAL.RP_TYPE)) 982 { 983 return cadData.getIncident(incidentId).getRpType(); 984 } 985 else if (tag.equals(INC_VAL.ALI)) 986 { 987 return cadData.getIncident(incidentId).getAli(); 988 } 989 else if (tag.equals(INC_VAL.MEDIA)) 990 { 991 return cadData.getIncident(incidentId).getMedia(); 992 } 993 else 994 { 995 throw new RemoteException("Wrong Enum sent into Coordinator.getCadDataIncVal"); 965 Incident current = cadData.getIncident(incidentId); 966 if (current != null) 967 { 968 if (tag.equals(INC_VAL.LOG_NUM)) 969 { 970 return current.getLogNum(); 971 } 972 else if (tag.equals(INC_VAL.MASTER_INC)) 973 { 974 return current.getMasterInc(); 975 } 976 else if (tag.equals(INC_VAL.OAU)) 977 { 978 return current.getOau(); 979 } 980 else if (tag.equals(INC_VAL.P)) 981 { 982 return current.getP(); 983 } 984 else if (tag.equals(INC_VAL.DESCRIPTION)) 985 { 986 return current.getDescription(); 987 } 988 else if (tag.equals(INC_VAL.RP)) 989 { 990 return current.getRp(); 991 } 992 else if (tag.equals(INC_VAL.RP_TYPE)) 993 { 994 return current.getRpType(); 995 } 996 else if (tag.equals(INC_VAL.ALI)) 997 { 998 return current.getAli(); 999 } 1000 else if (tag.equals(INC_VAL.MEDIA)) 1001 { 1002 return current.getMedia(); 1003 } 1004 else 1005 { 1006 throw new RemoteException("Wrong Enum sent into Coordinator.getCadDataIncVal"); 1007 } 1008 } 1009 else 1010 { 1011 return null; 996 1012 } 997 1013 } … … 1049 1065 public String getCadDataIncLoc(INC_LOC tag, int incidentId) throws RemoteException 1050 1066 { 1051 if (tag.equals(INC_LOC.ADDRESS)) 1052 { 1053 return cadData.getIncident(incidentId).getIncidentLocation().getAddress(); 1054 } 1055 else if (tag.equals(INC_LOC.LOC)) 1056 { 1057 return cadData.getIncident(incidentId).getIncidentLocation().getLoc(); 1058 } 1059 else if (tag.equals(INC_LOC.CITY)) 1060 { 1061 return cadData.getIncident(incidentId).getIncidentLocation().getCity(); 1062 } 1063 else if (tag.equals(INC_LOC.COUNTY)) 1064 { 1065 return cadData.getIncident(incidentId).getIncidentLocation().getCounty(); 1066 } 1067 else if (tag.equals(INC_LOC.STATE)) 1068 { 1069 return cadData.getIncident(incidentId).getIncidentLocation().getState(); 1070 } 1071 else if (tag.equals(INC_LOC.ZIP)) 1072 { 1073 return cadData.getIncident(incidentId).getIncidentLocation().getZip(); 1074 } 1075 else if (tag.equals(INC_LOC.BEAT)) 1076 { 1077 return cadData.getIncident(incidentId).getIncidentLocation().getBeat(); 1078 } 1079 else if (tag.equals(INC_LOC.AREA)) 1080 { 1081 return cadData.getIncident(incidentId).getIncidentLocation().getArea(); 1082 } 1083 else if (tag.equals(INC_LOC.SECTOR)) 1084 { 1085 return cadData.getIncident(incidentId).getIncidentLocation().getSector(); 1086 } 1087 else if (tag.equals(INC_LOC.SECTOR_CODE)) 1088 { 1089 return cadData.getIncident(incidentId).getIncidentLocation().getSectorCode(); 1090 } 1091 else if (tag.equals(INC_LOC.DIVISION)) 1092 { 1093 return cadData.getIncident(incidentId).getIncidentLocation().getDivision(); 1094 } 1095 else if (tag.equals(INC_LOC.APT)) 1096 { 1097 return cadData.getIncident(incidentId).getIncidentLocation().getApt(); 1098 } 1099 else if (tag.equals(INC_LOC.BUILDING)) 1100 { 1101 return cadData.getIncident(incidentId).getIncidentLocation().getBuilding(); 1102 } 1103 else if (tag.equals(INC_LOC.CROSS_ST)) 1104 { 1105 return cadData.getIncident(incidentId).getIncidentLocation().getCrossSt(); 1106 } 1107 else if (tag.equals(INC_LOC.LAW)) 1108 { 1109 return cadData.getIncident(incidentId).getIncidentLocation().getLaw(); 1110 } 1111 else if (tag.equals(INC_LOC.FIRE)) 1112 { 1113 return cadData.getIncident(incidentId).getIncidentLocation().getFire(); 1114 } 1115 else if (tag.equals(INC_LOC.EMS)) 1116 { 1117 return cadData.getIncident(incidentId).getIncidentLocation().getEms(); 1118 } 1119 else 1120 { 1121 throw new RemoteException("Wrong Enum sent into Coordinator.getCadDataIncLoc"); 1067 Incident current = cadData.getIncident(incidentId); 1068 if (current != null) 1069 { 1070 if (tag.equals(INC_LOC.ADDRESS)) 1071 { 1072 return current.getIncidentLocation().getAddress(); 1073 } 1074 else if (tag.equals(INC_LOC.LOC)) 1075 { 1076 return current.getIncidentLocation().getLoc(); 1077 } 1078 else if (tag.equals(INC_LOC.CITY)) 1079 { 1080 return current.getIncidentLocation().getCity(); 1081 } 1082 else if (tag.equals(INC_LOC.COUNTY)) 1083 { 1084 return current.getIncidentLocation().getCounty(); 1085 } 1086 else if (tag.equals(INC_LOC.STATE)) 1087 { 1088 return current.getIncidentLocation().getState(); 1089 } 1090 else if (tag.equals(INC_LOC.ZIP)) 1091 { 1092 return current.getIncidentLocation().getZip(); 1093 } 1094 else if (tag.equals(INC_LOC.BEAT)) 1095 { 1096 return current.getIncidentLocation().getBeat(); 1097 } 1098 else if (tag.equals(INC_LOC.AREA)) 1099 { 1100 return current.getIncidentLocation().getArea(); 1101 } 1102 else if (tag.equals(INC_LOC.SECTOR)) 1103 { 1104 return current.getIncidentLocation().getSector(); 1105 } 1106 else if (tag.equals(INC_LOC.SECTOR_CODE)) 1107 { 1108 return current.getIncidentLocation().getSectorCode(); 1109 } 1110 else if (tag.equals(INC_LOC.DIVISION)) 1111 { 1112 return current.getIncidentLocation().getDivision(); 1113 } 1114 else if (tag.equals(INC_LOC.APT)) 1115 { 1116 return current.getIncidentLocation().getApt(); 1117 } 1118 else if (tag.equals(INC_LOC.BUILDING)) 1119 { 1120 return current.getIncidentLocation().getBuilding(); 1121 } 1122 else if (tag.equals(INC_LOC.CROSS_ST)) 1123 { 1124 return current.getIncidentLocation().getCrossSt(); 1125 } 1126 else if (tag.equals(INC_LOC.LAW)) 1127 { 1128 return current.getIncidentLocation().getLaw(); 1129 } 1130 else if (tag.equals(INC_LOC.FIRE)) 1131 { 1132 return current.getIncidentLocation().getFire(); 1133 } 1134 else if (tag.equals(INC_LOC.EMS)) 1135 { 1136 return current.getIncidentLocation().getEms(); 1137 } 1138 else 1139 { 1140 throw new RemoteException("Wrong Enum sent into Coordinator.getCadDataIncLoc"); 1141 } 1142 } 1143 else 1144 { 1145 return ""; 1122 1146 } 1123 1147 } … … 1132 1156 public void setCadDataIncLoc(INC_LOC tag, int incidentId, String value) throws RemoteException 1133 1157 { 1134 if (tag.equals(INC_LOC.ADDRESS)) 1135 { 1136 cadData.getIncident(incidentId).getIncidentLocation().setAddress(value); 1137 } 1138 else if (tag.equals(INC_LOC.LOC)) 1139 { 1140 cadData.getIncident(incidentId).getIncidentLocation().setLoc(value); 1141 } 1142 else if (tag.equals(INC_LOC.CITY)) 1143 { 1144 cadData.getIncident(incidentId).getIncidentLocation().setCity(value); 1145 } 1146 else if (tag.equals(INC_LOC.COUNTY)) 1147 { 1148 cadData.getIncident(incidentId).getIncidentLocation().setCounty(value); 1149 } 1150 else if (tag.equals(INC_LOC.STATE)) 1151 { 1152 cadData.getIncident(incidentId).getIncidentLocation().setState(value); 1153 } 1154 else if (tag.equals(INC_LOC.ZIP)) 1155 { 1156 cadData.getIncident(incidentId).getIncidentLocation().setZip(value); 1157 } 1158 else if (tag.equals(INC_LOC.BEAT)) 1159 { 1160 cadData.getIncident(incidentId).getIncidentLocation().setBeat(value); 1161 } 1162 else if (tag.equals(INC_LOC.AREA)) 1163 { 1164 cadData.getIncident(incidentId).getIncidentLocation().setArea(value); 1165 } 1166 else if (tag.equals(INC_LOC.SECTOR)) 1167 { 1168 cadData.getIncident(incidentId).getIncidentLocation().setSector(value); 1169 } 1170 else if (tag.equals(INC_LOC.SECTOR_CODE)) 1171 { 1172 cadData.getIncident(incidentId).getIncidentLocation().setSectorCode(value); 1173 } 1174 else if (tag.equals(INC_LOC.DIVISION)) 1175 { 1176 cadData.getIncident(incidentId).getIncidentLocation().setDivision(value); 1177 } 1178 else if (tag.equals(INC_LOC.APT)) 1179 { 1180 cadData.getIncident(incidentId).getIncidentLocation().setApt(value); 1181 } 1182 else if (tag.equals(INC_LOC.BUILDING)) 1183 { 1184 cadData.getIncident(incidentId).getIncidentLocation().setBuilding(value); 1185 } 1186 else if (tag.equals(INC_LOC.CROSS_ST)) 1187 { 1188 cadData.getIncident(incidentId).getIncidentLocation().setCrossSt(value); 1189 } 1190 else if (tag.equals(INC_LOC.LAW)) 1191 { 1192 cadData.getIncident(incidentId).getIncidentLocation().setLaw(value); 1193 } 1194 else if (tag.equals(INC_LOC.FIRE)) 1195 { 1196 cadData.getIncident(incidentId).getIncidentLocation().setFire(value); 1197 } 1198 else if (tag.equals(INC_LOC.EMS)) 1199 { 1200 cadData.getIncident(incidentId).getIncidentLocation().setEms(value); 1201 } 1202 else 1203 { 1204 throw new RemoteException("Wrong Enum sent into Coordinator.setCadDataIncLoc"); 1158 Incident current = cadData.getIncident(incidentId); 1159 if (current != null) 1160 { 1161 if (tag.equals(INC_LOC.ADDRESS)) 1162 { 1163 current.getIncidentLocation().setAddress(value); 1164 } 1165 else if (tag.equals(INC_LOC.LOC)) 1166 { 1167 current.getIncidentLocation().setLoc(value); 1168 } 1169 else if (tag.equals(INC_LOC.CITY)) 1170 { 1171 current.getIncidentLocation().setCity(value); 1172 } 1173 else if (tag.equals(INC_LOC.COUNTY)) 1174 { 1175 current.getIncidentLocation().setCounty(value); 1176 } 1177 else if (tag.equals(INC_LOC.STATE)) 1178 { 1179 current.getIncidentLocation().setState(value); 1180 } 1181 else if (tag.equals(INC_LOC.ZIP)) 1182 { 1183 current.getIncidentLocation().setZip(value); 1184 } 1185 else if (tag.equals(INC_LOC.BEAT)) 1186 { 1187 current.getIncidentLocation().setBeat(value); 1188 } 1189 else if (tag.equals(INC_LOC.AREA)) 1190 { 1191 current.getIncidentLocation().setArea(value); 1192 } 1193 else if (tag.equals(INC_LOC.SECTOR)) 1194 { 1195 current.getIncidentLocation().setSector(value); 1196 } 1197 else if (tag.equals(INC_LOC.SECTOR_CODE)) 1198 { 1199 current.getIncidentLocation().setSectorCode(value); 1200 } 1201 else if (tag.equals(INC_LOC.DIVISION)) 1202 { 1203 current.getIncidentLocation().setDivision(value); 1204 } 1205 else if (tag.equals(INC_LOC.APT)) 1206 { 1207 current.getIncidentLocation().setApt(value); 1208 } 1209 else if (tag.equals(INC_LOC.BUILDING)) 1210 { 1211 current.getIncidentLocation().setBuilding(value); 1212 } 1213 else if (tag.equals(INC_LOC.CROSS_ST)) 1214 { 1215 current.getIncidentLocation().setCrossSt(value); 1216 } 1217 else if (tag.equals(INC_LOC.LAW)) 1218 { 1219 current.getIncidentLocation().setLaw(value); 1220 } 1221 else if (tag.equals(INC_LOC.FIRE)) 1222 { 1223 current.getIncidentLocation().setFire(value); 1224 } 1225 else if (tag.equals(INC_LOC.EMS)) 1226 { 1227 current.getIncidentLocation().setEms(value); 1228 } 1229 else 1230 { 1231 throw new RemoteException("Wrong Enum sent into Coordinator.setCadDataIncLoc"); 1232 } 1233 } 1234 else 1235 { 1236 return; 1205 1237 } 1206 1238 } … … 2076 2108 public UnitStatusEnums getCadDataUnitStatus(String unitNum) throws RemoteException 2077 2109 { 2078 return cadData.getUnit(unitNum).getUnitStatus(); 2110 // Validate input parameter 2111 if (unitNum.equals("")) 2112 { 2113 coorLogger.logp(Level.INFO, "Coordinator", "getCadDataUnitStatus", 2114 "Unitnum parameter is blank.", "Error"); 2115 return UnitStatusEnums.NotAssignable; 2116 } 2117 else 2118 { 2119 Unit desiredUnit = cadData.getUnit(unitNum); 2120 // If it exists 2121 if (desiredUnit != null) 2122 { 2123 // Fetch and return its status (an enum) 2124 return desiredUnit.getUnitStatus(); 2125 } 2126 else 2127 { 2128 return UnitStatusEnums.NotAssignable; 2129 } 2130 } 2079 2131 } 2080 2132 … … 2089 2141 public String getCadDataUnitValue(String unitNum, UNIT_TAGS tag) throws RemoteException 2090 2142 { 2091 if (tag.equals(UNIT_TAGS.MASTER_INC_NUM)) 2092 { 2093 return cadData.getUnit(unitNum).getMasterInc(); 2094 } 2095 else if (tag.equals(UNIT_TAGS.STATUS)) 2096 { 2097 return cadData.getUnit(unitNum).getStatus(); 2098 } 2099 else if (tag.equals(UNIT_TAGS.OOS)) 2100 { 2101 return cadData.getUnit(unitNum).getOos(); 2102 } 2103 else if (tag.equals(UNIT_TAGS.TYPE)) 2104 { 2105 return cadData.getUnit(unitNum).getType(); 2106 } 2107 else if (tag.equals(UNIT_TAGS.CURR_LOC)) 2108 { 2109 return cadData.getUnit(unitNum).getCurrentLocation(); 2110 } 2111 else if (tag.equals(UNIT_TAGS.DESTINATION)) 2112 { 2113 return cadData.getUnit(unitNum).getDestination(); 2114 } 2115 else if (tag.equals(UNIT_TAGS.MISC_INFO)) 2116 { 2117 return cadData.getUnit(unitNum).getMisc(); 2118 } 2119 else if (tag.equals(UNIT_TAGS.STACK)) 2120 { 2121 return cadData.getUnit(unitNum).getStack(); 2122 } 2123 else if (tag.equals(UNIT_TAGS.AREA)) 2124 { 2125 return cadData.getUnit(unitNum).getArea(); 2126 } 2127 else if (tag.equals(UNIT_TAGS.OFFICER)) 2128 { 2129 return cadData.getUnit(unitNum).getOfficer(); 2130 } 2131 else if (tag.equals(UNIT_TAGS.BADGE_NUM)) 2132 { 2133 return cadData.getUnit(unitNum).getBadge(); 2134 } 2135 else if (tag.equals(UNIT_TAGS.TIMER)) 2136 { 2137 return cadData.getUnit(unitNum).getTimerInString(); 2138 } 2139 else if (tag.equals(UNIT_TAGS.OFFICE)) 2140 { 2141 return cadData.getUnit(unitNum).getOffice(); 2142 } 2143 else if (tag.equals(UNIT_TAGS.P)) 2144 { 2145 return cadData.getUnit(unitNum).getP(); 2146 } 2147 else if (tag.equals(UNIT_TAGS.AGY)) 2148 { 2149 return cadData.getUnit(unitNum).getAgy(); 2150 } 2151 else if (tag.equals(UNIT_TAGS.ALIAS)) 2152 { 2153 return cadData.getUnit(unitNum).getAlias(); 2154 } 2155 else 2156 { 2157 throw new RemoteException("Wrong Enum sent into Coordinator.getCadDataUnitValue"); 2143 // Fetch unit, given it's string representation 2144 Unit desiredUnit = cadData.getUnit(unitNum); 2145 // If it exists 2146 if (desiredUnit != null) 2147 { 2148 if (tag.equals(UNIT_TAGS.MASTER_INC_NUM)) 2149 { 2150 return desiredUnit.getMasterInc(); 2151 } 2152 else if (tag.equals(UNIT_TAGS.STATUS)) 2153 { 2154 return desiredUnit.getStatus(); 2155 } 2156 else if (tag.equals(UNIT_TAGS.OOS)) 2157 { 2158 return desiredUnit.getOos(); 2159 } 2160 else if (tag.equals(UNIT_TAGS.TYPE)) 2161 { 2162 return desiredUnit.getType(); 2163 } 2164 else if (tag.equals(UNIT_TAGS.CURR_LOC)) 2165 { 2166 return desiredUnit.getCurrentLocation(); 2167 } 2168 else if (tag.equals(UNIT_TAGS.DESTINATION)) 2169 { 2170 return desiredUnit.getDestination(); 2171 } 2172 else if (tag.equals(UNIT_TAGS.MISC_INFO)) 2173 { 2174 return desiredUnit.getMisc(); 2175 } 2176 else if (tag.equals(UNIT_TAGS.STACK)) 2177 { 2178 return desiredUnit.getStack(); 2179 } 2180 else if (tag.equals(UNIT_TAGS.AREA)) 2181 { 2182 return desiredUnit.getArea(); 2183 } 2184 else if (tag.equals(UNIT_TAGS.OFFICER)) 2185 { 2186 return desiredUnit.getOfficer(); 2187 } 2188 else if (tag.equals(UNIT_TAGS.BADGE_NUM)) 2189 { 2190 return desiredUnit.getBadge(); 2191 } 2192 else if (tag.equals(UNIT_TAGS.TIMER)) 2193 { 2194 return desiredUnit.getTimerInString(); 2195 } 2196 else if (tag.equals(UNIT_TAGS.OFFICE)) 2197 { 2198 return desiredUnit.getOffice(); 2199 } 2200 else if (tag.equals(UNIT_TAGS.P)) 2201 { 2202 return desiredUnit.getP(); 2203 } 2204 else if (tag.equals(UNIT_TAGS.AGY)) 2205 { 2206 return desiredUnit.getAgy(); 2207 } 2208 else if (tag.equals(UNIT_TAGS.ALIAS)) 2209 { 2210 return desiredUnit.getAlias(); 2211 } 2212 else 2213 { 2214 throw new RemoteException("Wrong Enum sent into Coordinator.getCadDataUnitValue"); 2215 } 2216 } 2217 else 2218 { 2219 coorLogger.logp(Level.INFO, "Coordinator", "getCadDataUnitValue", 2220 "Desired unit not found: " + unitNum 2221 + ". Proceeding with empty string value.", "Error"); 2222 return ""; 2158 2223 } 2159 2224 }
Note: See TracChangeset
for help on using the changeset viewer.
