Package gov.nysenate.openleg.model

Examples of gov.nysenate.openleg.model.Bill


                    listBills = new ArrayList<Bill>();
                    meeting.setBills(listBills);
                }

                for(XMLBill xmlBill : xmlCommMeeting.getBills().getBill()) {
                    Bill bill = handleXMLBill(storage, meeting, xmlBill, addendum.getAgenda().getSession());
                    if (!listBills.contains(bill)) {
                        logger.debug("adding bill:" + bill.getBillId() + " to meeting:" + meeting.getOid());
                        listBills.add(bill);
                    }
                    else {
                        // Since we already have a reference don't do anything. handleXMLBill will update the bill details
                    }
View Full Code Here


        // This is a crappy situation, all bills on calendars should already exist but sometimes they won't.
        // This almost exclusively because we are missing sobi files. It shouldn't happen in production but
        // does frequently in development.
        BillProcessor processor = new BillProcessor();
        SOBIBlock mockBlock = new SOBIBlock(year+billId+(billId.matches("[A-Z]$") ? "" : " ")+1+"     ");
        Bill bill = processor.getOrCreateBill(mockBlock, modifiedDate, storage);

        if (sponsorName != null) {
            String[] sponsors = sponsorName.trim().split(",");
            bill.setSponsor(new Person(sponsors[0].trim()));

            // Other sponsors are removed when a calendar/agenda is resent without
            // The other sponsor included in the sponsors list.
            ArrayList<Person> otherSponsors = new ArrayList<Person>();
            for (int i = 1; i < sponsors.length; i++) {
                otherSponsors.add(new Person(sponsors[i].trim()));
            }

            if (!bill.getOtherSponsors().equals(otherSponsors)) {
                bill.setOtherSponsors(otherSponsors);
                new BillProcessor().saveBill(bill, storage);
            }
        }

        // It must be published if it is on the agenda
        if (!bill.isPublished()) {
            bill.setPublishDate(modifiedDate);
            bill.setActive(true);
            processor.saveBill(bill, storage);
        }

        return bill;
    }
