10-30-2009 10:36 AM
11-03-2009 02:35 AM
11-04-2009 05:03 AM
11-04-2009 07:22 AM
/**
* Class to contain the information about the result from the query
*/
public class ContentResult
{
private String id;
private String name;
private String description;
private String url;
private String createDate;
public ContentResult(String id)
{
this.id = id;
}
public String getCreateDate()
{
return createDate;
}
public void setCreateDate(String createDate)
{
this.createDate = createDate;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public String getId()
{
return id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getUrl()
{
return url;
}
public void setUrl(String url)
{
this.url = url;
}
@Override
public String toString()
{
return "id=" + this.id +
"; name=" + this.name +
"; description=" + this.description +
"; created=" + this.createDate +
"; url=" + this.url;
}
}
11-04-2009 09:43 AM
11-04-2009 09:49 AM
/**
* Get a list of ordered results of documents in the space specified matching the search
* text provided.
*
* @param spaceName the name of the space (immediatly beneth the company home space) to search
* @param searchValue the FTS search value
* @return list of results
*/
public List<ContentResult> getRankedContent(String spaceName, String searchValue)
{
List<ContentResult> results = new ArrayList<ContentResult>();
try
{
AuthenticationUtils.startSession(USERNAME, PASSWORD);
try
{
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
// Get a reference to the space we have named
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);
// Create a query object, looking for all items with alfresco in the name of text
Query query = new Query(
Constants.QUERY_LANG_LUCENE,
"+PARENT:\"workspace://SpacesStore/"+ nodes[0].getReference().getUuid() + "\" +TEXT:\"" + searchValue + "\"");
// 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())
{
if (namedValue.getName().endsWith(Constants.PROP_CREATED) == true)
{
contentResult.setCreateDate(namedValue.getValue());
}
else if (namedValue.getName().endsWith(Constants.PROP_NAME) == true)
{
contentResult.setName(namedValue.getValue());
}
else if (namedValue.getName().endsWith(Constants.PROP_DESCRIPTION) == true)
{
contentResult.setDescription(namedValue.getValue());
}
else if (namedValue.getName().endsWith(Constants.PROP_CONTENT) == true)
{
// We could go to the content service and ask for the content to get the URL but to save time we
// might as well dig the content URL out of the results.
String contentString = namedValue.getValue();
String[] values = contentString.split("[|=]");
contentResult.setUrl(values[1]);
}
}
results.add(contentResult);
}
}
}
finally
{
// End the session
AuthenticationUtils.endSession();
}
}
catch (Exception serviceException)
{
throw new RuntimeException("Unable to perform search.", serviceException);
}
return results;
}
http://sourceforge.net/projects/alfresco/files/SDK/11-04-2009 10:07 AM
// Para cada row x dentro de rows
NamedValue[] columns = row.getColumns();
for (int y = 0; y < columns.length; y++){
System.out.println("row " + x + ": "
+ row.getColumns(y).getName() + " = "
+ row.getColumns(y).getValue());
}
11-05-2009 10:43 AM
…….
…….
Query query = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"/app:company_home/cm:prueba_folder//*\" + @cm\\:name:scri*");
final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
QueryResult queryResult = repositoryService.query(STORE, query, false);
ResultSet results = queryResult.getResultSet();
ResultSetRow[] rows = results.getRows();
if(rows != null){
for(ResultSetRow row : rows){
String nodeId = row.getNode().getId();
ContentResult contentResult = new ContentResult(nodeId);
for (NamedValue namedValue : row.getColumns()){
if (namedValue.getName().endsWith(Constants.PROP_CREATED) == true){
contentResult.setCreateDate(namedValue.getValue());
}
else if (namedValue.getName().endsWith(Constants.PROP_NAME) == true){
contentResult.setName(namedValue.getValue());
}
else if (namedValue.getName().endsWith(Constants.PROP_DESCRIPTION) == true){
contentResult.setDescription(namedValue.getValue());
}
else if (namedValue.getName().endsWith(Constants.PROP_CONTENT) == true){
// We could go to the content service and ask for the content to get the URL but to save time we
// might as well dig the content URL out of the results.
String contentString = namedValue.getValue();
String[] values = contentString.split("[|=]");
contentResult.setUrl(values[1]);
}
System.out.println("Resultado " + x + ": \n" + contentResult.toString());
}
}
11-18-2009 07:46 AM
11-25-2009 10:41 AM
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.