You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Alec Fernandez <Al...@sas.com> on 2008/04/10 05:10:17 UTC

adding filters to a filterset

Hello,

I'm hoping someone can tell me if this is possible.  I'm beginning to think that since there is no set method in Project that this simply is not possible.

I define a filterset in a target and then call a custom task to which I pass the refid of the filterset.

      <filterset id="configobj.filterset" >
          <filter token="foo.foo" value="bar.bar" />
      </filterset>


      <mytask filteretrefid="configobj.filterset" />
         </then>

In the task I can then see the filters in the filterset

            Reference r = new Reference(getProject(), filtersetrefid);
            f = (FilterSet) r.getReferencedObject();
            String allfilters = f.getFilterHash().toString();
            Logger.log( Project.MSG_VERBOSE, this, "filterhash toString():" + allfilters );

I then use f.addFilter to add filter elements to the filterset and I can print these in the task.

[GetObjectProperties] filterhash toString():{oma.folder.products.path=/Products, oma.person.demo.login.userid=hpusrv001\sasdemo, foo.foo=bar.bar}


However, upon returning from the task to the calling target, the filterset seems to only have the original filter element that was added in the filterset task.

Does anyone know if I can accomplish adding filter elements to a filterset in this manner?
Or can I create a new filterset in my task, give it a refid and then use that refid back in my target?

Thanks,
Alec



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: adding filters to a filterset

Posted by Alec Fernandez <Al...@sas.com>.
For future reference:

the fact that I was creating a new reference was the cause of my problems.

Reference r = new Reference(getProject(), filtersetrefid);

This code works and allows me to use the expanded filterset in my project after my custom task runs.

f = (FilterSet) getProject().getReference(filtersetrefid)

-Alec

>> -----Original Message-----
>> From: Alec Fernandez [mailto:Alec.Fernandez@sas.com]
>> Sent: Wednesday, April 09, 2008 11:10 PM
>> To: Ant Users List
>> Subject: adding filters to a filterset
>>
>> Hello,
>>
>> I'm hoping someone can tell me if this is possible.  I'm beginning to
>> think that since there is no set method in Project that this simply is
>> not possible.
>>
>> I define a filterset in a target and then call a custom task to which
>> I pass the refid of the filterset.
>>
>>       <filterset id="configobj.filterset" >
>>           <filter token="foo.foo" value="bar.bar" />
>>       </filterset>
>>
>>
>>       <mytask filteretrefid="configobj.filterset" />
>>          </then>
>>
>> In the task I can then see the filters in the filterset
>>
>>             Reference r = new Reference(getProject(), filtersetrefid);
>>             f = (FilterSet) r.getReferencedObject();
>>             String allfilters = f.getFilterHash().toString();
>>             Logger.log( Project.MSG_VERBOSE, this, "filterhash
>> toString():" + allfilters );
>>
>> I then use f.addFilter to add filter elements to the filterset and I
>> can print these in the task.
>>
>> [GetObjectProperties] filterhash
>> toString():{oma.folder.products.path=/Products,
>> oma.person.demo.login.userid=hpusrv001\sasdemo, foo.foo=bar.bar}
>>
>>
>> However, upon returning from the task to the calling target, the
>> filterset seems to only have the original filter element that was
>> added in the filterset task.
>>
>> Does anyone know if I can accomplish adding filter elements to a
>> filterset in this manner?
>> Or can I create a new filterset in my task, give it a refid and then
>> use that refid back in my target?
>>
>> Thanks,
>> Alec
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org