|
81 | 81 | import org.labkey.api.util.ExceptionUtil; |
82 | 82 | import org.labkey.api.util.FileUtil; |
83 | 83 | import org.labkey.api.util.HtmlString; |
84 | | -import org.labkey.api.util.HtmlStringBuilder; |
85 | 84 | import org.labkey.api.util.JsonUtil; |
86 | 85 | import org.labkey.api.util.Pair; |
87 | 86 | import org.labkey.api.util.URLHelper; |
|
109 | 108 | import java.util.Map; |
110 | 109 | import java.util.Set; |
111 | 110 |
|
| 111 | +import static org.labkey.api.util.DOM.BR; |
| 112 | +import static org.labkey.api.util.DOM.INPUT; |
| 113 | +import static org.labkey.api.util.DOM.P; |
| 114 | +import static org.labkey.api.util.DOM.TABLE; |
| 115 | +import static org.labkey.api.util.DOM.TD; |
| 116 | +import static org.labkey.api.util.DOM.TR; |
| 117 | +import static org.labkey.api.util.DOM.at; |
| 118 | +import static org.labkey.api.util.DOM.createHtmlFragment; |
| 119 | +import static org.labkey.api.util.DOM.Attribute.style; |
| 120 | + |
112 | 121 |
|
113 | 122 | public class LaboratoryController extends SpringActionController |
114 | 123 | { |
@@ -175,17 +184,13 @@ public void validateCommand(Object form, Errors errors) |
175 | 184 | @Override |
176 | 185 | public ModelAndView getConfirmView(Object form, BindException errors) throws Exception |
177 | 186 | { |
178 | | - HtmlStringBuilder sb = HtmlStringBuilder.of(); |
179 | | - sb.append("Certain assays can have performance improved by the addition of indexes, which can be suggested by modules. The following indexes are recommended for the assays installed on this server:<p>"); |
180 | | - |
181 | 187 | List<String> msgs = LaboratoryManager.get().createIndexes(getUser(), false, false); |
182 | 188 |
|
183 | | - for (String msg : msgs) |
184 | | - sb.append(msg).unsafeAppend("<br>"); |
185 | | - |
186 | | - sb.unsafeAppend("<p>Do you want to continue?</p>"); |
187 | | - |
188 | | - return new HtmlView(sb.getHtmlString()); |
| 189 | + return new HtmlView(createHtmlFragment( |
| 190 | + "Certain assays can have performance improved by the addition of indexes, which can be suggested by modules. The following indexes are recommended for the assays installed on this server:", |
| 191 | + P(msgs.stream().map(msg -> createHtmlFragment(msg, BR()))), |
| 192 | + P("Do you want to continue?") |
| 193 | + )); |
189 | 194 | } |
190 | 195 |
|
191 | 196 | @Override |
@@ -236,19 +241,12 @@ public ModelAndView getConfirmView(EnsureAssayFieldsForm form, BindException err |
236 | 241 | { |
237 | 242 | try |
238 | 243 | { |
239 | | - HtmlStringBuilder sb = HtmlStringBuilder.of(); |
240 | | - sb.append("This action will iterate all protocols for the assay ") |
241 | | - .append(form.getProviderName()) |
242 | | - .unsafeAppend(" and append any columns present in the definition, but lacking from that instance of the assay. The following changes will be made:<br><br>"); |
243 | 244 | List<String> messages = AssayHelper.ensureAssayFields(getUser(), form.getProviderName(), form.isRenameConflicts(), true); |
244 | | - for (String msg : messages) |
245 | | - { |
246 | | - sb.append(msg).unsafeAppend("<br><br>"); |
247 | | - } |
248 | | - |
249 | | - sb.unsafeAppend("<br>Do you want to continue?"); |
250 | | - |
251 | | - return new HtmlView(sb.getHtmlString()); |
| 245 | + return new HtmlView(createHtmlFragment( |
| 246 | + "This action will iterate all protocols for the assay " + form.getProviderName() + " and append any columns present in the definition, but lacking from that instance of the assay. The following changes will be made:", BR(), BR(), |
| 247 | + messages.stream().map(msg -> createHtmlFragment(msg, BR(), BR())), |
| 248 | + BR(), "Do you want to continue?" |
| 249 | + )); |
252 | 250 | } |
253 | 251 | catch (ChangePropertyDescriptorException e) |
254 | 252 | { |
@@ -314,25 +312,23 @@ public void validateCommand(SetTableIncrementForm form, Errors errors) |
314 | 312 | @Override |
315 | 313 | public ModelAndView getConfirmView(SetTableIncrementForm form, BindException errors) throws Exception |
316 | 314 | { |
317 | | - HtmlStringBuilder sb = HtmlStringBuilder.of(); |
318 | | - sb.unsafeAppend("This allows you to reset the current value for an auto-incrementing table<br><br>"); |
319 | | - sb.unsafeAppend("<table style='border-collapse: collapse;'>"); |
320 | | - |
321 | 315 | String schema = form.getSchemaName() == null ? "" : form.getSchemaName(); |
322 | | - sb.unsafeAppend("<tr><td>Schema:</td><td><input name=\"schema\" value=\"").append(schema).unsafeAppend("\"></td></tr>"); |
323 | | - |
324 | 316 | String query = form.getQueryName() == null ? "" : form.getQueryName(); |
325 | | - sb.unsafeAppend("<tr><td>Query:</td><td><input name=\"query\" value=\"").append(query).unsafeAppend("\"></td></tr>"); |
326 | 317 |
|
327 | 318 | ContainerIncrementingTable ti = getTable(schema, query, errors, false); |
328 | | - Integer value = null; |
| 319 | + Integer currentId = null; |
329 | 320 | if (ti != null) |
330 | | - value = ti.getCurrentId(getContainer()); |
331 | | - |
332 | | - sb.unsafeAppend("<tr><td>Value:</td><td><input name=\"value\" value=\"").append(value == null ? "" : value.toString()).unsafeAppend("\"></td></tr>"); |
333 | | - sb.unsafeAppend("</table><br>Do you want to continue?"); |
| 321 | + currentId = ti.getCurrentId(getContainer()); |
334 | 322 |
|
335 | | - return new HtmlView(sb.getHtmlString()); |
| 323 | + return new HtmlView(createHtmlFragment( |
| 324 | + "This allows you to reset the current value for an auto-incrementing table", BR(), BR(), |
| 325 | + TABLE(at(style, "border-collapse: collapse;"), |
| 326 | + TR(TD("Schema:"), TD(INPUT(at().name("schema").value(schema)))), |
| 327 | + TR(TD("Query:"), TD(INPUT(at().name("query").value(query)))), |
| 328 | + TR(TD("Value:"), TD(INPUT(at().name("value").value(currentId == null ? "" : currentId.toString())))) |
| 329 | + ), |
| 330 | + BR(), "Do you want to continue?" |
| 331 | + )); |
336 | 332 | } |
337 | 333 |
|
338 | 334 | @Override |
@@ -513,20 +509,18 @@ public void validateCommand(SetTableIncrementForm form, Errors errors) |
513 | 509 | @Override |
514 | 510 | public ModelAndView getConfirmView(SetTableIncrementForm form, BindException errors) throws Exception |
515 | 511 | { |
516 | | - HtmlStringBuilder sb = HtmlStringBuilder.of(); |
517 | | - sb.unsafeAppend("This allows you to initialize the autoincrementing column for the provided schema/query<br><br>"); |
518 | | - sb.unsafeAppend("This is very rarely required and was created as a helper for admins with a good deal of knowledge about this module. Under most cases these columns will be automatically populated and you will not need to worry about this. If you are unsure about this page, please post on the LabKey help forums, which are read by the authors of this module.<br><br>"); |
519 | | - sb.unsafeAppend("<table style='border-collapse: collapse;'>"); |
520 | | - |
521 | 512 | String schema = form.getSchemaName() == null ? "" : form.getSchemaName(); |
522 | | - sb.unsafeAppend("<tr><td>Schema:</td><td><input name=\"schema\" value=\"").append(schema).unsafeAppend("\"></td></tr>"); |
523 | | - |
524 | 513 | String query = form.getQueryName() == null ? "" : form.getQueryName(); |
525 | | - sb.unsafeAppend("<tr><td>Query:</td><td><input name=\"query\" value=\"").append(query).unsafeAppend("\"></td></tr>"); |
526 | | - |
527 | | - sb.unsafeAppend("</table><br>Do you want to continue?"); |
528 | 514 |
|
529 | | - return new HtmlView(sb.getHtmlString()); |
| 515 | + return new HtmlView(createHtmlFragment( |
| 516 | + "This allows you to initialize the autoincrementing column for the provided schema/query", BR(), BR(), |
| 517 | + "This is very rarely required and was created as a helper for admins with a good deal of knowledge about this module. Under most cases these columns will be automatically populated and you will not need to worry about this. If you are unsure about this page, please post on the LabKey help forums, which are read by the authors of this module.", BR(), BR(), |
| 518 | + TABLE(at(style, "border-collapse: collapse;"), |
| 519 | + TR(TD("Schema:"), TD(INPUT(at().name("schema").value(schema)))), |
| 520 | + TR(TD("Query:"), TD(INPUT(at().name("query").value(query)))) |
| 521 | + ), |
| 522 | + BR(), "Do you want to continue?" |
| 523 | + )); |
530 | 524 | } |
531 | 525 |
|
532 | 526 |
|
|
0 commit comments