Package gov.nysenate.openleg.model

Examples of gov.nysenate.openleg.model.Vote


    public void applyVoteMemo(String data, Bill bill, Date date) throws ParseError
    {
        // TODO: Parse out sequence number once LBDC (maybe) includes it, #6531
        // Because sometimes votes are back to back we need to check for headers
        // Example of a double vote entry: SOBI.D110119.T140802.TXT:390
        Vote vote = null;
        for(String line : data.split("\n")) {
            Matcher voteHeader = voteHeaderPattern.matcher(line);
            if (voteHeader.find()) {
                // TODO: this assumes they are the same vote sent twice, what else could happen?
                //Start over if we hit a header, sometimes we get back to back entries.
                try {
                    // Use the old vote if we can find it, otherwise make a new one using now as the publish date
                    vote = new Vote(bill, voteDateFormat.parse(voteHeader.group(2)), Vote.VOTE_TYPE_FLOOR, "1");
                    vote.setPublishDate(date);
                    for (Vote oldVote : bill.getVotes()) {
                        if (oldVote.equals(vote)) {
                            // If we've received this vote before, use the old publish date
                            vote.setPublishDate(oldVote.getPublishDate());
                            break;
                        }
                    }
                    vote.setModifiedDate(date);
                } catch (ParseException e) {
                    throw new ParseError("voteDateFormat not matched: "+line);
                }

            }
            else if (vote!=null){
                //Otherwise, build the existing vote
                Matcher voteLine = votePattern.matcher(line);
                while(voteLine.find()) {
                    String type = voteLine.group(1).trim();
                    Person voter = new Person(voteLine.group(2).trim());

                    if (type.equals("Aye")) {
                        vote.addAye(voter);
                    }
                    else if (type.equals("Nay")) {
                        vote.addNay(voter);
                    }
                    else if (type.equals("Abs")) {
                        vote.addAbsent(voter);
                    }
                    else if (type.equals("Abd")) {
                        vote.addAbstain(voter);
                    }
                    else if (type.equals("Exc")) {
                        vote.addExcused(voter);
                    }
                    else {
                        throw new ParseError("Unknown vote type found: "+line);
                    }
                }
View Full Code Here


            bill.setActClause(xmlBill.getTitle().getContent());
        }

        if (xmlBill.getVotes() != null) {
            Date voteDate = meeting.getMeetingDateTime();
            Vote vote = new Vote(bill, voteDate, Vote.VOTE_TYPE_COMMITTEE, "1");
            vote.setPublishDate(modifiedDate);
            vote.setModifiedDate(modifiedDate);

            // remove the old vote
            // TODO: will this ever actually work with aye/nay counts at -1?
            //    I suppose is will now that I'm using sequence numbers instead
            bill.removeVote(vote);

            vote.setVoteType(Vote.VOTE_TYPE_COMMITTEE);
            vote.setDescription(meeting.getCommitteeName());
            for( XMLMember member : xmlBill.getVotes().getMember()) {
                Person person = new Person(member.getName().getContent());
                String voteType = member.getVote().getContent().toLowerCase();

                if (voteType.startsWith("abstain"))
                    vote.addAbstain(person);
                else if (voteType.startsWith("aye w/r"))
                    vote.addAyeWR(person);
                else if (voteType.startsWith("aye"))
                    vote.addAye(person);
                else if (voteType.startsWith("excused"))
                    vote.addExcused(person);
                else if (voteType.startsWith("nay"))
                    vote.addNay(person);
                else if (voteType.startsWith("absent"))
                    vote.addAbsent(person);
            }

            // Add the new vote, effectively replacing an older copy
            bill.updateVote(vote);
View Full Code Here

                    fields.put("date", DATE_FORMAT_MED.format(billEvent
                            .getDate()));
                    fields.put("billno", billId);
                } else if (type.equals("vote")) {
                    Vote vote = (Vote) resultObj;

                    if (vote.getVoteType() == Vote.VOTE_TYPE_COMMITTEE)
                        fields.put("type", "Committee Vote");
                    else if (vote.getVoteType() == Vote.VOTE_TYPE_FLOOR)
                        fields.put("type", "Floor Vote");

                    HashMap<String, String> resultFields = result.getFields();
                    fields.put("sponsor", resultFields.get("sponsor"));
                    fields.put("billno", resultFields.get("billno"));
                    fields.put("othersponsors", resultFields.get("othersponsors"));

                    if (vote.getVoteType() == Vote.VOTE_TYPE_COMMITTEE)
                        fields.put("committee", vote.getDescription());

                    title +=  DATE_FORMAT_CUSTOM.format(vote.getVoteDate());
                }

                result.setTitle(title);
                result.setSummary(summary);
                result.setFields(fields);
View Full Code Here

    {
        if (node.isNull()) {
            return null;
        }
        else {
            Vote vote = new Vote(
                node.get("billId").asText(),
                makeDate(node.get("date")),
                node.get("voteType").asInt(),
                node.get("sequenceNumber").asText()
            );
            vote.setAbsent((List<String>)makeList(String.class, node.get("absent")));
            vote.setAyes((List<String>)makeList(String.class, node.get("ayes")));
            vote.setAyeswr((List<String>)makeList(String.class, node.get("ayeswr")));
            vote.setNays((List<String>)makeList(String.class, node.get("nays")));
            vote.setExcused((List<String>)makeList(String.class, node.get("excused")));
            vote.setAbstains((List<String>)makeList(String.class, node.get("abstains")));
            vote.setDescription(node.get("description").asText());
            vote.setActive(node.get("active").asBoolean());
            vote.setModifiedDate(makeDate(node.get("modified")));
            vote.setPublishDate(makeDate(node.get("published")));
            vote.setDataSources(new HashSet<String>((List<String>)makeList(String.class, node.get("dataSources"))));
            return vote;
        }
    }
View Full Code Here

            if (result.getOtype().equals("action")) {
                Action action = (Action)result.getObject();
                resultNode.setAttribute("billno", action.getBill().getBillId());
            }
            else if (result.getOtype().equals("vote")) {
                Vote vote = (Vote)result.getObject();
                resultNode.setAttribute("billno", vote.getBill().getBillId());
                resultNode.setAttribute("sponsor", vote.getBill().getSponsor().getFullname());
            }
            else if (result.getOtype().equals("bill")) {
                root.setName("docket");
                resultNode.setName("bill");
                Bill bill = (Bill)result.getObject();
View Full Code Here

                "Kruger", "Lanza", "Larkin", "LaValle", "Libous", "Little", "Marcellino", "Martins", "Maziarz", "McDonald",
                "Montgomery", "Nozzolio", "O'Mara", "Oppenheimer", "Parker", "Peralta", "Perkins", "Ranzenhofer", "Ritchie",
                "Rivera", "Robach", "Saland", "Sampson", "Savino", "Serrano", "Seward", "Skelos", "Smith", "Squadron", "Stavisky",
                "Stewart-Cousin", "Valesky", "Young", "Zeldin"};
        String[] senateAbsVotes2011 = { "Espaillat", "Huntley" };
        Vote expected = new Vote();
        expected.setAyes(Arrays.asList(senateAyeVotes2011));
        expected.setAbsent(Arrays.asList(senateAbsVotes2011));
        VoteTests.testSenateVotes(env, sobiDirectory, storage, billKey, senateVoteSobi2011, expected);
    }
View Full Code Here

                "Klein", "Krueger", "Lanza", "Larkin", "LaValle", "Libous", "Little", "Marcellino", "Martins", "Maziarz", "McDonald",
                "Montgomery", "Nozzolio", "O'Mara", "Oppenheimer", "Parker", "Peralta", "Perkins", "Ranzenhofer", "Ritchie", "Rivera",
                "Robach", "Saland", "Sampson", "Savino", "Serrano", "Seward", "Skelos", "Smith", "Squadron", "Stavisky", "Stewart-Cousin",
                "Valesky", "Young", "Zeldin"};
        String[] senateExcusedVotes2012 = {"Huntley"};
        Vote expected = new Vote();
        expected.setAyes(Arrays.asList(senateAyeVotes2012));
        expected.setExcused(Arrays.asList(senateExcusedVotes2012));
        VoteTests.testSenateVotes(env, sobiDirectory, storage, billKey, senateVoteSobi2012, expected);
    }
