cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to get the Path from a ResultSetRow

jeango
Champ in-the-making
Champ in-the-making
Hi There,

Here is my situation

I have some Categories, each category is a space in alfresco with type "category" and (amongst others) two named properties: "CatNum" and "CatName"
I have some Subjects, each subject is a space in alfresco with type "subject".  subjects can be children of either a category, or another subject. the have a named property "SubNum"
I have some products that are described in pdf files (and have a specific type named "product").  products can be children of either a Category or a Subject

I need to make a search tool that uses the Web Services API to list all products that are found somewhere under a Category with "CatName" that starts with the letter A (for instance) and a Subject with SubNum starting with the number 123

The way I thought I'd do this was to first search for all the Categories that start with A, then for each found node, use its Path (by doing +PATH:"blabla//*" to search for all the Subjects with SubNum starting 123 and use their path to search for all the products in there.

But I can't figure out, after recieving the ResultSetRow back from the query, how to get the Path from there.  Looking at the docs it seems that this information is just not available at all in ResultSetRow.  Is there maybe another way to do this?

Thanks in advance
3 REPLIES 3

fstnboy
Champ on-the-rise
Champ on-the-rise
Hi,

What you can do is get the path of each node from the resultSet…. I don´t know if that´s what you want.

jeango
Champ in-the-making
Champ in-the-making
Yeah, getting the path of each node in the ResultRet is exactly what I need to do… however what I have here is a org.alfresco.webservice.types.ResultSet and not a org.alfresco.service.cmr.search.ResultSet so there is no getPropertyPaths method available.

masofcon
Champ in-the-making
Champ in-the-making
Look at this code:



   ResultSetRow row = resultSet.getRows();
   // Get document properties
   NamedValue[] props = row.getColumns();
   HashMap<String, Serializable> properties = getPropertyMap(props);

   // print path property
   System.out.println(properties.get("{http://www.alfresco.org/model/content/1.0}path"));

and getPropertyMap(…) is:

   private HashMap<String, Serializable> getPropertyMap(NamedValue[] namedValues) {
      HashMap<String, Serializable> properties = new HashMap<String, Serializable>();
      if (namedValues != null) {
         for (NamedValue value : namedValues) {
            properties.put(value.getName(), value.getValue());
         }
      }
      return properties;
   }


Hope it helps.