Dashboard > Atlassian Plugins > ... > Macros > text-filter
  Atlassian Plugins Log In | Sign Up   View a printable version of the current page.  
  text-filter

Added by david , last edited by David Peterson on Feb 05, 2008  (view change)
Labels: 

{text-filter}

Plugin: Reporting Plugin, from version 1.0

This filter will ensure that the specified 'prefix:key' value matches the required text value.

Description

This must be used in a reporter macro. It allows filtering based on the number of characters or on a regular expression.

Usage

{text-filter:prefix:key|minLength=[#]|maxLength=[#]|include=[regexp]|exclude=[regexp]|required=true/false}

Parameters

Name Required Default Description
[default]/key
The key value to filter on.
minLength
If specified, value must have at least this many characters.
maxLength
If specified, the value must have at most this many characters.
include
If specified, this is a regular expression specifying the pattern required to be included. Details on regular expression requirements are here.
exclude
If specified, this is a regular expression specifying the pattern required to be excluded. Details on regular expression requirements are here.
required
false
If set to 'true', the key value must have a value with more than one non-whitespace character.

Recipes

See Also

David, can you provide an example using text-filter with include option? I'm trying 1.0.2 with no luck.

Sample (looking for space names with 'ABC'):

{space-reporter:space=@global}
{text-filter:space:name|include=ABC}
{space-reporter}
Anonymous

The include and exclude parameters use fully fledged regular expressions. Try this:

{space-reporter:space=@global}
{text-filter:space:name|include=.*ABC.*}
{space-reporter}

Hi David,
Can you provide an example of using space reporter's label by content parameter. Basically I m trying to display all the labels used in a particular space. I tried content reporter but it returns me repeating labels.

{report-block}
{space-reporter:space=@self}
{space-reporter}
{report-body}
{report-info:space:labels for content}
{report-body}
{report-empty}
_No labels are available._
{report-empty}
{report-block}

it returned me this error. Any idea??

 report-info: Unsupported context object: com.atlassian.confluence.spaces.Space$$EnhancerByCGLIB$$d0393fee 

Hi Noon,

Turns out it is a result of two problems: a bug in Space Supplier which is producing a confusing error message, as well as a typo in my Space Supplier documentation. To fix your problem, use "space:labels in content" instead of "space:labels for content". I've updated the space supplier documentation and fixed the unhelpful error message for the next release of Reporting.

Thanks a lot!! It works perfectly now!
have a nice day!

I'm trying to do an "OR" filter as below, but it seems to be "AND"ing the conditions I specify. (Also, I'm not sure about the expanded filter). See Below

{content-reporter:type=page|scope=MyPage > children}
    {expand-on:data:Metrics|as=metric}
      {text-filter:expanded:metric > data:LinkLOB|include=Mobile}
    {expand-on}
    {text-filter:data:MetricsLOB|include=Mobile}
  {content-reporter}

First, should this:

{text-filter:expanded:metric > data:LinkLOB|include=Mobile}

Be this?

{text-filter:data:LinkLOB|include=Mobile}

Second, How can I formulate this to say:
Include IF (MetricsLOB == Mobile || LinkLOB == Mobile)

Thanks!!!

Shawn

I'm assuming that 'Metrics' is a a table-data or repeating-data? If so, I'm not sure you can specify that. If 'Metrics' is a group-data, you can do it like this:

{local-reporter:content:children|matchAll=false}
    {text-filter:data:Metrics > data:LinkLOB|include=Mobile}
    {text-filter:data:MetricsLOB|include=Mobile}
{local-reporter}

However, I'm guessing Metrics is not a group. There is a feature request to add a new filter type to do what you're after here, but we haven't had time to implement it yet. Feel free to vote/watch/comment.

Yes, Metrics is table-data.

Ahhh, matchAll=false is what I was looking for. Thank you!

  • I'm trying to filter a group of pages based on the metadata associated with the page (using metadata v2), and display a report that includes that metadata. I can't seem to get it to work. I know we talked about this before on this website, but after some searching I can't find the comments on this website any longer. No matter what I try, the 'data:Status' comes back blank, and the data:Status filter blocks out everything. The 'metadata-from' works fine (as long as the filter is not there), but the content is not rendered as wiki markup, just plain text.
{report-table}
{content-reporter:space=@self|type=page|scope=MyPage > descendents}
  {text-filter:data:Status|include=.*good.*}
{content-reporter}
{report-column:title=Title}{report-info:content:title|link=true}{report-column}
{report-column:title=Status}{report-info:data:Status}{metadata-from:Status}{report-column}
{report-table}

anybody have experience with metadata plugin and reporting plugin?

  • I'm on reporting plugin v.1.3.2 and metadata v2.0.3

Hi James,

I am not certain that the 'data:' prefix will work with Metadata 2. I haven't done any investigation to see if Andy changed the metadata storage system with version 2 or not...

What is the markup on your original page?

if you mean the target pages for the report above? something simple like this:

{metadata-list}
|| some | field |
|| Status | this is good |
|| other | fields |
{metadata-list}
  • I'm not sure if Andy changed the metadata plugin storage, but it seems to be backwards compatible with the metadata-v1 (we didn't lose any metadata during the upgrade or perform any sort of migration) and both versions of metadata are compatible with the checklist plugin, the sub-section edit plugin and the metadata-tab plugin.
  • if the 'data' supply chain is fine-tuned to scaffolding, and scaffolding and metadata have diverged again on their data-store, what would it take to create a 'metadata' supply chain for the traditional metadata?

