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
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import org.jlab.dtm.business.service.AnnualRepairReportService;
import org.jlab.dtm.business.session.CategoryFacade;
import org.jlab.dtm.business.session.CcAccHourService;
import org.jlab.dtm.persistence.entity.Category;
import org.jlab.dtm.persistence.model.AnnualRepairReportRecord;
import org.jlab.dtm.presentation.util.DtmParamConverter;
import org.jlab.smoothness.business.util.TimeUtil;
Expand All @@ -33,6 +30,7 @@
public class AnnualRepair extends HttpServlet {

@EJB CcAccHourService accHourService;
@EJB CategoryFacade categoryFacade;

/**
* Handles the HTTP <code>GET</code> method.
Expand All @@ -54,6 +52,8 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
throw new ServletException("Unable to parse date", e);
}

String zeroDowntime = request.getParameter("zeroDowntime");

Calendar c = Calendar.getInstance();
// Date now = c.getTime();
c.set(Calendar.MILLISECOND, 0);
Expand Down Expand Up @@ -99,6 +99,31 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
try {
AnnualRepairReportService reportService = new AnnualRepairReportService();
recordList = reportService.find(start, end);

// Add in any categories (groups) that are missing as zero valued to explicitly celebrate
// they're zero
if ("hide".equals(zeroDowntime)) {
// Do nothing (if there was downtime in category, and it rounds down to zero percent, so
// be it)
// We could forcibly hide downtime that rounds to zero, but we don't right now.
} else { // show: forcibly show all categories, even if zero downtime
Date lastMonthStart = TimeUtil.startOfMonth(end, Calendar.getInstance());

List<Category> allAlphaCategoryList = categoryFacade.findAlphaCategoryList();
Set<String> representedCategorySet = new HashSet<>();
for (AnnualRepairReportRecord record : recordList) {
representedCategorySet.add(record.getCategory());
}

for (Category cat : allAlphaCategoryList) {
if (!representedCategorySet.contains(cat.getName())) {
AnnualRepairReportRecord record =
new AnnualRepairReportRecord(
cat.getName(), cat.getCategoryId(), lastMonthStart, 0);
recordList.add(record);
}
}
}
} catch (SQLException e) {
throw new ServletException("Unable to query report database", e);
}
Expand Down
13 changes: 12 additions & 1 deletion src/main/webapp/WEB-INF/views/operability/annual-repair.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,18 @@
<option value="table"${param.chart eq 'table' ? ' selected="selected"' : ''}>Table</option>
</select>
</div>
</li>
</li>
<li>
<div class="li-key">
<label for="zeroDowntime">Zero Downtime</label>
</div>
<div class="li-value">
<select id="zeroDowntime" name="zeroDowntime">
<option value="show"${param.zeroDowntime eq 'show' ? ' selected="selected"' : ''}>Show</option>
<option value="hide"${param.zeroDowntime eq 'hide' ? ' selected="selected"' : ''}>Hide</option>
</select>
</div>
</li>
</ul>
</fieldset>
<input class="filter-form-submit-button" type="submit" value="Apply"/>
Expand Down
Loading