Skip to content

Commit e0048a8

Browse files
Minor cleanup - delete unused params and methods, etc
1 parent 63d054f commit e0048a8

2 files changed

Lines changed: 17 additions & 94 deletions

File tree

LDK/src/org/labkey/ldk/notification/SiteSummaryNotification.java

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ public String getEmailSubject(Container c)
114114
return "Daily Admin Alerts: " + getDateTimeFormat(c).format(new Date());
115115
}
116116

117-
public DateFormat getDateFormat(Container c)
118-
{
119-
return new SimpleDateFormat(LookAndFeelProperties.getInstance(c).getDefaultDateFormat());
120-
}
121-
122117
public DateFormat getDateTimeFormat(Container c)
123118
{
124119
return new SimpleDateFormat(LookAndFeelProperties.getInstance(c).getDefaultDateTimeFormat());
@@ -150,7 +145,7 @@ private String getLastSaveString(Container c, Map<String, String> map)
150145
return getDateTimeFormat(c).format(new Date(lastSaveMills));
151146
}
152147

153-
private void saveValues(Container c, Map<String, String> saved, Map<String, String> newValues)
148+
private void saveValues(Container c, Map<String, String> newValues)
154149
{
155150
WritablePropertyMap map = PropertyManager.getWritableProperties(c, PROP_CATEGORY, true);
156151

@@ -190,13 +185,13 @@ public String getMessageBodyHTML(Container c, User u)
190185
StringBuilder msg = new StringBuilder();
191186
StringBuilder alerts = new StringBuilder();
192187

193-
getSiteUsageStats(c, u, msg, alerts, saved, newValues);
188+
getSiteUsageStats(c, u, msg);
194189

195190
getTableSizeStats(c, u, msg, alerts, saved, newValues);
196191

197192
getFileRootSizes(c, u, msg, alerts, saved, newValues);
198193

199-
validateContainerScopedTables(c, u, msg, alerts);
194+
validateContainerScopedTables(c, msg, alerts);
200195

201196
//allow registering of additional sections
202197
Set<NotificationSection> sections = ((LDKServiceImpl)LDKServiceImpl.get()).getSiteSummaryNotificationSections();
@@ -219,15 +214,15 @@ public String getMessageBodyHTML(Container c, User u)
219214

220215
msg.insert(0, "This email contains a series of alerts designed for site admins. It was run on: " + getDateTimeFormat(c).format(new Date()) + ". Runtime: " + DurationFormatUtils.formatDurationWords((new Date()).getTime() - start.getTime(), true, true) + "<p>");
221216

222-
saveValues(c, saved, newValues);
217+
saveValues(c, newValues);
223218

224219
return msg.toString();
225220
}
226221

227222
/**
228223
* summarize site usage in the past 7 days
229224
*/
230-
private void siteUsage(Container c, User u, final StringBuilder msg, final StringBuilder alerts, Map<String, String> saved, Map<String, String> toSave)
225+
private void siteUsage(final StringBuilder msg)
231226
{
232227
//different behavior depending on whether audit data has migrated
233228
AuditTypeProvider ap = AuditLogService.get().getAuditProvider("UserAuditEvent");
@@ -274,35 +269,6 @@ public void exec(ResultSet rs) throws SQLException
274269
}
275270
}
276271

