Package org.apache.directory.studio.ldapbrowser.core.model

Examples of org.apache.directory.studio.ldapbrowser.core.model.ISearch


    {
        Object objectToSelect = null;

        if ( obj instanceof ISearch )
        {
            ISearch search = ( ISearch ) obj;

            universalListener.setInput( search.getBrowserConnection() );

            mainWidget.getViewer().expandToLevel( search, 0 );

            objectToSelect = search;
        }
        if ( obj instanceof ISearchResult )
        {
            ISearchResult searchResult = ( ISearchResult ) obj;
            ISearch search = searchResult.getSearch();

            universalListener.setInput( search.getBrowserConnection() );

            mainWidget.getViewer().expandToLevel( search, 1 );

            objectToSelect = searchResult;
        }
View Full Code Here


                        select( entry );
                    }
                    else if ( obj instanceof ISearchResult )
                    {
                        ISearchResult sr = ( ISearchResult ) obj;
                        ISearch search = sr.getSearch();
                        // The search may be a clone, lookup original search from search manager.
                        // The result may be null, in that case the selection won't change.
                        search = search.getBrowserConnection().getSearchManager().getSearch( search.getName() );
                        select( search );
                    }
                    return true;
                }
            };
View Full Code Here

                    }
                }
                else if ( input != null && input instanceof SearchResultEditorInput )
                {
                    SearchResultEditorInput srei = ( SearchResultEditorInput ) input;
                    ISearch search = srei.getSearch();
                    if ( search != null )
                    {
                        objectToSelect = search.getBrowserConnection().getConnection();
                    }
                }
            }

            if ( objectToSelect != null )
View Full Code Here

     *
     * This viewer selects the updated search.
     */
    public void searchUpdated( SearchUpdateEvent searchUpdateEvent )
    {
        ISearch search = searchUpdateEvent.getSearch();
        viewer.setSelection( StructuredSelection.EMPTY );
        viewer.refresh();

        if ( search instanceof IContinuation )
        {
            viewer.setSelection( new StructuredSelection( search ), true );
        }
        else if ( search.getBrowserConnection().getSearchManager().getSearches().contains( search ) )
        {
            viewer.setSelection( new StructuredSelection( search ), true );
        }
        else if ( search.getBrowserConnection().getSearchManager().getQuickSearch() == search )
        {
            viewer.setSelection( new StructuredSelection( search ), true );
        }
        else
        {
View Full Code Here

        // clear old children
        clearCaches( parent, purgeAllCaches );

        // create search
        ISearch search = createSearch( parent, pagedSearchControl, false, false, false );

        // search
        executeSearch( parent, search, monitor );
        ISearchResult[] srs = search.getSearchResults();
        SearchContinuation[] scs = search.getSearchContinuations();

        // fill children in search result
        if ( ( srs != null && srs.length > 0 ) || ( scs != null && scs.length > 0 ) )
        {
            // clearing old children before filling new children is
            // necessary to handle aliases and referrals.
            clearCaches( parent, false );

            do
            {
                if ( srs != null )
                {
                    for ( ISearchResult searchResult : srs )
                    {
                        parent.addChild( searchResult.getEntry() );
                    }
                    srs = null;
                }

                if ( scs != null )
                {
                    for ( SearchContinuation searchContinuation : scs )
                    {
                        ContinuedSearchResultEntry entry = new ContinuedSearchResultEntry( parent
                            .getBrowserConnection(), searchContinuation.getUrl().getDn() );
                        entry.setUnresolved( searchContinuation.getUrl() );
                        parent.addChild( entry );
                    }
                    scs = null;
                }

                StudioPagedResultsControl sprRequestControl = null;
                StudioPagedResultsControl sprResponseControl = null;
                for ( StudioControl responseControl : search.getResponseControls() )
                {
                    if ( responseControl instanceof StudioPagedResultsControl )
                    {
                        sprResponseControl = ( StudioPagedResultsControl ) responseControl;
                    }
                }
                for ( StudioControl requestControl : search.getControls() )
                {
                    if ( requestControl instanceof StudioPagedResultsControl )
                    {
                        sprRequestControl = ( StudioPagedResultsControl ) requestControl;
                    }
                }

                if ( sprRequestControl != null && sprResponseControl != null )
                {
                    if ( sprRequestControl.isScrollMode() )
                    {
                        if ( sprRequestControl.getCookie() != null )
                        {
                            // create top page search runnable, same as original search
                            InitializeChildrenRunnable topPageChildrenRunnable = new InitializeChildrenRunnable(
                                parent, null );
                            parent.setTopPageChildrenRunnable( topPageChildrenRunnable );
                        }

                        if ( sprResponseControl.getCookie() != null )
                        {
                            StudioPagedResultsControl newSprc = new StudioPagedResultsControl( sprRequestControl
                                .getSize(), sprResponseControl.getCookie(), sprRequestControl.isCritical(),
                                sprRequestControl.isScrollMode() );
                            InitializeChildrenRunnable nextPageChildrenRunnable = new InitializeChildrenRunnable(
                                parent, newSprc );
                            parent.setNextPageChildrenRunnable( nextPageChildrenRunnable );
                        }
                    }
                    else
                    {
                        // transparently continue search, till count limit is reached
                        if ( sprResponseControl.getCookie() != null
                            && ( search.getCountLimit() == 0 || search.getSearchResults().length < search
                                .getCountLimit() ) )
                        {

                            search.setSearchResults( new ISearchResult[0] );
                            search.getResponseControls().clear();
                            sprRequestControl.setCookie( sprResponseControl.getCookie() );

                            executeSearch( parent, search, monitor );
                            srs = search.getSearchResults();
                            scs = search.getSearchContinuations();
                        }
                    }
                }
            }
            while ( srs != null && srs.length > 0 );
        }
        else
        {
            parent.setHasChildrenHint( false );
        }

        // get sub-entries
        ISearch subSearch = createSearch( parent, null, true, false, false );
        if ( parent.getBrowserConnection().isFetchSubentries() || parent.isFetchSubentries() )
        {
            executeSubSearch( parent, subSearch, monitor );
        }

        // get aliases and referrals
        ISearch aliasOrReferralSearch = createSearch( parent, null, false, parent.isFetchAliases(), parent
            .isFetchReferrals() );
        if ( parent.isFetchAliases() || parent.isFetchReferrals() )
        {
            executeSubSearch( parent, aliasOrReferralSearch, monitor );
        }

        // check exceeded limits / canceled
        parent.setHasMoreChildren( search.isCountLimitExceeded() || subSearch.isCountLimitExceeded()
            || aliasOrReferralSearch.isCountLimitExceeded() || monitor.isCanceled() );

        // set initialized state
        parent.setChildrenInitialized( true );
    }
View Full Code Here

        // referral handling
        ReferralHandlingMethod referralsHandlingMethod = parent.getBrowserConnection().getReferralsHandlingMethod();

        // create search
        ISearch search = new Search( null, parent.getBrowserConnection(), parent.getDn(), filter,
            ISearch.NO_ATTRIBUTES, scope, parent.getBrowserConnection().getCountLimit(), parent.getBrowserConnection()
                .getTimeLimit(), aliasesDereferencingMethod, referralsHandlingMethod, BrowserCorePlugin.getDefault()
                .getPluginPreferences().getBoolean( BrowserCoreConstants.PREFERENCE_CHECK_FOR_CHILDREN ), null );

        // controls
        if ( parent.isReferral() || isReferralsSearch || parent.getBrowserConnection().isManageDsaIT() )
        {
            search.getSearchParameter().getControls().add( StudioControl.MANAGEDSAIT_CONTROL );
        }
        if ( isSubentriesSearch )
        {
            search.getSearchParameter().getControls().add( StudioControl.SUBENTRIES_CONTROL );
        }
        if ( pagedSearchControl != null )
        {
            search.getSearchParameter().getControls().add( pagedSearchControl );
        }

        return search;
    }
