Changeset 1309
- Timestamp:
- Mar 4, 2011, 1:58:17 PM (13 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/install.jsp
r1288 r1309 48 48 49 49 var numMissing = 0; 50 var numWarnings = 0; 50 51 var numErrors = 0; 51 52 var checks = response.checks; … … 56 57 { 57 58 var check = checks[i]; 58 var icon = check.status == 'ok' ? 'ok.gif' : 'error.gif'; 59 if (check.status == 'missing') numMissing++; 60 if (check.status == 'error') numErrors++; 59 var icon = 'ok.gif'; 60 if (check.status == 'missing') 61 { 62 numMissing++; 63 icon = 'error.gif'; 64 } 65 if (check.status == 'error') 66 { 67 numErrors++; 68 icon = 'error.gif'; 69 } 70 if (check.status == 'warning') 71 { 72 numWarnings++; 73 icon = 'warning.gif'; 74 } 61 75 if (lastItemType != check.itemType) 62 76 { 63 html += '<tr class="newitemtype" ><td>'+check.itemType+'</td>';77 html += '<tr class="newitemtype" valign="top"><td>'+check.itemType+'</td>'; 64 78 } 65 79 else 66 80 { 67 html += '<tr ><td> </td>';81 html += '<tr class="sameitemtype" valign="top"><td> </td>'; 68 82 } 69 83 lastItemType = check.itemType; 70 html += '<td><div class="link" onclick="itemOnClick(event, \''+check.itemType+'\','+check.id+')"'; 71 html += ' title="View this item (use CTRL, ALT or SHIFT to edit)">'+check.name+'</div></td>'; 72 html += '<td><img src="../../images/'+icon+'"></td>'; 73 html += '<td>'+check.message+'</td>'; 74 html += '</tr>'; 84 if (check.id) 85 { 86 html += '<td><div class="link" onclick="itemOnClick(event, \''+check.itemType+'\','+check.id+')"'; 87 html += ' title="View this item (use CTRL, ALT or SHIFT to edit)">'+check.name+'</div></td>'; 88 } 89 else 90 { 91 html += '<td><i>' + check.name + '</i></td>'; 92 } 93 html += '<td><img src="../../images/'+icon+'"></td><td>'; 94 if (check.messages.length > 1) 95 { 96 for (var m = 0; m < check.messages.length; m++) 97 { 98 html += '• '+check.messages[m] + '<br>'; 99 } 100 } 101 else 102 { 103 html += check.messages; 104 } 105 html += '</td></tr>'; 75 106 } 76 107 html += '</table>'; … … 81 112 { 82 113 setFatalError(numErrors+' errors was detected. You need to fix those manually.'); 114 } 115 else if (numWarnings > 0) 116 { 117 setWarningMessage(numWarnings+' warnings was detected. Reggie may still work. If not, you need to fix it manually.'); 83 118 } 84 119 Main.showHide('createMissingItems', numMissing > 0); … … 96 131 setInnerHTML('errorMessage', message); 97 132 Main.show('errorMessage'); 133 } 134 135 function setWarningMessage(message) 136 { 137 setInnerHTML('warningMessage.message', message); 138 Main.show('warningMessage'); 98 139 } 99 140 … … 143 184 .report .newitemtype td 144 185 { 145 border-top: 1px solid #999999; 186 border-top: 1px solid #999999; 187 } 188 .report .sameitemtype td 189 { 190 border-top: 1px dotted #cccccc; 146 191 } 147 192 … … 156 201 157 202 <div id="validationResult" style="margin-left: 20px;">Checking; please wait...</div> 158 159 <div class="error" id="errorMessage" style="display: none; width: 800px; margin-left: 20px; margin-bottom: 0px;"></div>160 203 161 204 <div id="createMissingItems" style="display:none; margin-left: 20px; margin-top: 10px;"> … … 165 208 </div> 166 209 210 <div class="error" id="errorMessage" style="display: none; width: 800px; margin-left: 20px; margin-bottom: 0px;"></div> 211 212 <base:note id="warningMessage" type="warning" style="display: none; width: 800px; margin-left: 20px; margin-top: 20px;"><div id="warningMessage.message"></div></base:note> 213 167 214 <pre> 168 215 <div id="debug"></div> -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java
r1288 r1309 24 24 import net.sf.basedb.core.MultiPermissions; 25 25 import net.sf.basedb.core.Permission; 26 import net.sf.basedb.core.Project; 26 27 import net.sf.basedb.core.SessionControl; 27 28 import net.sf.basedb.core.SharedItem; … … 67 68 boolean createIfMissing = "Install".equals(cmd); 68 69 JSONArray jsonChecks = new JSONArray(); 70 71 // Project checks 72 jsonChecks.add(checkActiveProject(dc)); 73 69 74 // Group checks 70 75 jsonChecks.add(checkGroup(dc, Reggie.GROUP_PATIENT_CURATOR, createIfMissing)); … … 166 171 { 167 172 JSONObject json = new JSONObject(); 173 JSONArray jsonMessages = new JSONArray(); 168 174 json.put("itemType", Item.ANNOTATIONTYPE.name()); 169 175 json.put("name", name); 170 176 171 List<AnnotationType> result = Reggie.listAnnotationTypes(dc, itemType, name);177 List<AnnotationType> result = Reggie.listAnnotationTypes(dc, null, name); 172 178 if (result.size() == 0) 173 179 { … … 177 183 json.put("id", at.getId()); 178 184 json.put("status", "ok"); 179 json .put("message","Created");185 jsonMessages.add("Created"); 180 186 } 181 187 else 182 188 { 183 189 json.put("status", "missing"); 184 json .put("message","Not found");190 jsonMessages.add("Not found"); 185 191 } 186 192 } … … 188 194 { 189 195 json.put("status", "error"); 190 json .put("message","Found > 1 annotation type");196 jsonMessages.add("Found > 1 annotation type"); 191 197 } 192 198 else … … 194 200 AnnotationType at = result.get(0); 195 201 json.put("id", at.getId()); 196 json.put("status", "ok"); 197 json.put("message", "Ok"); // For now -- more checks below 202 json.put("status", "ok");// For now -- more checks below 198 203 if (permissions != null && !permissions.checkPermissions(at)) 199 204 { 205 json.put("status", "warning"); 206 jsonMessages.add(permissions.getMessage()); 207 } 208 if (!at.isEnabledForItem(itemType)) 209 { 200 210 json.put("status", "error"); 201 json .put("message", permissions.getMessage());202 } 203 else if (!at.isEnabledForItem(itemType))211 jsonMessages.add("Not enabled for " + itemType.name()); 212 } 213 if (at.getValueType() != valueType) 204 214 { 205 215 json.put("status", "error"); 206 json .put("message", "Found, but is not enabled for " + itemType.name());207 } 208 else if (at.getValueType() != valueType)216 jsonMessages.add("Is not a " + valueType.name() + " type"); 217 } 218 if (at.getMultiplicity() != multiplicity) 209 219 { 210 220 json.put("status", "error"); 211 json .put("message", "Found, but is not a " + valueType.name() + " type");212 } 213 else if (at.getMultiplicity() != multiplicity)221 jsonMessages.add("Should have multiplicity=" + (multiplicity == 0 ? "unlimited" : multiplicity)); 222 } 223 if (at.isEnumeration() && enumOptions == null) 214 224 { 215 225 json.put("status", "error"); 216 json.put("message", "Found, but should have multiplicity=" + (multiplicity == 0 ? "unlimited" : multiplicity)); 217 } 218 else if (at.isEnumeration() && enumOptions == null) 219 { 220 json.put("status", "error"); 221 json.put("message", "Found, but should not be an enumeration"); 222 } 223 else if (enumOptions != null) 226 jsonMessages.add("Should not be an enumeration"); 227 } 228 if (enumOptions != null) 224 229 { 225 230 if (!at.isEnumeration()) 226 231 { 227 232 json.put("status", "error"); 228 json .put("message", "Found, but doesn't have options: " + enumOptions.getList());233 jsonMessages.add("Is not enumeration of: " + enumOptions.getList()); 229 234 } 230 235 else if (!EqualsHelper.invariantEquals(at.getValues().toArray(), enumOptions.getArray())) 231 236 { 232 237 json.put("status", "error"); 233 json .put("message", "Found, but doesn't haveoptions: " + enumOptions.getList());238 jsonMessages.add("Doesn't have all options: " + enumOptions.getList()); 234 239 } 235 240 } 236 237 } 241 } 242 if (jsonMessages.size() == 0) jsonMessages.add("Ok"); 243 json.put("messages", jsonMessages); 238 244 return json; 239 245 … … 277 283 { 278 284 JSONObject json = new JSONObject(); 285 JSONArray jsonMessages = new JSONArray(); 279 286 json.put("itemType", Item.GROUP.name()); 280 287 json.put("name", name); 288 281 289 List<Group> result = Reggie.listGroups(dc, name); 282 290 if (result.size() == 0) … … 287 295 json.put("id", g.getId()); 288 296 json.put("status", "ok"); 289 json .put("message","Created");297 jsonMessages.add("Created"); 290 298 } 291 299 else 292 300 { 293 301 json.put("status", "missing"); 294 json .put("message","Not found");302 jsonMessages.add("Not found"); 295 303 } 296 304 } … … 298 306 { 299 307 json.put("status", "error"); 300 json .put("message","Found > 1 group");308 jsonMessages.add("Found > 1 group"); 301 309 } 302 310 else … … 307 315 json.put("message", "Ok"); 308 316 } 317 if (jsonMessages.size() == 0) jsonMessages.add("Ok"); 318 json.put("messages", jsonMessages); 309 319 return json; 310 311 312 } 313 320 } 321 322 @SuppressWarnings("unchecked") 323 public JSONObject checkActiveProject(DbControl dc) 324 { 325 JSONObject json = new JSONObject(); 326 JSONArray jsonMessages = new JSONArray(); 327 json.put("itemType", Item.PROJECT.name()); 328 329 int projectId = dc.getSessionControl().getActiveProjectId(); 330 if (projectId == 0) 331 { 332 json.put("status", "warning"); 333 json.put("name", "not selected"); 334 jsonMessages.add("No active project"); 335 } 336 else 337 { 338 Project p = Project.getById(dc, projectId); 339 json.put("name", p.getName()); 340 json.put("id", projectId); 341 json.put("status", "ok"); 342 } 343 if (jsonMessages.size() == 0) jsonMessages.add("Ok"); 344 json.put("messages", jsonMessages); 345 return json; 346 } 347 348 314 349 /** 315 350 Store options for enumerated annotation types.
Note: See TracChangeset
for help on using the changeset viewer.