Hi Matthias, You should use the Query Module ( http://extensions.xwiki.org/xwiki/bin/view/Extension/Query+Module ) to search for documents having objects of a specified type (e.g. QuarXs.NodeTypeClass). Also, the parameter passed to XWikiDocument#getXObjects(DocumentReference) is the class reference, i.e. the reference to the document that defines the class (e.g. a reference to QuarXs.NodeTypeClass document). You can access the javadoc from http://platform.xwiki.org/xwiki/bin/view/DevGuide/API .
Hope this helps, Marius On Mon, Oct 14, 2013 at 9:31 PM, Matthias Wegner <[email protected]> wrote: > Hello, > > i programmed a class /Node/ which is here used as /n/ and a class /NodeType/ > which is reference by Node. In the ClassBuilder from Node i use this method > to get the NodeType > > try { > List<XWikiDocument> docs = > getXWikiContext().getWiki().getStore().searchDocuments(" ", > getXWikiContext()); > for (XWikiDocument xWikiDocument : docs) { > List<BaseObject> objects = > xWikiDocument.getXObjects(xWikiDocument.getDocumentReference()); > if (objects != null) { > for (BaseObject bo : objects) { > if (bo.getName().contains("QuarXs.NodeTypeClass")) { > DefaultNodeType nt = new DefaultNodeType(); > nt.setName(bo.getStringValue("name")); > nt.setGuid(bo.getGuid()); > n.setType(nt); > } > } > } > } > } catch (Exception ee) { > System.out.println("Error: " + ee); > } > > To test this i defined a class from a wiki-page named "NodeTypeClass" in > Space "QuarXs". But now i used /AbstractMandatoryDocumentInitializer/ to > initialize everything. The Initialization works fine and looks great, but > now my upper method is not working. I can define objects and reference to > NodeType, but can't find objects of type "NodeType" with the upper method. > Can you give me a hint? > > I checked it with > > {{groovy}} > import org.rogatio.quarxs.Node; > for (Node node : > services.component.getComponentManager().getInstanceList(Node.class)) { > println("* "+node.getPrettyId() ) > println("** "+node.getType()) // gives back null. Reason: No > BaseObject of class "QuarXs.NodeTypeClass" found with upper method > // println("** "+node.getType().getName()) // worked fine when i made > the classes by hand > } > {{/groovy}} > > If you like i post my code. > > Regards, > Matthias > > > > -- > View this message in context: > http://xwiki.475771.n2.nabble.com/Query-for-self-defined-objects-tp7587586.html > Sent from the XWiki- Dev mailing list archive at Nabble.com. > _______________________________________________ > devs mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/devs _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