We will have to confer with Andy about the metadata data mechanism. With regards to adding a 'metadata' supplier, I'm guessing it would be fairly easy to add to the Metadata Plugin. The instructions are here - essentially, it's a matter of creating a Supplier instance and configuring it via an EventListener.

I raised a feature request as best I could with my limited understanding of the problem. if you have anything that you can contribute to make things more clear or help thinks along, please do!



Updated by Brandon Faloona
Jun 10, 2008 05:16

I'm trying to filter a report based on the title of the current page matching the value of a list-data in the page I'm reporting on. The use case is: Show the pages that are assigned to the page being viewed.

The data I'm filtering on is set like so:

Project: {list-data:Project}
{content-options:parent=AllProjects}
{list-data}

The data displays properly in the report:

{report-info:data:Project}

But, no results are returned when I add a filter like so:

{content-reporter:space=myspace|labels=+foo|scope=WorkItems > descendents}
    {text-filter:data:Project|include=ABC123}
  {content-reporter}

Ah-Ha! list-data is stored as a reference so this is the syntax I needed:

...
{text-filter:data:Project > reference:value > content:title|include=%PageTitle%}
...

So, why does eliminating the reference syntax work in report-info?

{report-info:data:Project}

Lastly, where can I find more info about when and how to use reference supplier

Hi Brandon,

The two macro which use References are list-data and attachment-data. List data will always use it, no matter what type of 'options' (list-option, content-options, etc) are used. The type of value returned will vary depending on the option type, of course.

report-info doesn't need it to be explicitly listed because it will automatically drill down through the returned object types until it finds a text, number or boolean value. If it gets to the bottom and it's still not one of the above, it will just call 'toString' on the object, hoping that it is smart enough to display itself. report-info also does a lot of other tricks like automatically detecting collections and iterating through them, etc., which don't make sense for filters and sorters.

This doesn't work for filters because they tend to be more specific, and automatically drilling down would provide some unexpected results in some cases.

Essentially, it is only the display macros (report-info in particular) which will automatically drill down. All other macros need to have the key chain be listed explicitly.

Hi David,

I spent hours and hours to figure out, how to filter a report based on the content of a {data-list} macro. Meanwhile I feel that I am going round in circles.

I have to build a report on child pages representing conference papers and information on the different languages in which they can be presented. The presentation languages are selected from a list on the respective child page with a list-data clause like that:

{list-data:languagePresent|type=check|multiple=true}{list-option}English{list-option}{list-option}German{list-option}{list-data}

The report on the parent page has to show all papers that can be presented in a certain language. I tried a lot of different ways to solve the problem, unfortunately with no success. One of my last attempts was

{report-table}
{local-reporter:content:children|type=page}
    {text-filter:data:languagePresent > reference:value|include=German}
{local-reporter}
{report-column:title=Language}{report-info:data:languagePresent}{report-column}
{report-column:title=Author}{report-info:data:authorLastname}, {report-info:data:authorFirstname}{report-column}
{report-column:title=Page}{report-info:content:title|link=true}{report-column}
{report-column:title=Title}{report-info:data:PaperTitle}{report-column}
{report-empty}This report has no items.{report-empty}
{report-table}

which works fine without the text-filter macro but results in an empty report for all other filter approaches I tried.

I would appreciate your help!

Thanks in advance

Günter

Hi Günter,

I suspect the issue is that your data field is 'multiple=true'. As such, it will (potentially) have a list of reference values, rather than just the one. As such, you will need to use the collection-filter here (check what version of Reporting you're using to make sure you have it - it's a fairly recent addition).

