Well, there might be a way to do what you want, but you will need to go to the dark side of drools :) (basically means magical castings)<div><br></div><div>A KnowwledgeBase contains one or more packages, and inside the packages is where the Declared Types live.</div>
<div>So, using this code (I didn't test it but it should work), you can access all your declared types of all the packages in a knowledge base:</div><div><br></div><div><div>Set<String> declaredFactTypes = new HashSet<String>(); </div>
<div> Collection<KnowledgePackage> knowledgePackages = kbase.getKnowledgePackages();</div><div> for (KnowledgePackage knowledgePackage : knowledgePackages) {</div><div> //the key of this map is the simple name of the declared type and not the fqn</div>
<div> Map<String, TypeDeclaration> typeDeclarations = ((KnowledgePackageImp)knowledgePackage).pkg.getTypeDeclarations();</div><div> //collect all the keys in the set</div><div> for (String type : typeDeclarations.keySet()) {</div>
<div> //store the fqn of the declared types to avoid name collision</div><div> declaredFactTypes.add(knowledgePackage.getName()+"."+type);</div><div> }</div><div> }</div>
</div><div> <br clear="all">Best Regards,<br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com </a><br>- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br><br><div class="gmail_quote">On Fri, Dec 9, 2011 at 12:43 PM, srinivasasanda <span dir="ltr"><<a href="mailto:srinivasasanda@gmail.com">srinivasasanda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thanks Lauene for your response.Really Thank you very much.<br>
<br>
I've tried with this code,as u said it is being not as much as stable.Trying<br>
to work out it.By the way,Here there is no way to retrieve the fact names.My<br>
requirement is<br>
<br>
I'm having a package-----------*PersonDetails*<br>
<br>
In that I declared a Model called--------*Person*<br>
<br>
In that I declared two facts with two fields called --------------*Man<br>
(name,age) Women(name,age)*<br>
<br>
Now,My objective is to print the factnames in console.It means My output<br>
should be FactNames are *Man and Women*.Is it possible?<br>
<br>
How can I achieve this.....Can you please suggest me please according to my<br>
requirement.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Fact-Names-in-a-Model-tp3572234p3572703.html" target="_blank">http://drools.46999.n3.nabble.com/Fact-Names-in-a-Model-tp3572234p3572703.html</a><br>
</font></span><div class="HOEnZb"><div class="h5">Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br></div>