Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions api/src/org/labkey/api/module/Summary.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
public class Summary
{
private final long count;
private final String nounSingular;
private final String nounPlural;
private final String noun;

private String replaceNounTitles(String nounSingular) {
private String replaceNounTitles(String noun) {
String[] search = new String[] {
"ExpressionSystem",
"Ingredients",
Expand All @@ -34,30 +33,22 @@ private String replaceNounTitles(String nounSingular) {
"Protein sequence",
"Raw material"
};
return StringUtils.replaceEach(nounSingular, search, replacements);
return StringUtils.replaceEach(noun, search, replacements);
}

public Summary(final long count, final String nounSingular, final String nounPlural)
public Summary(final long count, final String noun)
{
this.count = count;
this.nounSingular = nounSingular;
this.nounPlural = nounPlural;
}

public Summary(final long count, final String nounSingular)
{
String nounName = replaceNounTitles(nounSingular);
String nounName = replaceNounTitles(noun);

this.count = count;
this.nounSingular = nounName;
this.nounPlural = nounName.endsWith("s") ? nounName : nounName + "s";
this.noun = nounName;
}

public JSONObject toJSON()
{
JSONObject json = new JSONObject();
json.put("count", count);
json.put("noun", count > 1 ? nounPlural : nounSingular);
json.put("noun", noun);
return json;
}
}
4 changes: 2 additions & 2 deletions experiment/src/org/labkey/experiment/ExperimentModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ public Collection<String> getSummary(Container c)
List<? extends ExpDataClass> dataClasses = ExperimentService.get().getDataClasses(c, user, false);
int dataClassCount = dataClasses.size();
if (dataClassCount > 0)
summaries.add(new Summary(dataClassCount, "Data Class", "Data Classes"));
summaries.add(new Summary(dataClassCount, "Data Class"));

ExpSchema expSchema = new ExpSchema(user, c);

Expand Down Expand Up @@ -925,7 +925,7 @@ public Collection<String> getSummary(Container c)
{
String name = entry.getKey();
Summary s = name.equals("MixtureBatches")
? new Summary(count, "Batch", "Batches") // Special handling for name replacement + pluralization
? new Summary(count, "Batch")
: new Summary(count, name);
summaries.add(s);
}
Expand Down