Something like this will probably work better:

{local-reporter:content:children|type=page}
  {collection-filter:data:languagePresent|matchItems=any}
    {text-filter:reference:value|include=German}
  {collection-filter}
{local-reporter}

This will loop through the values in 'languagePresent' and match if any of them match the filter's specified, in this case, the text-filter.

Ahhh, now it is working fine!

Thanks a lot for your help and your immediate response!

Günter

Hello.
I've gotten in WAY over my head here.

{report-list:style=disc|firstResult=1}
{content-reporter:type=page|space=@self|label=+book}
 {text-filter:data:content:title|include=boolean b = m.matches(\\A[b-zB-z])}
 {text-sort:content:title|mode=natural|order=ascending}
{content-reporter}

{report-body}
h5. _{report-info:content:title|link=true}_  {report-info:data:BookSubTitle} {report-info:data:Read|render=wiki}
-- *by {report-info:data:Author}*
_Abstract:_ {report-info:content:excerpt}
{report-body}

{report-empty}_There are no books in this shelf._{report-empty}
{report-list}

I have started a book club at my office and with the open ended nature of adding every book we review and every book we want to read to our wiki site for ratings and comments within the firm, I've realized the probability that I'll need to separate this alphabetically. So, my idea was to have a filter in the content reporter that would filter out all the A's B's C's etc by the first letter in the title hence the weird text after the include parameter.

All in all I wanted to have separate cards within a deck that would be tabbed for each letter of the alphabet that would report the titles under that letter. But sadly, my filter doesn't work and reports nothing... says it's empty.

I think mostly I'm just confused about how the regular expressions work... I read the page associated with it the "Why aren't my regular expressions working?" page, even looked at the Patterns for Java 2. But can't figure it out.
Any help by anyone would be greatly appreciated.

Thanks.
-AB

Hi Andrew,

You just need the actual regular expression in the 'include' parameter, not any java code. Eg, to match items starting with 'A', your text-filter should be this:

{text-filter:content:title|include=[Aa].*}

However, in your case, there is a better option. You can automatically generate the appropriate tab titles by doing this:

{report-block:style=disc|firstResult=1}
{content-reporter:type=page|space=@self|label=+book}
 {text-sort:content:title|mode=natural|order=ascending}
{content-reporter}

{report-header}
{deck:id=Shelves}
{report-header}

{repeat-filter:content:title > first 1 > upper case case}
{report-body|injected=true}
{card:title=%content:title > first 1 > upper case%}
{report-body}

{report-body}
h5. _{report-info:content:title|link=true}_  {report-info:data:BookSubTitle} {report-info:data:Read|render=wiki}
-- *by {report-info:data:Author}*
_Abstract:_ {report-info:content:excerpt}
{report-body}

{repeat-filter:content:title > first 1 > upper case case}
{report-body}
{card}
{report-body}

{report-footer}
{deck}
{report-footer}

{report-empty}_There are no books available._{report-empty}

{report-body}

This will do the following:

  1. If no books are available, no tabs are displayed, just the 'empty' message.
  2. If any books are available, only tabs for letters of the alphabet with books present will be generated.

Good luck!

Thank you for the help. This would be an awesome, awesome thing. However, I couldn't get it to work properly. I had to modify it because there were some syntax stuff that was a little off, and I got some errors, but that wasn't any big deal. Here is my modified below:

{composition-setup}

{report-block:style=disc|firstResult=1}
{content-reporter:type=page|space=@self|label=+book}
 {text-sort:content:title|mode=natural|order=ascending}
{content-reporter}

{report-header}
{deck:id=Shelves}
{report-header}

{repeat-filter:content:title > first 1 > upper case case}
{report-body:injected=true}
{card:title=%content:title > first 1 > upper case%}
{report-body}

{report-body}
h5. _{report-info:content:title|link=true}_  {report-info:data:BookSubTitle} {report-info:data:Read|render=wiki}
-- *by {report-info:data:Author}*
_Abstract:_ {report-info:content:excerpt}
{report-body}

{repeat-filter:content:title > first 1 > upper case case}
{report-body}
{card}
{report-body}

{report-footer}
{deck}
{report-footer}

{report-empty}_There are no books available._{report-empty}

{report-block}

The result of the report-block is the same thing as I had without the header and footer, or any filters, except it now has a box around it. Like it's wanting to create cards but it doesn't. Or something like that.

