From 68389bb59974797d813f8342b44691622855d55b Mon Sep 17 00:00:00 2001 From: "gyeongseok.seo" Date: Tue, 21 May 2013 19:25:46 +0900 Subject: [PATCH] [Title] Fixed tempalte create and search logic [Desc.] search result sorting print [Issue] Change-Id: I6bed3dc991fa08097707647dba23b25bd510c6fd --- .../src/org/tizen/cli/command/CreateTemplate.java | 4 +- .../src/org/tizen/cli/command/SearchTemplate.java | 52 +++++++++++++++++----- .../src/org/tizen/cli/exec/AbstractLauncher.java | 1 + 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/org.tizen.cli/src/org/tizen/cli/command/CreateTemplate.java b/org.tizen.cli/src/org/tizen/cli/command/CreateTemplate.java index 43887e4..cefa283 100644 --- a/org.tizen.cli/src/org/tizen/cli/command/CreateTemplate.java +++ b/org.tizen.cli/src/org/tizen/cli/command/CreateTemplate.java @@ -34,7 +34,7 @@ import org.tizen.common.verrari.Storage; import org.tizen.common.verrari.Template; import org.tizen.common.verrari.TemplateContext; import org.tizen.common.verrari.TemplateException; -import org.tizen.common.verrari.realm.StandardRealm; +import org.tizen.common.verrari.realm.CommonRealm; import org.tizen.common.verrari.storage.FileStorage; import org.tizen.common.verrari.template.TemplateConstants; @@ -111,7 +111,7 @@ implements CommandWithParameter } cache.put( name, template ); template.template( models, storage ); - final String[] dependencies = StandardRealm.separate( template.getAttribute( TemplateConstants.ATTR_DEPENDENCY ) ); + final String[] dependencies = CommonRealm.separate( template.getAttribute( TemplateConstants.ATTR_DEPENDENCY ) ); if ( null == dependencies ) { continue; diff --git a/org.tizen.cli/src/org/tizen/cli/command/SearchTemplate.java b/org.tizen.cli/src/org/tizen/cli/command/SearchTemplate.java index a29564a..97749e5 100644 --- a/org.tizen.cli/src/org/tizen/cli/command/SearchTemplate.java +++ b/org.tizen.cli/src/org/tizen/cli/command/SearchTemplate.java @@ -29,6 +29,8 @@ import static org.tizen.common.util.StringUtil.isEmpty; import java.io.IOException; import java.util.Collection; +import java.util.Iterator; +import java.util.TreeSet; import org.tizen.common.core.command.ExecutionContext; import org.tizen.common.verrari.AttributeContainer; @@ -43,19 +45,13 @@ extends AbstractCommand implements CommandWithParameter { - @Override - public void process( + protected void + search( + final Realm realm, final ExecutionContext context, final String[] args ) throws IOException { - if ( null == args || 0 == args.length ) - { - context.getPrompter().error( "A keyword required." ); - return ; - } - final Realm realm = (Realm) context.getValue( PluginConstants.REALM ); - if ( !( realm instanceof SearchableRealm ) ) { context.getPrompter().error( "Search unsupported realm." ); @@ -73,12 +69,23 @@ implements CommandWithParameter context.getPrompter().notify( "No template with '" + keyword + "'." ); return ; } + + TreeSet sortTree = new TreeSet(); for ( final AttributeContainer template : templates ) { final StringBuilder buffer = new StringBuilder(); final String name = template.getAttribute( TemplateConstants.ATTR_NAME ); final String desc = template.getAttribute( TemplateConstants.ATTR_DESCRIPTION ); + final String version = template.getAttribute( TemplateConstants.ATTR_VERSION ); + buffer.append( name ); + if ( !isEmpty( version ) ) + { + buffer.append( " ( " ); + buffer.append( version ); + buffer.append( " ) " ); + } + buffer.append( " - " ); if ( isEmpty( desc ) ) { @@ -88,9 +95,32 @@ implements CommandWithParameter { buffer.append( desc ); } - - context.getPrompter().notify( buffer.toString() + "." ); + + sortTree.add( buffer.toString() ); + } + + // search result notify + Iterator iter = sortTree.iterator(); + while ( iter.hasNext() ) { + context.getPrompter().notify( iter.next() + "." ); } } + /* (non-Javadoc) + * @see org.tizen.cli.command.CommandWithParameter#process(org.tizen.common.core.command.ExecutionContext, java.lang.String[]) + */ + @Override + public void process( + final ExecutionContext context, + final String[] args + ) throws IOException + { + if ( null == args || 0 == args.length ) + { + context.getPrompter().error( "A keyword required." ); + return ; + } + final Realm realm = (Realm) context.getValue( PluginConstants.REALM ); + search( realm, context, args ); + } } diff --git a/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java b/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java index 720fd0c..6e091a8 100644 --- a/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java @@ -477,6 +477,7 @@ AbstractLauncher { getPrompter().error( e.getMessage() ); logger.error( "Command stop because of exception", e ); + Throwable iter = e; while ( null != iter ) { -- 2.7.4