Link for a given model class and filter name
 @param model_class [Class]
 @param filter_name [String, Symbol]
 @param filters [Hash]
 @param url_params [Hash, ActionController::Parameters]
 @return [String] HTML anchor link
357933
def filter_link(model_class, filter_name, filters: {}, url_params: {})
      is_all = filter_name == :all
      config = filters[filter_name] || {}
      label = is_all ? all_label : filter_label(filter_name, filters)
      url_params =
        if config[:default] then index_params.except(:filter).merge(url_params)
        else index_params.merge(filter: filter_name).merge(url_params)
        end
      index_link(model_class, url_params: url_params) { label }
    end
1031182
def get_filter_class(self, view, queryset=None):
        
        filter_class = getattr(view, 'filter_class', None)
        if filter_class:
            filter_model = filter_class.Meta.model

            assert issubclass(queryset._document, filter_model), \
                'FilterSet model %s does not match queryset model %s' % \
                (filter_model, queryset.model)

            return filter_class
        return
1222071
public void addFilter(final WebAppFilter filter) {
		NullArgumentException.validateNotNull(filter, "Filter");
		NullArgumentException.validateNotNull(filter.getFilterName(),
				"Filter name");
		NullArgumentException.validateNotNull(filter.getFilterClass(),
				"Filter class");
		filters.put(filter.getFilterName(), filter);
		// add url patterns and servlet names for filter mappings added before
		// filter
		for (WebAppFilterMapping mapping : getFilterMappings(filter
				.getFilterName())) {
			if (mapping.getUrlPattern() != null
					&& mapping.getUrlPattern().trim().length() > 0) {
				filter.addUrlPattern(mapping.getUrlPattern());
			}
			if (mapping.getServletName() != null
					&& mapping.getServletName().trim().length() > 0) {
				filter.addServletName(mapping.getServletName());
			}
		}
	}
798697
function () {
			// Remove the `selected` class from the old link and add it to the link for the current location hash
			this.element.find('#filters').find('a').removeClass('selected')
				.end().find('[href="' + window.location.hash + '"]').addClass('selected');
		}
45779
def export_link(model_class, url_params: {})
      url_params = index_params.except(:page, :per).merge(format: 'csv').merge(url_params)
      index_link(model_class, url_params: url_params) { t 'links.export', ext: 'CSV' }
    end
1353971
public void addFilterModel(final FilterModel model) {
		if (model.getUrlPatterns() != null) {
			try {
				filterLock.writeLock().lock();
				associateBundle(model.getContextModel().getVirtualHosts(), model.getContextModel().getBundle());
				for (String virtualHost : resolveVirtualHosts(model)) {
					for (String urlPattern : model.getUrlPatterns()) {
							final UrlPattern newUrlPattern = new UrlPattern(getFullPath(model.getContextModel(), urlPattern),
											model);
							String fullPath = getFullPath(model.getContextModel(), urlPattern);
							if (filterUrlPatterns.get(virtualHost) == null) {
								filterUrlPatterns.put(virtualHost, new ConcurrentHashMap<>());
							}
							Set<UrlPattern> urlSet = filterUrlPatterns.get(virtualHost).get(fullPath);
							if (urlSet == null) {
									//initialize first
									urlSet = new HashSet<>();
							}
							urlSet.add(newUrlPattern);
							filterUrlPatterns.get(virtualHost).put(fullPath, urlSet);
    //					final UrlPattern existingPattern = filterUrlPatterns.putIfAbsent(
    //							getFullPath(model.getContextModel(), urlPattern), newUrlPattern);
    //					if (existingPattern != null) {
    //						// this should never happen but is a good assertion
    //						LOG.error("Internal error (please report): Cannot associate url mapping "
    //								+ getFullPath(model.getContextModel(), urlPattern) + " to " + newUrlPattern
    //								+ " because is already associated to " + existingPattern);
    //					}
                                    }
                                }
			} finally {
				filterLock.writeLock().unlock();
			}
		}
	}
