Author: chathura
Date: Sat Dec 15 07:19:06 2007
New Revision: 11163
Log:
Implemented a searched tags display with the tag count in the tag search
results page.
Now, if you search for tags, "java" and "wso2", tag counts for each resource
tagged with those two tags will be displayed along with the resource.
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SearchAction.java
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/utils/ResourceData.java
trunk/registry/modules/webapps/src/main/webapp/admin/search.jsp
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
Sat Dec 15 07:19:06 2007
@@ -508,6 +508,10 @@
// break the tags from spaces
String[] tags = tag.trim().split(",");
+ for (int i = 0; i < tags.length; i++) {
+ tags[i] = tags[i].trim();
+ }
+
//List pathList = new ArrayList();
List taggedPaths = new ArrayList();
@@ -523,7 +527,6 @@
taggedResourcePath.setResourcePath(path);
for (int i = 0; i < tags.length; i++) {
- tags[i] = tags[i].trim();
long count = tagsDAO.getTagCount(path, tags[i], conn);
taggedResourcePath.addTagCount(tags[i], count);
}
Modified:
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SearchAction.java
==============================================================================
---
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SearchAction.java
(original)
+++
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SearchAction.java
Sat Dec 15 07:19:06 2007
@@ -44,71 +44,97 @@
public String execute(HttpServletRequest request) throws RegistryException
{
setRequest(request);
-
+
// get the resource for the queryPath
// get all its children and fill ResourceOverview objects
// add ResourceOverview object to the resourceDataList list
Registry registry = getRegistry();
- String[] childPaths;
+ //String[] childPaths;
if (tag != null && tag.length() != 0) {
TaggedResourcePath[] taggedPaths =
registry.getResourcePathsWithTag(tag);
- childPaths = new String[taggedPaths.length];
+ //childPaths = new String[taggedPaths.length];
for (int i = 0; i < taggedPaths.length; i++) {
- childPaths[i] = taggedPaths[i].getResourcePath();
- }
+ String resultPath = taggedPaths[i].getResourcePath();
- } else {
+ ResourceData resourceData = new ResourceData();
+ resourceData.setResourcePath(resultPath);
- Resource resource;
- try {
- resource = registry.get(queryPath);
- } catch (AuthorizationFailedException e) {
- status = "error";
- errorMessage = "User " + getUserName() +
- " does not have permission to browse this collection.";
- return ERROR;
- }
+ if (resultPath != null) {
+ String[] parts =
resultPath.split(RegistryConstants.PATH_SEPARATOR);
+ resourceData.setName(parts[parts.length - 1]);
+ }
- if (resource == null) {
- status = "error";
- errorMessage = "Requested collection at queryPath " +
queryPath + " does not exists.";
- return ERROR;
- }
+ try {
+ Resource child = registry.get(resultPath);
- childPaths = (String[]) resource.getContent();
- }
+ resourceData.setResourceType(
+ child.isDirectory()? ResourceData.COLLECTION :
ResourceData.RESOURCE);
+ resourceData.setAuthorUserName(child.getAuthorUserName());
+ resourceData.setDescription(child.getDescription());
+
resourceData.setAverageRating(registry.getAverageRating(child.getPath()));
+ resourceData.setCreatedOn(child.getCreatedTime());
+ resourceData.setTagCounts(taggedPaths[i].getTagCounts());
- for (int i = 0; i < childPaths.length; i++) {
+ } catch (AuthorizationFailedException e) {
- ResourceData resourceData = new ResourceData();
- resourceData.setResourcePath(childPaths[i]);
+ resourceData.setResourceType(ResourceData.UNKNOWN);
+ }
- if (childPaths[i] != null) {
- String[] parts =
childPaths[i].split(RegistryConstants.PATH_SEPARATOR);
- resourceData.setName(parts[parts.length - 1]);
+ resourceDataList.add(resourceData);
}
- try {
- Resource child = registry.get(childPaths[i]);
-
- resourceData.setResourceType(
- child.isDirectory()? ResourceData.COLLECTION :
ResourceData.RESOURCE);
- resourceData.setAuthorUserName(child.getAuthorUserName());
- resourceData.setDescription(child.getDescription());
-
resourceData.setAverageRating(registry.getAverageRating(child.getPath()));
- resourceData.setCreatedOn(child.getCreatedTime());
-
- } catch (AuthorizationFailedException e) {
-
- resourceData.setResourceType(ResourceData.UNKNOWN);
- }
+ } else {
- resourceDataList.add(resourceData);
+ //Resource resource;
+ //try {
+ // resource = registry.get(queryPath);
+ //} catch (AuthorizationFailedException e) {
+ // status = "error";
+ // errorMessage = "User " + getUserName() +
+ // " does not have permission to browse this
collection.";
+ // return ERROR;
+ //}
+ //
+ //if (resource == null) {
+ // status = "error";
+ // errorMessage = "Requested collection at queryPath " +
queryPath + " does not exists.";
+ // return ERROR;
+ //}
+ //
+ //childPaths = (String[]) resource.getContent();
}
+ //for (int i = 0; i < childPaths.length; i++) {
+ //
+ // ResourceData resourceData = new ResourceData();
+ // resourceData.setResourcePath(childPaths[i]);
+ //
+ // if (childPaths[i] != null) {
+ // String[] parts =
childPaths[i].split(RegistryConstants.PATH_SEPARATOR);
+ // resourceData.setName(parts[parts.length - 1]);
+ // }
+ //
+ // try {
+ // Resource child = registry.get(childPaths[i]);
+ //
+ // resourceData.setResourceType(
+ // child.isDirectory()? ResourceData.COLLECTION :
ResourceData.RESOURCE);
+ // resourceData.setAuthorUserName(child.getAuthorUserName());
+ // resourceData.setDescription(child.getDescription());
+ //
resourceData.setAverageRating(registry.getAverageRating(child.getPath()));
+ // resourceData.setCreatedOn(child.getCreatedTime());
+ //
+ // } catch (AuthorizationFailedException e) {
+ //
+ // resourceData.setResourceType(ResourceData.UNKNOWN);
+ // }
+ //
+ // resourceDataList.add(resourceData);
+ //}
+
status = "success";
return SUCCESS;
}
Modified:
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/utils/ResourceData.java
==============================================================================
---
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/utils/ResourceData.java
(original)
+++
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/utils/ResourceData.java
Sat Dec 15 07:19:06 2007
@@ -19,6 +19,8 @@
import org.wso2.registry.RegistryConstants;
import java.util.Date;
+import java.util.Map;
+import java.util.HashMap;
public class ResourceData {
@@ -41,6 +43,7 @@
private float averageRating;
private String[] averageStars = new String[5];
private Date createdOn;
+ private Map tagCounts = new HashMap();
public String getName() {
return name;
@@ -130,4 +133,12 @@
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
+
+ public Map getTagCounts() {
+ return tagCounts;
+ }
+
+ public void setTagCounts(Map tagCounts) {
+ this.tagCounts = tagCounts;
+ }
}
Modified: trunk/registry/modules/webapps/src/main/webapp/admin/search.jsp
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/search.jsp
(original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/search.jsp Sat Dec
15 07:19:06 2007
@@ -3,6 +3,7 @@
<%@ page import="java.util.Iterator" %>
<%@ page import="org.wso2.registry.web.actions.utils.ResourceData" %>
<%@ page import="org.wso2.registry.web.actions.SearchAction" %>
+<%@ page import="java.util.Map" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
@@ -62,10 +63,23 @@
<a href="#" title="Show
Details" style="margin-left:5px;"><img src="images/icon-details.gif" border="0"
/></a>
<a href="#" title="Delete"
style="margin-left:5px;"><img src="images/icon-trash.gif" border="0" /></a>
</td>
-
-
</tr>
- <tr id="1-des" style="display:none;">
+ <tr>
+ <td colspan="6">
+ <%
+ Map tagCounts = resourceData.getTagCounts();
+ Iterator iTags = tagCounts.keySet().iterator();
+ while (iTags.hasNext()) {
+ String tag = (String) iTags.next();
+ Long count = (Long) tagCounts.get(tag);
+ %>
+
+ <a
href="/wso2registry/system/search?criteria=<%=tag%>"><%=tag%></a>
(<%=count.toString()%>)<% if (iTags.hasNext()) { %> | <% } %>
+
+ <% } %>
+ </td>
+ </tr>
+ <tr id="1-des" style="display:none;">
<td colspan="6"
class="table-description">
<%=resourceData.getDescription()%>
</td>
_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev