[rules-users] Searching for archived packages in the repository

Carlsen, Len len.carlsen at ubc.ca
Thu Mar 27 19:35:11 EDT 2008


Hi,

 

I am trying to get a list of all archived packages from the Drools
repository but I can't seem to get packages that have been archived.

Below is the query I am using to get a list of archived packages:

 

RulesRepository repo = createRepository();   

 

PackageItem item = repo.createPackage( "testPackage", "A test" );

item.archiveItem( true );

item.checkin( "Archive test" );

 

System.out.println( "Archived=" + repo.loadPackageByUUID( item.getUUID()
).isArchived());

 

String sql = "SELECT " 

      + PackageItem.TITLE_PROPERTY_NAME + ", " 

      + PackageItem.DESCRIPTION_PROPERTY_NAME + ", " 

      + PackageItem.CONTENT_PROPERTY_ARCHIVE_FLAG; 

sql += " FROM " + PackageItem.RULE_PACKAGE_TYPE_NAME;

sql += " WHERE ";

sql += " jcr:path LIKE '/" 

      + RulesRepository.RULES_REPOSITORY_NAME + "/" 

      + RulesRepository.RULE_PACKAGE_AREA + "/%'";

//sql += " AND " + PackageItem.CONTENT_PROPERTY_ARCHIVE_FLAG + " =
'true'";

 

Query q =
repo.getSession().getWorkspace().getQueryManager().createQuery( sql,
Query.SQL );

 

QueryResult res = q.execute();

 

Iterator<PackageItem> it = new PackageIterator( repo, res.getNodes() );

 

while( it.hasNext() )

{

      PackageItem pi = it.next();

      System.out.println( "*****  item=" +pi.getUUID() + ", name="
+pi.getName() + ", isArchived=" + pi.isArchived() );

}

 

If I don't archive a package then the code returns my package. I know
that the package is archived because if I do

"loadPackageByUUID( uuid ).isArchived()" it return true.

 

Does anyone know what I am doing wrong here?

 

Thanks,

 

Len

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080327/3125e074/attachment.html 


More information about the rules-users mailing list