From: gyeongseok.seo Date: Tue, 21 May 2013 10:25:46 +0000 (+0900) Subject: [Title] Fixed tempalte create and search logic X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=88478083b9095862dd3767705f35c931f026c215;p=sdk%2Ftools%2Fcli.git [Title] Fixed tempalte create and search logic [Desc.] search result sorting print [Issue] Change-Id: I6bed3dc991fa08097707647dba23b25bd510c6fd --- 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 100755 --- 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 100755 --- 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 505b37e..32b4d5f 100755 --- a/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java +++ b/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java @@ -470,6 +470,7 @@ AbstractLauncher { getPrompter().error( e.getMessage() ); logger.error( "Command stop because of exception", e ); + Throwable iter = e; while ( null != iter ) {