/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.*; import java.io.*; import org.ofbiz.entity.*; import org.ofbiz.entity.util.*; import org.ofbiz.base.util.*; import org.ofbiz.widget.html.*; delegator = request.getAttribute("delegator"); nowTimestampString = UtilDateTime.nowTimestamp().toString(); context.put("nowTimestampString", nowTimestampString); //default this to true, ie only show active boolean activeOnly = !"false".equals(request.getParameter("activeOnly")); context.put("activeOnly", activeOnly); boolean useValues = true; if (request.getAttribute("_ERROR_MESSAGE_") != null) useValues = false; facilityGroupId = request.getParameter("facilityGroupId"); GenericValue facilityGroup = delegator.findByPrimaryKey("FacilityGroup", UtilMisc.toMap("facilityGroupId", facilityGroupId)); if (facilityGroup == null) useValues = false; facilityGroupMembers = facilityGroup.getRelated("FacilityGroupMember", null, UtilMisc.toList("sequenceNum", "facilityId")); if (activeOnly) facilityGroupMembers = EntityUtil.filterByDate(facilityGroupMembers, true); facilityGroups = delegator.findAll("FacilityGroup", UtilMisc.toList("description")); if ("true".equalsIgnoreCase((String)request.getParameter("useValues"))) useValues = true; int viewIndex = 0; int viewSize = 20; int highIndex = 0; int lowIndex = 0; int listSize = 0; try { viewIndex = Integer.valueOf((String) request.getParameter("VIEW_INDEX")).intValue(); } catch (Exception e) { viewIndex = 0; } try { viewSize = Integer.valueOf((String) request.getParameter("VIEW_SIZE")).intValue(); } catch (Exception e) { viewSize = 20; } if (facilityGroupMembers != null) { listSize = facilityGroupMembers.size(); } lowIndex = viewIndex * viewSize; highIndex = (viewIndex + 1) * viewSize; if (listSize < highIndex) { highIndex = listSize; } context.put("facilityGroupId", facilityGroupId); context.put("facilityGroup", facilityGroup); context.put("facilityGroupMembers", facilityGroupMembers); context.put("facilityGroups", facilityGroups); context.put("useValues", useValues); context.put("viewIndex", viewIndex); context.put("viewSize", viewSize); context.put("listSize", listSize); context.put("lowIndex", lowIndex); context.put("highIndex", highIndex);