From 41eefa4f67c30ba0c39ca312a8a77ad60cc36a55 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 15 Jan 2014 23:32:28 +0000 Subject: [PATCH] fixing browsing with typeahead git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1558609 13f79535-47bb-0310-9956-ffa450edef68 --- .../rest/api/model/BrowseResultEntry.java | 49 +++++++++++++++++-- .../rest/services/DefaultBrowseService.java | 4 +- .../src/main/webapp/js/archiva/search.js | 8 +-- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/BrowseResultEntry.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/BrowseResultEntry.java index 9ee7a1f1d..4b7816dce 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/BrowseResultEntry.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/BrowseResultEntry.java @@ -34,6 +34,16 @@ public class BrowseResultEntry private boolean project; + /** + * @since 2.0.0 + */ + private String groupId; + + /** + * @since 2.0.0 + */ + private String artifactId; + public BrowseResultEntry() { // no op @@ -70,13 +80,46 @@ public class BrowseResultEntry return this.name.compareTo( browseGroupResultEntry.name ); } + public String getGroupId() + { + return groupId; + } + + public void setGroupId( String groupId ) + { + this.groupId = groupId; + } + + public BrowseResultEntry groupId( String groupId ) + { + this.groupId = groupId; + return this; + } + + public String getArtifactId() + { + return artifactId; + } + + public void setArtifactId( String artifactId ) + { + this.artifactId = artifactId; + } + + public BrowseResultEntry artifactId( String artifactId ) + { + this.artifactId = artifactId; + return this; + } + @Override public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append( "BrowseResultEntry" ); - sb.append( "{name='" ).append( name ).append( '\'' ); + final StringBuilder sb = new StringBuilder( "BrowseResultEntry{" ); + sb.append( "name='" ).append( name ).append( '\'' ); sb.append( ", project=" ).append( project ); + sb.append( ", groupId='" ).append( groupId ).append( '\'' ); + sb.append( ", artifactId='" ).append( artifactId ).append( '\'' ); sb.append( '}' ); return sb.toString(); } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java index 7055fdea3..316531396 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java @@ -195,11 +195,11 @@ public class DefaultBrowseService new ArrayList( namespaces.size() + projects.size() ); for ( String namespace : namespaces ) { - browseGroupResultEntries.add( new BrowseResultEntry( namespace, false ) ); + browseGroupResultEntries.add( new BrowseResultEntry( namespace, false ).groupId( namespace ) ); } for ( String project : projects ) { - browseGroupResultEntries.add( new BrowseResultEntry( groupId + '.' + project, true ) ); + browseGroupResultEntries.add( new BrowseResultEntry( groupId + '.' + project, true ).groupId( groupId ).artifactId( project ) ); } Collections.sort( browseGroupResultEntries ); return new BrowseResult( browseGroupResultEntries ); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/search.js index 079d2bd94..be66adef3 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/search.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/search.js @@ -1528,7 +1528,7 @@ define("archiva.search",["jquery","jquery.ui","i18n","jquery.tmpl","select2","kn //window.sammyArchivaApplication.setLocation("#quicksearch~" + datum.artifactId); if (datum.project){ - goToArtifactDetail(theGroupId,datum.name); + goToArtifactDetail(datum.groupId,datum.artifactId); } else { var selectedRepo=getSelectedBrowsingRepository(); var location ="#browse"; @@ -1677,15 +1677,17 @@ define("archiva.search",["jquery","jquery.ui","i18n","jquery.tmpl","select2","kn if (data.browseResultEntries) { return $.isArray(data.browseResultEntries) ? $.map(data.browseResultEntries,function(item){ - return new BrowseResultEntry(item.name, item.project); + return new BrowseResultEntry(item.name, item.project,item.groupId,item.artifactId); } ).sort(function(a, b){return a.name.localeCompare(b.name)}): [data.browseResultEntries]; } return []; } - BrowseResultEntry=function(name,project){ + BrowseResultEntry=function(name,project,groupId,artifactId){ this.name=name; this.project=project; + this.groupId=groupId; + this.artifactId=artifactId; } BreadCrumbEntry=function(groupId,displayValue){