1238170
def urls(cls):
        
        class_name = cls.get_class_name()
        if django.VERSION >= (2, 0):
            return path('{}/'.format(class_name), include([
                path('popup/', cls.create().as_view(), name='{}_popup_create'.format(class_name)),
                path('popup/<int:pk>/', cls.update().as_view(), name='{}_popup_update'.format(class_name)),
                path('popup/delete/<int:pk>/', cls.delete().as_view(), name='{}_popup_delete'.format(class_name)),
            ]))
        else:
            return url(r'^{}/'.format(class_name), include([
                url(r'^popup/$', cls.create().as_view(), name='{}_popup_create'.format(class_name)),
                url(r'^popup/(?P<pk>\d+)/$', cls.update().as_view(), name='{}_popup_update'.format(class_name)),
                url(r'^popup/delete/(?P<pk>\d+)/$', cls.delete().as_view(), name='{}_popup_delete'.format(class_name)),
            ]))
205042
public static WebMvcLinkBuilder linkTo(Class<?> controller, Method method, Object... parameters) {

		Assert.notNull(controller, "Controller type must not be null!");
		Assert.notNull(method, "Method must not be null!");

		String mapping = DISCOVERER.getMapping(controller, method);
		UriTemplate template = UriTemplateFactory.templateFor(mapping);
		URI uri = template.expand(parameters);

		return new WebMvcLinkBuilder(UriComponentsBuilderFactory.getBuilder()).slash(uri);
	}
204932
public static function url($input, $field_name = 'url')
    {
        //Define trivial model
        $model = [
            $field_name => ['type' => Validate::TYPE_URL, Validate::REQUIRED]
        ];

        $parameters = [$field_name => $input];
        Validate::model($parameters, $model);

        return $parameters[$field_name];
    }
332796
def report_filter_params
      Hash[*viable_report_filters.map{|filter| filter.filter_match_params}.flatten].
        merge(order: self.sorter)
    end
342700
def object_filter(filter)
    raise ArgumentError, "object_filter expects an instance of SoftLayer::ObjectFilter" if filter.nil? || !filter.kind_of?(SoftLayer::ObjectFilter)

    # we create a new object in case the user wants to store off the
    # filter chain and reuse it later
    APIParameterFilter.new(self.target, @parameters.merge({:object_filter => filter}));
  end
1350137
def find_controller_by(params)
      model_class = find_model_class_by params
      Map.controller_map(model_class, params[:resources_controller]) || default_controller(params)
    end
155817
def wf_link_template?(template)
      if template.is_a?(String) &&
         template.start_with?('http://', 'https://')
        return true
      end

      raise Wavefront::Exception::InvalidLinkTemplate
    end
1254997
def model_to_select_list(model_class, filter_dict=None, q_filter=None):
    
    if filter_dict is None:
        filter_dict = {}

    if q_filter is not None:
        filter_list = [q_filter]
    else:
        filter_list = []

    objects = model_class.objects.filter(
        *filter_list, **filter_dict).values('id', 'name')

    return list(objects)
981463
def delete_filter(filter_class)
      index = @filters.index { |f| f.class.name == filter_class.name }
      @filters.delete_at(index) if index
    end
690652
def filter_from_url_arg(model_cls, query, arg, query_operator=and_,
                        arg_types=None):
    

    fields = arg.split(',')
    mapper = class_mapper(model_cls)

    if not arg_types:
        arg_types = {}

    exprs = []
    joins = set()
    for expr in fields:
        if expr == "":
            continue

        e_mapper = mapper
        e_model_cls = model_cls

        operator = None
        method = None
        for op in operator_order:
            if op in expr:
                operator = op
                method = operator_to_method[op]
                break

        if operator is None:
            raise Exception('No operator in expression "{0}".'.format(expr))

        (column_names, value) = expr.split(operator)

        column_names = column_names.split('__')
        value = value.strip()

        for column_name in column_names:
            if column_name in arg_types:
                typed_value = arg_types[column_name](value)
            else:
                typed_value = value

            if column_name in e_mapper.relationships:
                joins.add(column_name)
                e_model_cls = e_mapper.attrs[column_name].mapper.class_
                e_mapper = class_mapper(e_model_cls)

        if hasattr(e_model_cls, column_name):
            column = getattr(e_model_cls, column_name)
            exprs.append(getattr(column, method)(typed_value))
        else:
            raise Exception('Invalid property {0} in class {1}.'.format(column_name, e_model_cls))

    return query.join(*joins).filter(query_operator(*exprs))
187817
public ClassificationModel attachLink(ClassificationModel classificationModel, LinkModel linkModel)
    {
        for (LinkModel existing : classificationModel.getLinks())
        {
            if (StringUtils.equals(existing.getLink(), linkModel.getLink()))
            {
                return classificationModel;
            }
        }
        classificationModel.addLink(linkModel);
        return classificationModel;
    }