Package gov.nysenate.openleg.model

Examples of gov.nysenate.openleg.model.Addendum


        List<Addendum> listAddendums = agendaVote.getAddendums();
        for(Object next : xmlAgendaVote.getContent()) {

            if (next instanceof XMLAddendum) {
                XMLAddendum xmlAddendum = (XMLAddendum) next;
                Addendum addendum = parseAddendum(storage, xmlAddendum, agendaVote, true);
                addendum.setAgenda(agendaVote);

                // Don't repeat yourself
                if (!listAddendums.contains(addendum)) {
                    listAddendums.add(addendum);
                }
View Full Code Here


        // Build a list of addendums on the current list.
        // TOOD: is this resent whole each time or not?
        List<Addendum> listAddendums = agenda.getAddendums();
        for(XMLAddendum xmlAddendum : xmlAgenda.getAddendum()) {
            Addendum addendum = parseAddendum(storage, xmlAddendum, agenda, false);
            addendum.setAgenda(agenda);

            // Don't add duplicates!
            // TODO: What about addendums that are updated? Can that happen?
            if (!listAddendums.contains(addendum)) {
                listAddendums.add(addendum);
View Full Code Here

                logger.error("unable to parse addendum date/time format", pe);
            }
        }

        // Try to retrieve existing addendum and update it
        Addendum addendum = new Addendum(addendumId, weekOf, publishDate, agenda.getNumber(), agenda.getYear());
        addendum.setAgenda(agenda);
        for (Addendum oldAddendum : agenda.getAddendums()) {
            if (oldAddendum.getOid().equals(addendum.getOid())) {
                addendum = oldAddendum;
                addendum.setAgenda(agenda); // Nulled out during serialization.
                addendum.setWeekOf(weekOf);
                addendum.setPublishDate(publishDate);
                break;
            }
        }

        List<Meeting> listMeetings = addendum.getMeetings();
        for( XMLCommittee xmlCommMeeting : xmlAddendum.getCommittees().getCommittee()) {
            String action = xmlCommMeeting.getAction();
            String commName = xmlCommMeeting.getName().getContent();
            if (commName == null) {
                continue;
            }

            if (action != null && action.equals("remove")) {
                for (Meeting meeting : new ArrayList<Meeting>(listMeetings)) {
                    if (meeting.getCommitteeName().equals(commName)) {
                        logger.info("removing meeting: " + meeting.getOid());
                        // Delete the meeting and save the agenda
                        String key = storage.key(meeting);
                        storage.del(key);
                        ChangeLogger.delete(key, storage);
                        listMeetings.remove(meeting);
                        storage.set(agenda);
                        ChangeLogger.record(storage.key(agenda), storage);
                        break;
                    }
                }
                continue;
            }

            // If action isn't remove, we should have a date time.
            Date meetDateTime = null;
            try {
                meetDateTime = LRS_DATETIME_FORMAT.parse(xmlCommMeeting.getMeetdate().getContent() + xmlCommMeeting.getMeettime().getContent());
            } catch (ParseException e) {
                logger.error("Could not parse meeting date", e);
                continue;
            }

            Meeting meeting = new Meeting(commName, meetDateTime);
            meeting.setPublishDate(modifiedDate);
            String key = storage.key(meeting);
            Meeting oldMeeting = (Meeting)storage.get(key, Meeting.class);

            if (oldMeeting != null) {
                // If we have an old meeting, either use it or delete it if we are replacing.
                // This is wrong just like the rest of the meeting stuff. The replace is for
                // the addendum entry, you don't know how much to replace.
                if (action != null && action.equals("replace")) {
                    // If we are replacing votes it'll be handled in handleXmlBill
                    if (!isVote) {
                        logger.info("removing meeting: " + oldMeeting.getOid());
                        storage.del(key);
                        agenda.removeCommitteeMeeting(oldMeeting);
                    }
                }
                else {
                    // Use the old meeting of since it is not null or replaced.
                    meeting = oldMeeting;
                }
            }

            meeting.setModifiedDate(modifiedDate);

            // Add a bunch of meeting meta data
            if (xmlCommMeeting.getLocation() != null && xmlCommMeeting.getLocation().getContent().length() > 0) {
                meeting.setLocation(xmlCommMeeting.getLocation().getContent());
            }

            if (xmlCommMeeting.getMeetday() != null && xmlCommMeeting.getMeetday().getContent().length() > 0) {
                meeting.setMeetday(xmlCommMeeting.getMeetday().getContent());
            }

            if (xmlCommMeeting.getNotes() != null && xmlCommMeeting.getNotes().getContent().length() > 0) {
                // latin1 encoded
                String notes = xmlCommMeeting.getNotes().getContent();
                notes = new String(notes.getBytes("CP850"), "latin1");
                meeting.setNotes(notes);
            }

            if (xmlCommMeeting.getChair() != null && xmlCommMeeting.getChair().getContent().length() > 0) {
                meeting.setCommitteeChair(xmlCommMeeting.getChair().getContent());
            }

            if (!listMeetings.contains(meeting)) {
                listMeetings.add(meeting);
            }

            if (xmlCommMeeting.getBills() != null) {
                List<Bill> listBills = meeting.getBills();

                if (listBills == null) {
                    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
                    }
                }
            }
            storage.set(meeting);
            ChangeLogger.record(storage.key(meeting), storage);
        }
        addendum.setMeetings(listMeetings);
        return addendum;
    }
View Full Code Here

    {
        if (node.isNull()) {
            return null;
        }
        else {
            Addendum addendum = new Addendum(
                node.get("addendumId").asText(),
                node.get("weekOf").asText(),
                makeDate(node.get("published")),
                node.get("agendaNo").asInt(),
                node.get("year").asInt()
            );
            addendum.setMeetings((List<Meeting>)makeList(Meeting.class, node.get("meetings")));
            addendum.setActive(node.get("active").asBoolean());
            addendum.setModifiedDate(makeDate(node.get("modified")));
            addendum.setPublishDate(makeDate(node.get("published")));
            addendum.setDataSources(new HashSet<String>((List<String>)makeList(String.class, node.get("dataSources"))));
            return addendum;
        }
    }
View Full Code Here

TOP

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

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.