cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the name of a category?

jlbarrera
Champ in-the-making
Champ in-the-making
Hi

I need to get the name of a category of a Node.

By this way: (where row is a ResultSetRow)

row.getColumns(y).getValue()

I get the reference to Category Node:

workspace://SpacesStore/9472c578-c478-11da-8be5-db2bb273e6f3

But…How can get the name?

Thank!
4 REPLIES 4

jlbarrera
Champ in-the-making
Champ in-the-making
I try by other way..but i cant do it:

CategoriesResult[] categorias = null;
categorias = WebServiceFactory.getClassificationService().getCategories(predicate);
   

Where predicate is:

Reference reference = new Reference(STORE, row.getNode().getId(), null);
Predicate predicate = new Predicate(new Reference[]{reference}, null, null);

And Row is a ResultSetRow…

But in this code i received an error:

Type mismatch: cannot convert from CategoriesResult[] to CategoriesResult[]

Any ideas?

abichet
Champ in-the-making
Champ in-the-making
hi
you can retrieve the name of a node by :
Repository.getNameForNode(nodeService,nodeRef)

jlbarrera
Champ in-the-making
Champ in-the-making
Ok But i want make this by an Web Services.

jlbarrera
Champ in-the-making
Champ in-the-making
I solved the problem by this way:

1?) I have some ID's of any Categories (String)
I want get the name of theses categories so…

2?) i created a method that build a query, this query return all Categories (Nodes) that the uid is equals to ID:

public  static List<String> SearchCategoty (String[] lista) 
      throws ServiceException, RemoteException, RepositoryFault
   {
      /**
       * A partir de un String[] con los ID de la categor?a, obtengo sus nombres a trav?s de una b?squeda
       */
      
      StringBuilder idQuery = new StringBuilder(128);
      List<String> Categorias = new ArrayList<String>(lista.length);
      
      for (String c: lista){
         c=c.trim();
         if (idQuery.length() != 0){
            idQuery.append("\" OR ID:\"");
         }
         idQuery.append©;   
      }
      
      RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
      String pathQuery="ID:\"" + idQuery.toString() + "\"" ;
      Query queryCategory = new Query(QueryLanguageEnum.lucene, pathQuery);
      QueryResult queryResultCat = repositoryService.query(STORE, queryCategory, false);
      ResultSet resultSetCat = queryResultCat.getResultSet();
      ResultSetRow rowsCat[] = resultSetCat.getRows();
      
      // Compruebo que no haya elementos repetidos y retorno una lista de Strings
      if (rowsCat != null){
         for (ResultSetRow row: rowsCat){
            NamedValue columns[] = row.getColumns();
            for (NamedValue col: columns){
               if (col.getName().endsWith("name")){
                  col.getValue();
                  if (Categorias.contains(col.getValue())){
                     break;
                  }else{
                     Categorias.add(col.getValue());
                  }
               }
               
            }
         }
      }
      
      return Categorias;
   }