View Full Code Here

                    }
                }
            }

            // create search
            ISearch search = new Search( null, entry.getBrowserConnection(), entry.getDn(),
                entry.isSubentry() ? ISearch.FILTER_SUBENTRY : ISearch.FILTER_TRUE, attributes, SearchScope.OBJECT, 0,
                0, aliasesDereferencingMethod, referralsHandlingMethod, false, null );

            // add controls
            if ( entry.isReferral() )
            {
                search.getControls().add( StudioControl.MANAGEDSAIT_CONTROL );
            }

            // search
            SearchRunnable.searchAndUpdateModel( entry.getBrowserConnection(), search, monitor );
View Full Code Here

     *
     * This implementation refreshes the tree and selects the search.
     */
    public void searchUpdated( SearchUpdateEvent searchUpdateEvent )
    {
        ISearch search = searchUpdateEvent.getSearch();
        viewer.refresh();

        if ( search.getBrowserConnection().getSearchManager().getQuickSearch() == search )
        {
            viewer.setSelection( new StructuredSelection( search ), true );
            viewer.expandToLevel( search, 1 );
        }
    }
View Full Code Here

            StudioRunnableWithProgress runnable = ( StudioRunnableWithProgress ) o1;
            for ( Object lockedObject : runnable.getLockedObjects() )
            {
                if ( lockedObject instanceof ISearch )
                {
                    ISearch search = ( ISearch ) lockedObject;
                    if ( o1 == search.getTopSearchRunnable() )
                    {
                        return lessThan();
                    }
                    else if ( o1 == search.getNextSearchRunnable() )
                    {
                        return greaterThan();
                    }
                }
                else if ( lockedObject instanceof IEntry )
                {
                    IEntry entry = ( IEntry ) lockedObject;
                    if ( o1 == entry.getTopPageChildrenRunnable() )
                    {
                        return lessThan();
                    }
                    else if ( o1 == entry.getNextPageChildrenRunnable() )
                    {
                        return greaterThan();
                    }
                }
            }
            return lessThan();
        }
        if ( o2 instanceof StudioRunnableWithProgress )
        {
            StudioRunnableWithProgress runnable = ( StudioRunnableWithProgress ) o2;
            for ( Object lockedObject : runnable.getLockedObjects() )
            {
                if ( lockedObject instanceof ISearch )
                {
                    ISearch search = ( ISearch ) lockedObject;
                    if ( o2 == search.getTopSearchRunnable() )
                    {
                        return greaterThan();
                    }
                    else if ( o2 == search.getNextSearchRunnable() )
                    {
                        return lessThan();
                    }
                }
                else if ( lockedObject instanceof IEntry )
View Full Code Here

        monitor.beginTask( " ", searches.length + 1 ); //$NON-NLS-1$
        monitor.reportProgress( " " ); //$NON-NLS-1$

        for ( int pi = 0; pi < searches.length; pi++ )
        {
            ISearch search = searches[pi];
            ISearch searchToPerform = searchesToPerform[pi];
           
            monitor.setTaskName( BrowserCoreMessages.bind( BrowserCoreMessages.jobs__search_task, new String[]
                { search.getName() } ) );
            monitor.worked( 1 );

            if ( search.getBrowserConnection() != null )
            {
                // reset search results
                search.setSearchResults( new ISearchResult[0] );
                search.getResponseControls().clear();
                search.setNextPageSearchRunnable( null );
                search.setTopPageSearchRunnable( null );
                searchToPerform.setSearchResults( new ISearchResult[0] );
                searchToPerform.setNextPageSearchRunnable( null );
                searchToPerform.setTopPageSearchRunnable( null );
                searchToPerform.getResponseControls().clear();

                do
                {
                    // perform search
                    searchAndUpdateModel( searchToPerform.getBrowserConnection(), searchToPerform, monitor );

                    if ( search != searchToPerform )
                    {
                        // merge search results
                        ISearchResult[] sr1 = search.getSearchResults();
                        ISearchResult[] sr2 = searchToPerform.getSearchResults();
                        ISearchResult[] sr = new ISearchResult[sr1.length + sr2.length];
                        System.arraycopy( sr1, 0, sr, 0, sr1.length );
                        System.arraycopy( sr2, 0, sr, sr1.length, sr2.length );
                        search.setSearchResults( sr );
                    }
                    else
                    {
                        // set search results
                        search.setSearchResults( searchToPerform.getSearchResults() );
                    }

                    // check response controls
                    ISearch clonedSearch = ( ISearch ) searchToPerform.clone();
                    clonedSearch.getResponseControls().clear();
                    StudioPagedResultsControl sprResponseControl = null;
                    StudioPagedResultsControl sprRequestControl = null;
                    for ( StudioControl responseControl : searchToPerform.getResponseControls() )
                    {
                        if ( responseControl instanceof StudioPagedResultsControl )
                        {
                            sprResponseControl = ( StudioPagedResultsControl ) responseControl;
                        }
                    }
                    for ( Iterator<StudioControl> it = clonedSearch.getControls().iterator(); it.hasNext(); )
                    {
                        StudioControl requestControl = it.next();
                        if ( requestControl instanceof StudioPagedResultsControl )
                        {
                            sprRequestControl = ( StudioPagedResultsControl ) requestControl;
                            it.remove();
                        }
                    }
                    searchToPerform = null;

                    // paged search
                    if ( sprResponseControl != null && sprRequestControl != null )
                    {
                        StudioPagedResultsControl nextSpsc = new StudioPagedResultsControl(
                            sprRequestControl.getSize(), sprResponseControl.getCookie(),
                            sprRequestControl.isCritical(), sprRequestControl.isScrollMode() );
                        ISearch nextPageSearch = ( ISearch ) clonedSearch.clone();
                        nextPageSearch.getResponseControls().clear();
                        nextPageSearch.getControls().add( nextSpsc );
                        if ( sprRequestControl.isScrollMode() )
                        {
                            if ( sprRequestControl.getCookie() != null )
                            {
                                // create top page search runnable, same as original search
                                ISearch topPageSearch = ( ISearch ) search.clone();
                                topPageSearch.getResponseControls().clear();
                                SearchRunnable topPageSearchRunnable = new SearchRunnable( search, topPageSearch );
                                search.setTopPageSearchRunnable( topPageSearchRunnable );
                            }
                            if ( sprResponseControl.getCookie() != null )
                            {
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.ldapbrowser.core.model.ISearch

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.