Package henplus.commands

Examples of henplus.commands.ListUserObjectsCommand


        try {
            final long start = System.currentTimeMillis();
            int count = 0;

            final ListUserObjectsCommand objectLister = HenPlus.getInstance().getObjectLister();
            final SortedSet<String> tablesOne = objectLister.getTableNamesForSession(first);
            final SortedSet<String> tablesTwo = objectLister.getTableNamesForSession(second);

            final Set<String> alreadyDiffed = new HashSet<String>(); // which tables got already
            // diffed?

            /*
             * which tables are found in the first session via wildcards but are
             * not contained in the second session?
             */
            final ArrayList<String> missedFromWildcards = new ArrayList<String>();

            while (st.hasMoreTokens()) {

                final String nextToken = st.nextToken();

                if ("*".equals(nextToken) || nextToken.indexOf('*') > -1) {
                    Iterator<String> iter = null;

                    if ("*".equals(nextToken)) {
                        iter = objectLister.getTableNamesIteratorForSession(first);
                    } else if (nextToken.indexOf('*') > -1) {
                        final String tablePrefix = nextToken.substring(0, nextToken.length() - 1);
                        final NameCompleter compl = new NameCompleter(tablesOne);
                        iter = compl.getAlternatives(tablePrefix);
                    }
View Full Code Here


            final HashSet<String> alreadyGiven = new HashSet<String>();
            while (st.hasMoreElements()) {
                alreadyGiven.add(st.nextToken());
            }
            final ListUserObjectsCommand objectList = HenPlus.getInstance().getObjectLister();
            final Iterator<String> iter = objectList.completeTableName(session, lastWord);
            return new Iterator<String>() {

                String table = null;

                @Override
                public boolean hasNext() {
                    while (iter.hasNext()) {
                        table = iter.next();
                        if (alreadyGiven.contains(table) && !lastWord.equals(table)) {
                            continue;
                        }
                        return true;
                    }
                    return false;
                }

                @Override
                public String next() {
                    return table;
                }

                @Override
                public void remove() {
                    throw new UnsupportedOperationException("no!");
                }
            };

        } else if (partialCommand.indexOf(OPTION_SINGLE_DB) == -1 && argIndex == 0) {
            // !singledb && process the first session
            return HenPlus.getInstance().getSessionManager().completeSessionName(lastWord);
        } else if (partialCommand.indexOf(OPTION_SINGLE_DB) == -1 && argIndex == 1) {
            // !singledb && process the second session
            final String firstSession = st.nextToken();
            return getSecondSessionCompleter(lastWord, firstSession);
        } else if (argIndex > 1) {
            // process tables
            final SessionManager sessionManager = HenPlus.getInstance().getSessionManager();
            final SQLSession first = sessionManager.getSessionByName(st.nextToken());
            final SQLSession second = sessionManager.getSessionByName(st.nextToken());

            final HashSet<String> alreadyGiven = new HashSet<String>();
            while (st.hasMoreElements()) {
                alreadyGiven.add(st.nextToken());
            }
            final ListUserObjectsCommand objectList = HenPlus.getInstance().getObjectLister();
            final Iterator<String> firstIter = objectList.completeTableName(first, lastWord);
            final Iterator<String> secondIter = objectList.completeTableName(second, lastWord);
            final Iterator<String> intersectionIter = getIntersection(firstIter, secondIter);
            return new Iterator<String>() {

                String table = null;
View Full Code Here

        _sessionManager = SessionManager.getInstance();

        // FIXME: to many cross dependencies of commands now. clean up.
        _settingStore = new SetCommand(this);
        _dispatcher = new CommandDispatcher(_settingStore);
        _objectLister = new ListUserObjectsCommand(this);
        _henplusProperties.registerProperty("echo-commands", new EchoCommandProperty(_dispatcher));

        _dispatcher.register(new HelpCommand());

        /*
 
View Full Code Here

TOP

Related Classes of henplus.commands.ListUserObjectsCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.