View Full Code Here

                /*
                 * populate result objects with any relevant fields, this
                 * provides our more generic, non type-specific search
                 */
                if (type.equals("bill")) {
                    Bill bill = (Bill) resultObj;

                    if (bill.getTitle() != null)
                        title += bill.getTitle();
                    else
                        title += "(no title)";

                    if (bill.getSponsor() != null)
                        fields.put("sponsor", bill.getSponsor().getFullname());
                    else
                        fields.put("sponsor", null);

                    fields.put("othersponsors", StringUtils.join(bill.getOtherSponsors(), ", "));
                    summary = bill.getSummary();

                    fields.put("committee", bill.getCurrentCommittee());
                    fields.put("billno", bill.getBillId());
                    fields.put("summary", bill.getSummary());
                    fields.put("year", bill.getSession() + "");
                } else if (type.equals("calendar")) {
                    Calendar calendar = (Calendar) resultObj;

                    title = calendar.getNo() + "-" + calendar.getYear();

View Full Code Here

        String in = null;

        while((in = er.readLine()) != null) {
            if(!in.matches("\\s*")) {
                Bill luceneBill = SearchEngine.getInstance().getBill(getBillNumber(in, false));

                if(luceneBill == null) {
                    //TODO we don't have it
                    continue;
                }
                else {
                    if(luceneBill.getMemo() == null || luceneBill.getMemo().matches("\\s*")) {
                        ProblemBill problemBill = new ProblemBill(
                                luceneBill.getSenateBillNo(), luceneBill.getModified());
                        problemBill.addNonMatchingField(new NonMatchingField(FieldName.MEMO, null, null));
                        problemBill.setLastReported(time);

                        ret.add(problemBill);
                    }
View Full Code Here

    @Override
    public ArrayList<ProblemBill> getProblemBills(FieldName[] fieldNames) {
        ArrayList<ProblemBill> ret = new ArrayList<ProblemBill>();

        Bill lbdcBill = null;

        open();

        while((lbdcBill = nextBill()) != null) {
            Bill luceneBill = SearchEngine.getInstance().getBill(lbdcBill.getSenateBillNo() + "-" + SessionYear.getSessionYear());

            if(luceneBill == null) {
                //TODO we don't have it
                continue;
            }
            else {
                ProblemBill problemBill = new ProblemBill(luceneBill.getSenateBillNo(), luceneBill.getModified());
                problemBill.setLastReported(time);

                if(valid(lbdcBill.getSponsor(), luceneBill.getSponsor())) {
                    if(!cln(lbdcBill.getSponsor().getFullname()).equalsIgnoreCase(
                            cln(luceneBill.getSponsor().getFullname().replaceAll("\\s*\\(MS\\)", "")))) {

                        problemBill.addNonMatchingField(
                                new NonMatchingField(
                                        FieldName.SPONSOR,
                                        luceneBill.getSponsor().getFullname(),
                                        lbdcBill.getSponsor().getFullname()));
                    }
                }

                doCollectionField(problemBill, FieldName.ACTIONS, luceneBill.getActions(), lbdcBill.getActions());
                doCollectionField(problemBill, FieldName.COSPONSORS, luceneBill.getCoSponsors(), lbdcBill.getCoSponsors());
                doStringField(problemBill, FieldName.SUMMARY, luceneBill.getSummary(), lbdcBill.getSummary(), ".*?");
                doStringField(problemBill, FieldName.TITLE, luceneBill.getTitle(), lbdcBill.getTitle(), null);
                doStringField(problemBill, FieldName.LAW_SECTION, luceneBill.getLawSection(), lbdcBill.getLawSection(), null);

                if(problemBill.getNonMatchingFields() != null && problemBill.getNonMatchingFields().size() != 0)
                    ret.add(problemBill);
            }
        }
View Full Code Here

        return null;
    }

    private Bill getBillFromHtml(String text) {
        Bill bill = null;

        text = text.replaceAll("(</?(tr|td).+?>|<table.+?/table>)", "");
        Matcher m = billP.matcher((text));

        if(m.find()) {
            bill = new Bill();

            bill.setSenateBillNo(m.group(1).trim());
            bill.setTitle(m.group(3).trim());
            bill.setLawSection(m.group(4).trim());
            bill.setSummary(m.group(5).equals("BILL SUMMARY NOT FOUND") ? null : m.group(5).trim());

            String sponsorString = m.group(2).trim();

            text = text.substring(m.end());

            m.usePattern(sponsorP).reset(sponsorString);
            if(m.find()) {

                bill.setSponsor(new Person(m.group(1)));

                if(m.group(2) != null) {
                    String[] coSpons = sponsorString.trim().split(", ");

                    ArrayList<Person> cosponsors = new ArrayList<Person>();
                    for(String coSpon:coSpons) {
                        cosponsors.add(new Person(coSpon));
                    }

                    bill.setCoSponsors(cosponsors);
                }
            }

            m.usePattern(actionP).reset(text);

            ArrayList<Action> billEvents = new ArrayList<Action>();

            while(m.find()) {
                if(m.group(1) != null) {
                    continue;
                }

                try {
                    billEvents.add(new Action(bill.getSenateBillNo(), sdf.parse(m.group(2)), m.group(3)));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }

            bill.setActions(billEvents);
        }

        return bill;
    }
View Full Code Here

    }

    public Bill readBill(Reader reader) throws JsonProcessingException, IOException
    {
        JsonNode node = objectMapper.readTree(reader);
        Bill bill = new Bill(node.get("senateBillNo").asText(),node.get("year").asInt());
        bill.setActClause(node.get("actClause").asText());
        bill.setAmendments((List<String>)makeList(String.class, node.get("amendments")));
        bill.setCurrentCommittee(node.get("currentCommittee").asText());
        bill.setFulltext(node.get("fulltext").asText());
        bill.setLaw(node.get("law").asText());
        bill.setLawSection(node.get("lawSection").asText());
        bill.setMemo(node.get("memo").asText());
        bill.setPastCommittees((List<String>)makeList(String.class, node.get("pastCommittees")));
        bill.setPreviousVersions((List<String>)makeList(String.class, node.get("previousVersions")));
        bill.setSameAs(node.get("sameAs").asText());
        bill.setStricken(node.get("stricken").asBoolean());
        bill.setSummary(node.get("summary").asText());
        bill.setUniBill(node.get("uniBill").asBoolean());
        bill.setTitle(node.get("title").asText());

        bill.setActions((List<Action>)makeList(Action.class, node.get("actions")));
        for(Action action : bill.getActions()) {
            action.setBill(bill);
        }

        bill.setVotes((List<Vote>)makeList(Vote.class, node.get("votes")));
        for(Vote vote : bill.getVotes()) {
            vote.setBill(bill);
        }

        bill.setSponsor(makePerson(node.get("sponsor")));
        bill.setOtherSponsors((List<Person>)makeList(Person.class, node.get("otherSponsors")));
        bill.setCoSponsors((List<Person>)makeList(Person.class, node.get("coSponsors")));
        bill.setMultiSponsors((List<Person>)makeList(Person.class, node.get("multiSponsors")));

        bill.setActive(node.get("active").asBoolean());
        bill.setModifiedDate(makeDate(node.get("modified")));
        bill.setPublishDate(makeDate(node.get("published")));
        bill.setDataSources(new HashSet<String>((HashSet<String>)makeSet(String.class, node.get("dataSources"))));
        return bill;
    }
View Full Code Here

        request.setAttribute(type , so);

        try {
            if(type.equals("bill") && !format.matches("(csv|json|xml)")) {
                Bill bill = (Bill) so;
                request.setAttribute("related-action", bill.getActions());
                request.setAttribute("related-vote", bill.getVotes());

                String rType = "bill";
                String rQuery = QueryBuilder.build().otype(rType).and().relatedBills("oid", id).query();
                ArrayList<Bill> bills = Application.getLucene().getSenateObjects(rQuery);
                request.setAttribute("related-" + rType, bills);
View Full Code Here

        if(billNo.matches("(?i)[sajr]\\d+\\w?\\-\\d{4}")) {
            if(term.matches(".+?(\\-|[a-zA-Z])")) {
                return billNo;
            }

            Bill newestAmendment = Application.getLucene().getNewestAmendment(billNo);
            if(newestAmendment != null) {
                return newestAmendment.getBillId();
            }
        }
        return null;
    }
View Full Code Here

            return getBillFromLbdc(strings[0], strings[1]);
        }
    }

    public Bill getBillFromLbdc(String billNumber, String year) {
        Bill bill = new Bill();
        File file = new File(TEMP_FILE_NAME);
        try {
            writeDataFromLbdc(constructUrlBill(billNumber, year));

            BufferedReader br = new BufferedReader(new FileReader(file));

            //skip past http header
            while(!br.readLine().equals("Content-type: text/html"));
            br.readLine();

            String in = null;

            String status = null;
            String summary = null;
            String text = null;
            String memo = null;

            while((in = br.readLine()) != null) {
                if(in.contains("<B>STATUS:</B>")) {
                    status = "";
                }
                else if(in.contains("<B>SUMMARY:</B>")) {
                    summary = "";
                }
                else if(in.contains("<B>BILL TEXT:</B>")) {
                    text = "";
                }
                else if(in.contains("<B>SPONSORS MEMO:</B>")) {
                    memo = "";
                }

                if(memo != null) {
                    memo += in;
                }
                else if(text != null) {
                    text += in;
                }
                else if(summary != null) {
                    summary += in;
                }
                else if(status != null) {
                    status += in;
                }
            }
            br.close();

            bill.setSenateBillNo(bill + "-" + year);

            if(parseStatus(status, bill)
                    && parseSummary(summary, bill)
                    && parseText(text, bill)
                    && parseMemo(memo, bill)) {
                //success
                logger.info("Successfully retreieved bill: " + bill.getSenateBillNo());
            }
            else {
                logger.info("Failed to retreieve bill: " + billNumber + "-" + year);
                bill = null;
            }
View Full Code Here

TOP

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

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.