01-10-2008 05:23 AM
I am new to alfresco and tried everywhere to find out how to iterate through the repository using the soap interface but so far can only see the Query interface which is not really an iterative process.to the prog env. which is the wrong place I think (sorry for that)
I just want to iterate the tree to put all the contents in the repository into a java tree.
Can anybody point me in the right direction thanks.
Reference reference = new Reference(STORE, null, "/app:company_home/*[@cm:name=\"" + spaceName + "\"]");
Predicate predicate = new Predicate(new Reference[]{reference}, null, null);
Node[] nodes = repositoryService.get(predicate);
Query query = new Query(
Constants.QUERY_LANG_LUCENE,
"+PARENT:\"workspace://SpacesStore/"+ nodes[0].getReference().getUuid() + "\"");
// Execute the query
QueryResult queryResult = repositoryService.query(STORE, query, false);
// Display the results
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
if (rows != null)
{
// Get the infomation from the result set
for(ResultSetRow row : rows)
{
String nodeId = row.getNode().getId();
// ContentResult contentResult = new ContentResult(nodeId);
for (NamedValue namedValue : row.getColumns())
{
System.out.println(namedValue.getName()+" : "+namedValue.getValue());
if(namedValue.getName().endsWith(Constants.PROP_NAME) == true )
{
TreeItem item = new TreeItem( treeMailMerge, SWT.NONE );
item.setText(namedValue.getValue());
}
}
}
}
}
Node[] nodes = repositoryService.get(predicate);only supports a single reference. I am stuck and ANY help would be really appreciated. Thanks in advance.
01-10-2008 06:46 AM
void loadStore(String spaceName, RepositoryServiceSoapBindingStub repositoryService) throws RepositoryFault, RemoteException
{
Query query = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"/{http://www.alfresco.org/model/application/1.0}company_home/*\"");
// Execute the query
QueryResult queryResult = repositoryService.query(STORE, query, false);
// Load the results
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
if (rows == null)
{
System.out.println("No query results found.");
}
else
{
System.out.println("Results from query:");
TreeItem item = new TreeItem( this.treeMailMerge, SWT.NONE );
item.setText("root");
outputResultSet(repositoryService, rows, item);
}
}
public void outputResultSet(RepositoryServiceSoapBindingStub repositoryService, ResultSetRow[] rows, TreeItem parentTreeItem) throws RepositoryFault, RemoteException
{
if (rows != null)
{
for (ResultSetRow row :rows)
{
for( NamedValue namedValue: row.getColumns())
{
if(namedValue.getName().endsWith(Constants.PROP_NAME) == true )
{
//LOAD THE RESULT INTO AN SWT TREE
TreeItem item = new TreeItem( parentTreeItem, SWT.NONE );
item.setText(namedValue.getValue());
// Get the id of the first result
Reference reference = new Reference(STORE, row.getNode().getId(), null);
// Get the parent(s) of the first result
QueryResult childQueryResult = repositoryService.queryChildren(reference);
// Get the child of the this node
ResultSet childResultSet = childQueryResult.getResultSet();
ResultSetRow[] childRows = childResultSet.getRows();
if (childRows != null)
outputResultSet(repositoryService, childRows, item);
}
}
}
}
}
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.