001package votorola.s.gwt.scene.vote; // Copyright 2011, Michael Allan.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE.
002
003import java.util.*;
004import votorola.a.*;
005import votorola.a.count.*;
006import votorola.g.*;
007import votorola.s.gwt.scene.feed.ss.*;
008
009
010/** A configurer of bites for the votespace social scene.
011  */
012public final class VotespaceBiterSS implements Biter
013{
014
015
016    /** Constructs a VotespaceBiterSS.
017      */
018    public VotespaceBiterSS( final VoteServer.Run run ) { vsPollRun = run.scopePoll(); }
019
020
021
022   // - B i t e r ------------------------------------------------------------------------
023
024
025    public void configure( final BiteJig bite )
026    {
027        final PollJig pollJig = bite.poll();
028        if( pollJig == null ) return;
029
030        final List<PersonJig> persons = bite.persons();
031        final int pN = persons.size();
032        if( pN == 0 ) return;
033
034        for( int p = 0;; )
035        {
036            final PersonJig person = persons.get( p );
037            if( person.user() != null )
038            {
039                try
040                {
041                    final CountNodeW countNode = person.countNode( pollJig.count( vsPollRun ));
042                    person.setDartSector( countNode );
043                    person.setVoteTrace( countNode );
044                }
045                catch( votorola.s.gwt.scene.feed.NoSuchItem x ) { break; } // no count mounted
046                catch( Exception x ) { throw VotorolaRuntimeException.castOrWrapped( x ); }
047            }
048
049            ++p;
050            if( p == pN ) break;
051        }
052    }
053
054
055
056//// P r i v a t e ///////////////////////////////////////////////////////////////////////
057
058
059    private final PollService.VoteServerScope.Run vsPollRun;
060
061
062}