277-
/**
278-
* we print some stats on data entry
279-
*/
280-
private void dataEntryStatus(Container c, User u, final StringBuilder msg)
281-
{
282-
msg.append("<b>Data Entry Stats:</b><p>");
283-
284-
Calendar cal = Calendar.getInstance();
285-
cal.setTime(new Date());
286-
cal.add(Calendar.DATE, -1);
287-
SQLFragment sql = new SQLFragment("SELECT t.formtype, count(*) as total FROM ehr.tasks t WHERE cast(t.created as date) = ").appendValue(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())).append(" GROUP BY t.formtype ORDER BY t.formtype");
288-
289-
UserSchema us = QueryService.get().getUserSchema(u, c, "core");
290-
SqlSelector ss = new SqlSelector(us.getDbSchema(), sql);
291-
292-
msg.append("Number of Forms Created Yesterday: <br>\n");
293-
294-
ss.forEach(new Selector.ForEachBlock<>()
295-
{
296-
@Override
297-
public void exec(ResultSet rs) throws SQLException
298-
{
299-
msg.append(rs.getString("formtype") + ": " + rs.getInt("total") + "<br>\n");
300-
}
301-
});
302-
303-
msg.append("<p>\n");
304-
}
305-
306272
private void getStudySizeSummary(Container c, User u, final StringBuilder msg, final StringBuilder alerts, Map<String, String> saved, Map<String, String> toSave)
307273
{
308274
Set<? extends Study> studies = StudyService.get().getAllStudies(ContainerManager.getRoot(), u);
@@ -362,7 +328,7 @@ private String getPctChange(Long oldVal, Long newVal, double threshold, String m
362328

363329
}
364330

365-
private void getPipelineJobCount(Container c, User u, final StringBuilder msg, final StringBuilder alerts, Map<String, String> saved, Map<String, String> toSave)
331+
private void getPipelineJobCount(Container c, User u, final StringBuilder msg)
366332
{
367333
TableInfo jobs = PipelineService.get().getJobsTable(u, c);
368334
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("modified"), "-1d", CompareType.DATE_GTE);
@@ -372,7 +338,7 @@ private void getPipelineJobCount(Container c, User u, final StringBuilder msg, f
372338
msg.append("Pipeline jobs created/modified in the past 24 hours: " + count + "<br>");
373339
}
374340

375-
private void validateContainerScopedTables(Container c, User u, final StringBuilder msg, final StringBuilder alerts)
341+
private void validateContainerScopedTables(Container c, final StringBuilder msg, final StringBuilder alerts)
376342
{
377343
LDKServiceImpl service = (LDKServiceImpl)LDKServiceImpl.get();
378344
List<String> errors = service.validateContainerScopedTables(true);
@@ -459,15 +425,15 @@ private void getFileRootSizes(Container c, User u, final StringBuilder msg, fina
459425
toSave.put(fileRootCounts, new JSONObject(newValueMapCounts).toString());
460426
}
461427

462-
private void getSiteUsageStats(Container c, User u, final StringBuilder msg, final StringBuilder alerts, Map<String, String> saved, Map<String, String> toSave)
428+
private void getSiteUsageStats(Container c, User u, final StringBuilder msg)
463429
{
464430
msg.append("<br>The following items are designed to give a summary of recent site usage:<br><br>");
465431

466-
siteUsage(c, u, msg, alerts, saved, toSave);
432+
siteUsage(msg);
467433

468434
msg.append("<b>Other Misc Statistics:</b><br><br>");
469435

470-
getPipelineJobCount(c, u, msg, alerts, saved, toSave);
436+
getPipelineJobCount(c, u, msg);
471437

472438
msg.append("<hr>");
473439
}
@@ -514,15 +480,15 @@ public void exec(ResultSet object) throws SQLException
514480
if (!newValueMap.isEmpty())
515481
toSave.put(tableSizes, new JSONObject(newValueMap).toString());
516482

517-
getDBSize(c, u, msg, alerts, saved, toSave);
483+
getDBSize(msg);
518484
getStudySizeSummary(c, u, msg, alerts, saved, toSave);
519485
getAssayRunSummary(c, u, msg, alerts, saved, toSave);
520486
getListSummary(c, u, msg, alerts, saved, toSave);
521487

522488
msg.append("<hr>");
523489
}
524490

525-
private void getDBSize(Container c, User u, final StringBuilder msg, final StringBuilder alerts, Map<String, String> saved, Map<String, String> toSave)
491+
private void getDBSize(final StringBuilder msg)
526492
{
527493
SqlSelector ss = new SqlSelector(DbScope.getLabKeyScope(), new SQLFragment("SELECT pg_database_size(?) As size", DbScope.getLabKeyScope().getDatabaseName()));
528494
Map<String, Object>[] maps = ss.getMapArray();

LDK/src/org/labkey/ldk/query/DefaultTableCustomizer.java

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
import org.apache.logging.log4j.LogManager;
2525
import org.jetbrains.annotations.Nullable;
2626
import org.json.JSONObject;
27-
import org.labkey.api.assay.AssayResultTable;
2827
import org.labkey.api.data.AbstractTableInfo;
29-
import org.labkey.api.data.BuiltInButtonConfig;
3028
import org.labkey.api.data.ButtonBarConfig;
3129
import org.labkey.api.data.ButtonConfig;
3230
import org.labkey.api.data.ColumnInfo;
@@ -149,7 +147,7 @@ else if (keyFields.size() > 1)
149147
return;
150148
}
151149

152-
String keyField = keyFields.get(0);
150+
String keyField = keyFields.getFirst();
153151
StringExpression se = ti.getDetailsURL(null, ti.getUserSchema().getContainer());
154152
// Handle a null source string, which you get when the URL is a AbstractTableInfo.LINK_DISABLER. See issue 39403
155153
if (se == null || se.toString() == null || se.toString().contains("detailsQueryRow"))
@@ -214,7 +212,7 @@ else if (keyFields.size() != 1)
214212

215213
if (schemaName != null && queryName != null)
216214
{
217-
String keyField = keyFields.get(0);
215+
String keyField = keyFields.getFirst();
218216
if (!AbstractTableInfo.LINK_DISABLER_ACTION_URL.equals(ti.getImportDataURL(ti.getUserSchema().getContainer())))
219217
ti.setImportURL(DetailsURL.fromString("/query/importData.view?schemaName=" + schemaName + "&query.queryName=" + queryName + "&keyField=" + keyField + "&bulkImport=true"));
220218

@@ -371,47 +369,6 @@ public static void customizeButtonBar(AbstractTableInfo ti, List<ButtonConfigFac
371369
ti.setButtonBarConfig(cfg);
372370
}
373371

374-
private static String getExpectedImportBtnName(TableInfo ti)
375-
{
376-
if (ti instanceof AssayResultTable)
377-
{
378-
return "Import Data";
379-
}
380-
else if (ti.getInsertURL(ti.getUserSchema().getContainer()) != AbstractTableInfo.LINK_DISABLER_ACTION_URL && ti.getImportDataURL(ti.getUserSchema().getContainer()) != AbstractTableInfo.LINK_DISABLER_ACTION_URL)
381-
{
382-
return "Insert";
383-
}
384-
385-
return "Import Bulk Data";
386-
}
387-
388-
private static boolean hasImportDataBtn(ButtonBarConfig cfg, TableInfo ti)
389-
{
390-
if (cfg.getItems() == null)
391-
return false;
392-
393-
String expectedName = getExpectedImportBtnName(ti);
394-
for (ButtonConfig bc : cfg.getItems())
395-
{
396-
if (bc instanceof BuiltInButtonConfig)
397-
{
398-
if (((BuiltInButtonConfig)bc).getOriginalCaption().equals(expectedName))
399-
{
400-
return true;
401-
}
402-
}
403-
else if (bc instanceof UserDefinedButtonConfig)
404-
{
405-
if (((UserDefinedButtonConfig)bc).getText().equals(expectedName))
406-
{
407-
return true;
408-
}
409-
}
410-
}
411-
412-
return false;
413-
}
414-
415372
private static boolean configureMoreActionsBtn(TableInfo ti, List<ButtonConfigFactory> buttons, ButtonBarConfig cfg, Set<String> scripts)
416373
{
417374
if (buttons == null || buttons.isEmpty())
@@ -499,16 +456,16 @@ public enum PROPERIES
499456
overrideDetailsUrl(Boolean.class, true),
500457
primaryKeyField(String.class, null);
501458

502-
private final Class _clazz;
459+
private final Class<?> _clazz;
503460
private final Object _defaultVal;
504461

505-
PROPERIES(Class clazz, Object defaultVal)
462+
PROPERIES(Class<?> clazz, Object defaultVal)
506463
{
507464
_clazz = clazz;
508465
_defaultVal = defaultVal;
509466
}
510467

511-
public Class getConvertClass()
468+
public Class<?> getConvertClass()
512469
{
513470
return _clazz;
514471
}

0 commit comments

Comments
 (0)