/** * Expose the requested property from component context. * * @exception JspException if a JSP exception has occurred */ public int doStartTag() throws JspException { if (id == null) id = property; ComponentContext compContext = (ComponentContext) pageContext.getAttribute( ComponentConstants.COMPONENT_CONTEXT, PageContext.REQUEST_SCOPE); if (compContext == null) throw new JspException( "Error - tag.useProperty : component context is not defined. Check tag syntax"); Object value = compContext.getAttribute(property); if (value == null) throw new JspException( "Error - tag.useProperty : property '" + property + "' not found in context. Check tag syntax"); if (scopeName != null) { scope = TagUtils.getScope(scopeName, PageContext.PAGE_SCOPE); pageContext.setAttribute(id, value, scope); } else pageContext.setAttribute(id, value); // Continue processing this page return SKIP_BODY; }
/** {@inheritDoc} */ public ActionForward execute( ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String name = (String) context.getAttribute("name"); String type = (String) context.getAttribute("type"); HttpSession session = request.getSession(); final InterMineAPI im = SessionMethods.getInterMineAPI(session); Profile profile = SessionMethods.getProfile(session); TagManager tagManager = im.getTagManager(); Set<String> userTags = tagManager.getObjectTagNames(name, type, profile.getUsername()); String isFavourite = Boolean.toString(userTags.contains(TagNames.IM_FAVOURITE)); request.setAttribute("isFavourite", isFavourite); return null; }
@SuppressWarnings("unchecked") @Override public ActionForward execute( ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { dataManager = LookupUtil.getMeasurementDataManager(); chartsManager = LookupUtil.getMeasurementChartsManager(); WebUser user = SessionUtils.getWebUser(request.getSession()); Subject subject = user.getSubject(); Resource resource = (Resource) request.getAttribute(AttrConstants.RESOURCE_ATTR); // Get metric time range MeasurementPreferences preferences = user.getMeasurementPreferences(); MetricRangePreferences rangePreferences = preferences.getMetricRangePreferences(); long begin = rangePreferences.begin; long end = rangePreferences.end; List<AutoGroupComposite> children; List<AutoGroupCompositeDisplaySummary> displaySummary; int parentId = -1; int resourceTypeId = -1; if (resource == null) { parentId = WebUtility.getOptionalIntRequestParameter( request, AttrConstants.AUTOGROUP_PARENT_ATTR, -1); if (parentId > 0) // get data for individual autogroup children { resourceTypeId = WebUtility.getOptionalIntRequestParameter( request, AttrConstants.AUTOGROUP_TYPE_ATTR, -1); children = getAutoGroupChildren(subject, parentId, resourceTypeId); if (children == null) children = new ArrayList<AutoGroupComposite>(); displaySummary = new ArrayList<AutoGroupCompositeDisplaySummary>(children.size() + 1); // get the parent ResourceManagerLocal resourceManager = LookupUtil.getResourceManager(); AutoGroupComposite parentComposite = resourceManager.getResourceAutoGroup(subject, parentId); if (parentComposite != null) { parentComposite.setMainResource(true); List<MetricDisplaySummary> metricSummaries = null; metricSummaries = chartsManager.getMetricDisplaySummariesForMetrics( subject, parentId, DataType.MEASUREMENT, begin, end, true, true); displaySummary.add( 0, new AutoGroupCompositeDisplaySummary(parentComposite, metricSummaries)); } /* We have n children with each child representing exactly 1 resource. * As we are in an autogroup, all children have the same type, so we can just feed them to the backend * in one call with all n resources. */ // Loop over children, get resources, call some ..forMultiMetrics.. List<Integer> resourceIds = new ArrayList<Integer>(); for (AutoGroupComposite child : children) { List resources = child.getResources(); ResourceWithAvailability rwa = (ResourceWithAvailability) resources.get(0); resourceIds.add(rwa.getResource().getId()); } // Map<ResourceId, List<Summaries for that resource> Map<Integer, List<MetricDisplaySummary>> summaries = dataManager.findNarrowedMetricDisplaySummariesForResourcesAndParent( subject, resourceTypeId, parentId, resourceIds, begin, end); for (AutoGroupComposite child : children) { if (parentComposite != null) child.increaseDepth(1); List resources = child.getResources(); ResourceWithAvailability rwa = (ResourceWithAvailability) resources.get(0); List<MetricDisplaySummary> sumList = summaries.get(rwa.getResource().getId()); displaySummary.add(new AutoGroupCompositeDisplaySummary(child, sumList)); } } else { RequestUtils.setError(request, MessageConstants.ERR_RESOURCE_NOT_FOUND); return null; } } else { // resource != null // get children of that single resource, which can be individual resources or autogroups children = getResourceChildren(resource, subject); displaySummary = new ArrayList<AutoGroupCompositeDisplaySummary>(children.size()); for (AutoGroupComposite child : children) { List<MetricDisplaySummary> metrics = getMetrics(resource, child, subject, begin, end); displaySummary.add(new AutoGroupCompositeDisplaySummary(child, metrics)); } } context.putAttribute(AttrConstants.CTX_SUMMARIES, displaySummary); return null; }