cancel
Showing results for 
Search instead for 
Did you mean: 

Where to look for categories?

alina
Champ in-the-making
Champ in-the-making
Hello everybody,
I'm a total newbie to Alfresco scripting, but I have an urgent task, that has to be completed 'yesterday'. I'm a PHP& JavaScript programmer, but I do not yet understand the object model and the framework in Alfresco.

My task is to create category tree according to a structure stored elsewhere (XML, plain text or database).
I've found LOTS of info, but I can't put it all together.
The question is - where in the object model I can find categories? (those I can manage through Administration Console - Category Management) What is their root object?
14 REPLIES 14

afaust
Legendary Innovator
Legendary Innovator
Hello,

categories can be found via the classification root object.

Regards
Axel

alina
Champ in-the-making
Champ in-the-making
Axel, thanks a lot for your help.

Another question on classification. I have two properties there: a name (in Cyrillic) and a description. node.name returns me its ID (hex) and I cannot find descriptions at all.

And the final point is to create categories with descritions. I can see createSubCategory function, but it accepts only 'name' as an argument. How can I add a description?

afaust
Legendary Innovator
Legendary Innovator
Hello,

hmm, node.name (or alternatively node.properties.name) should yield your cyrillic name, not the ID. The description is a regular property and should be obtainable by node.properties.description.

You're right that the createSubCategory function only accepts a "name" argument. All classification services in Alfresco work on the assumption, that a classification node at their core only require a name for the classification tree. In order to add and access metadata to categories, you need to use the standard NodeService or ScriptNode operations, since categories are essentially just plain old nodes. So 1) create category via createSubCategory and then 2) modify the properties of the returned category node.

Regards
Axel

alina
Champ in-the-making
Champ in-the-making
Thank you very much for your answer.

Yet I don't understand. Maybe on my installation there is smth. wrong with the classification object?

I've written a primitive script - a line, actually:
var nodes_prop = classification.getAllCategoryNodes().length;

And only this var output in the template.

This is what I get from the server:

Message:   07130152 Wrapped Exception (with status template): 07136864 Failed to execute script '/test/folder1.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': 07136863 Can't find method org.alfresco.repo.jscript.Classification.getAllCategoryNodes(). (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/test/folder1.get.js#3)
   
Exception:   org.mozilla.javascript.EvaluatorException - Can't find method org.alfresco.repo.jscript.Classification.getAllCategoryNodes(). (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/test/folder1.get.js#3)
   
   org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109)
   org.mozilla.javascript.Context.reportRuntimeError(Context.java:1030)
   org.mozilla.javascript.Context.reportRuntimeError(Context.java:1086)

etc…

What is the reason?

afaust
Legendary Innovator
Legendary Innovator
Hello,

you're missing a parameter in your call to getAllCategoryNodes. This method requires you to specify the QName-String of the classification of which you want to retrieve all category nodes, so e.g.
var size = classification.getAllCategoryNodes("cm:generalClassifiable").length;

Regards
Axel

alina
Champ in-the-making
Champ in-the-making
Yes, thanks, indeed, my fault. Though I've tried this way too. Now it gives 0 as a result. Is that OK? I guess, no.

afaust
Legendary Innovator
Legendary Innovator
For cm:generalClassifiable this is not ok (except if you have deleted all the out-of-the-box categories). It may be that your Lucene / SOLR service is not working correctly, since all category handling is done via searches. Check the categoryRoot and classification via the node browser to make sure the categories are actually there.

Regards
Axel

alina
Champ in-the-making
Champ in-the-making
The categories are there. And if I use luceneSearch, I find many of them (but without proper names, as I've told above). What can I do in such situation? Is it possible to fix the search services?

alina
Champ in-the-making
Champ in-the-making
Our admin told me that there are indexes broken on the site. Could that be the reason?
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.