Thanks for your help.

Hello all,

My problem consists of want to report a table that hasn't been created yet. These tables would be on a different page within the space so I was hoping to use a
{local-report} along with a {text-filter:data:'table name'|include=...}. What I want to filter by is the title of the page that I'm reporting on. Here's what I have so far.

{report-block}
{local-reporter:content:children|location=Instruments Home}
{text-filter:data:Instrument Statistics|include={report-info:content:title}}
{local-reporter}
{report-body}
*{report-info:content:title|link=true}*
{report-table}
{local-reporter:data:Instrument Statistics}
{report-column:title=Instrument Type}{report-info:map:Instrument Type}{report-column}
{report-column:title=Specific Type}{report-info:map:Specific Type}{report-column}
{report-column:title=Wavelength}{report-info:map:Wavelength}{report-column}
{report-column:title=Spatial Resolution}{report-info:map:Spatial Resolution}{report-column}
{report-column:title=Mass (kg)}{report-info:map:Mass (kg)}{report-column}
{report-column:title=Power (W)}{report-info:map:Power (W)}{report-column}
{report-column:title=Volume}{report-info:map:Volume}{report-column}
{local-reporter}
{report-table}
{report-body}
{report-block}

Any suggestions? Will this even work?

If the 'Instrument Statistics' data field is a list-data + content-options, you use the content-filter instead of your text-filter:

{content-filter:data:Instrument Statistics > reference:value|scope=@self}

This will match if the item selected is the current page ('@self').

I'm not sure if it is list data.  Maybe if i describe the situation a little better you can tell.

The Hierarchy:
>Space

>> 4 Children off the Home (2 of which will be referred to as Missions and Instruments)

>>> Unlimited Children to be added to these subgroups as any Confluence user sees fit (2 of which will be referred to as Mission 1 and Instrument 1 which are children of Missions and Instruments respectively)

 The Goal:

Since the individual children in the Missions subgroup are intended to be an overview of all aspects of a mission, information on the Instruments children associated is also desired.  What we desire to display on the Mission 1 page is a table of information that is created in Instrument 1 when Instrument 1 is created.

 The Challenge:

This would be a simple matter if Instrument 1 already existed and we could "hard code" a name into a local-reporter|text-filter|report-table combo, but there are 3 problems with this.

1) We don't want the casual confluence user to have to go into the 'Edit Layout' mode and change the local-reporter|text-filter|report-table code themselves,

2) If Instrument 1 doesn't exist yet in the first place and will be added later, there is nothing yet there to report on, and

3) Since we don't want to grab every single data table from every single Instruments child, and since we need to write this reporter generically in a template that varies the filter to only search for Instruments children that contain a string of characters associated with the specific Missions child (e.g. Mission 1 only wanting to report info on Instrument 1 and not a supposed Instrument X, but then another supposed Mission X is created using the same template as Mission 1 but will only report info from Instruments it is associated with, like Instrument X)

This would suggest that in our template we need a filter that has a variable as its regular expression, one that pulls the title of Mission 1 (or Mission X as the case may be) and filters through Instruments children looking for instances of this title that the user will be prompted to fill in when creating an Instruments child (i.e. if Instrument 1 is interested in Mission 1, then Mission 1's title will be provided somewhere in Instrument 1's table to be reported).

I've had difficulty with this because if you try a text-filter with include={report-info:content:title} it simply displays the code rather than grabbing Mission 1's title and using it as the filter parameter.

One last piece of info, the table in Instrument 1 is generated via an editable table code and is subsequently filled upon generation of the Instruments child.

Sorry for the long-winded and probably painfully non-technical reply, just wanted to make sure my intent was portrayed and I'm working on a limited comp sci vocab here .

I'm assuming each Instrument is only interested in one Mission at present. Multiples can be done, but will have slightly different markup. My suggestion is to put something like this on your Instrument pages:

{list-data:Mission}
  {content-options:parent=Missions}
{list-data}

This will let Instrument page editors select from the available list of Missions.

Then, on your Mission page, have something like this:

h2. Instruments

{report-list}
{local-reporter:content:children|source=Instruments}
  {content-filter:data:Mission > reference:value|scope=@self}
{local-reporter}

{report-body}{report-info:content:title|link=true}

{report-list}

This will display all Instrument pages that link to the current (@self) Mission page.

Good luck

View the rest of this thread  |  4 more comments by 2 persons
Copyright(c) CustomWare Asia Pacific Pty Ltd
Powered by Atlassian Confluence 2.7.3, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators