AnsweredAssumed Answered

CML Documentation? E.G. how to add Aspect to existing node?

Question asked by jasperk64 on Jan 17, 2007
Latest reply on Feb 1, 2007 by rwetherall
Is there an update on availability of CML documentation?

For example, I downloaded the 1.3 community SDK and tried to mod the Query1 to add an aspect to an *existing* node, but I can't get it to work (creating a node and adding an aspect in the same CML block with a "local id" of "1" works).

Here is the code I tried, what's wrong with my CML? I put in print statements and the code seems to execute fine (no exceptions) but after the code is done, the aspect was not added to the existing node.

  // Look string "UNIQUE" in text, multiple existing nodes have this
  Query query = new Query(QueryLanguageEnum.lucene, "TEXT:'UNIQUE'");
               
  // Execute the query
  QueryResult queryResult = repositoryService.query(storeRef, query, false);
               
  // Add aspect to first result
  ResultSet resultSet = queryResult.getResultSet();
  ResultSetRow[] rows = resultSet.getRows();
  if (rows == null)
  {
        System.out.println("No query results found.");
  }
  else
  {
   // Get the id of the first result
   String firstResultId = rows[0].getNode().getId();

   // Setting a property
  NamedValue[] specificationProps = new NamedValue[1];
                   
  // Is it possible to not set at all and still add aspect?
  specificationProps[0] = Utils.createNamedValue(PROP_MYPROP,"DDD");
        
  CMLAddAspect addAspect = new CMLAddAspect(ASPECT_MYASPECT, specificationProps, null, firstResultId);
                
                    // Construct CML Block
                    CML aspect_cml = new CML();
                    aspect_cml.setAddAspect(new CMLAddAspect[] {addAspect});
                    repositoryService.update(aspect_cml);
}

Outcomes