View Full Code Here

    public void testCommitteeVote2011()
    {
        String meetingKey2011 = "2011/meeting/meeting-Codes-7-2011-2011";
        String[] committeeAyeVotes2011 = {"Saland", "DeFrancisco", "Flanagan", "Fuschillo", "Gallivan", "Golden", "Lanza",
                "Nozzolio", "O'Mara", "Gianaris", "Duane", "Huntley", "Parker", "Perkins", "Squadron", "Espaillat"};
        Vote expected = new Vote();
        expected.setAyes(Arrays.asList(committeeAyeVotes2011));
        VoteTests.testCommitteeVotes(env, sobiDirectory, storage, meetingKey2011, billName, committeeVoteSobi2011, expected);
    }
View Full Code Here

    {
        String meetingKey2012 = "2012/meeting/meeting-Codes-2-2011-2012";
        String[] committeeAyeVotes2012 = {"Saland", "DeFrancisco", "Flanagan", "Fuschillo", "Gallivan", "Golden", "Lanza",
                "Nozzolio", "O'Mara", "Gianaris", "Huntley", "Parker", "Perkins", "Squadron", "Espaillat"};
        String[] committeeAyeWRVotes2012 = {"Duane"};
        Vote expected = new Vote();
        expected.setAyes(Arrays.asList(committeeAyeVotes2012));
        expected.setAyeswr(Arrays.asList(committeeAyeWRVotes2012));
        VoteTests.testCommitteeVotes(env, sobiDirectory, storage, meetingKey2012, billName, committeeVoteSobi2012, expected);
    }
View Full Code Here

      Storage storage, String billKey, String voteSobi, String expectedVoteDate)
  {
    File[] voteSobiFile = TestHelper.getFilesByName(sobiDirectory, voteSobi);
    TestHelper.processFile(env, voteSobiFile);
    Bill bill = TestHelper.getBill(storage, billKey);
    Vote vote = bill.getVotes().get(0);
    Date voteDate = vote.getVoteDate();
    DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
    // Format the Date into a string and test.
    assertThat(dateFormat.format(voteDate), is(expectedVoteDate));
  }
View Full Code Here

TOP

Related Classes of gov.nysenate.openleg.model.Vote

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.