Package gov.nysenate.openleg.model

Examples of gov.nysenate.openleg.model.Supplemental


        ChangeLogger.setContext(file, modifiedDate);
        for(Object obj:senateData.getSencalendarOrSencalendaractive()) {

            Calendar calendar = null;
            String action = null;
            Supplemental supplemental = null;

            if (obj instanceof XMLSencalendar) {
                XMLSencalendar xmlCalendar = (XMLSencalendar)obj;

                action = xmlCalendar.getAction();

                calendar = getCalendar(storage, "floor",xmlCalendar.getNo(),xmlCalendar.getYear(),xmlCalendar.getSessyr());
                supplemental = parseSupplemental(storage, calendar,xmlCalendar.getSupplemental());

                if(supplemental.getSequences() != null
                        || (supplemental.getSections() != null && !supplemental.getSections().isEmpty())) {
                    supplemental.setCalendar(calendar);

                    calendar.addSupplemental(supplemental);
                }
            }
            else if (obj instanceof XMLSencalendaractive) {
                XMLSencalendaractive xmlActiveList = (XMLSencalendaractive)obj;

                action = xmlActiveList.getAction();

                calendar = getCalendar(storage, "active",xmlActiveList.getNo(),xmlActiveList.getYear(),xmlActiveList.getSessyr());

                supplemental = parseSupplemental(storage, calendar,xmlActiveList.getSupplemental());

                if(supplemental.getSequences() != null
                        || (supplemental.getSections() != null && !supplemental.getSections().isEmpty())) {
                    supplemental.setCalendar(calendar);

                    calendar.addSupplemental(supplemental);
                }
            } else {
                logger.warn("Unknown calendar type found: "+obj);
                continue;
            }

            if (action.equals("remove") && removeObject != null) {

                logger.info("REMOVING: " + removeObject.getClass() + "=" + removeObjectId);

                if(removeObject instanceof Supplemental) {
                    if(calendar.getSupplementals() != null) {
                        int indexOf = -1;
                        if((indexOf = calendar.getSupplementals().indexOf(removeObject)) != -1) {
                            calendar.getSupplementals().remove(indexOf);
                        }
                    }
                }
                else if (removeObject instanceof Sequence && calendar.getSupplementals() != null){
                    int supSize = calendar.getSupplementals().size();

                    for(int i = 0; i < supSize; i++) {
                        Supplemental sup = calendar.getSupplementals().get(i);

                        int indexOf = -1;
                        if((indexOf = sup.getSequences().indexOf(removeObject)) != -1) {
                            calendar.getSupplementals().get(i).getSequences().remove(indexOf);
                            break;
                        }
                    }
                } else {
View Full Code Here


    public Supplemental parseSupplemental (Storage storage, Calendar calendar, XMLSupplemental xmlSupp) {
        String suppId = calendar.getOid() + "-supp-" + xmlSupp.getId();

        // Create a new supplemental or get the existing one from the calendar
        Supplemental supplemental = new Supplemental();
        supplemental.setId(suppId);
        int index = -1;
        if(calendar != null && calendar.getSupplementals() != null &&
                (index = calendar.getSupplementals().indexOf(supplemental)) != -1) {
            supplemental = calendar.getSupplementals().get(index);
        } else {
            supplemental.setSupplementalId(xmlSupp.getId());
        }

        // Set parent reference
        supplemental.setCalendar(calendar);

        // Set this as the current object in case of removal
        setRemoveObject(supplemental, supplemental.getId());

        // Set the supplemental calendar date from the parent calendar
        if (xmlSupp.getCaldate()!=null)  {
            try {
                Date calDate = OpenLegConstants.LRS_DATE_ONLY_FORMAT.parse(xmlSupp.getCaldate().getContent());
                supplemental.setCalendarDate(calDate);
            }
            catch (ParseException e) {
                logger.error("Unable to parse calDate for supplement=" + xmlSupp.getId(),e);
            }
        }

        // Set the supplemental release date-time
        if (xmlSupp.getReleasedate()!=null && xmlSupp.getReleasetime()!=null) {
            try {
                String dateString = xmlSupp.getReleasedate().getContent() + xmlSupp.getReleasetime().getContent();
                Date releaseDateTime = OpenLegConstants.LRS_DATETIME_FORMAT.parse(dateString);
                supplemental.setReleaseDateTime(releaseDateTime);

            } catch (ParseException e) {
                logger.error("Unable to parse relDate for supplement=" + xmlSupp.getId(),e);
            }
        }

        if (xmlSupp.getSections()!=null) {
            Section section = null;

            // Get the existing set of sections if available.
            if (supplemental.getSections() == null)
                supplemental.setSections(new ArrayList<Section>());
            List<Section> sections = supplemental.getSections();

            // Parse the various sections from the supplied XML
            // TODO: Since whole sections might be sent each time, are whole supplementals resent also?
            for(XMLSection xmlSection:xmlSupp.getSections().getSection()) {
                section = parseSection(storage, supplemental, xmlSection);

                // Only add new sections
                if(!sections.contains(section))
                    sections.add(section);
            }
            supplemental.setSections(sections);
        }

        // Handle sequences when available
        XMLSequence xmlSequence = xmlSupp.getSequence();
        if (xmlSequence != null) {
            Sequence sequence = parseSequence(storage, supplemental, xmlSequence);
            supplemental.addSequence(sequence);

            // TODO: new removal objects? how/why?
            setRemoveObject(sequence, sequence.getId());
        }
View Full Code Here

                    else if (calendar.getType().equals("floor"))
                        fields.put("type", "Floor Calendar");
                    else
                        fields.put("type", calendar.getType());

                    Supplemental supp = calendar.getSupplementals().get(0);

                    if (supp.getCalendarDate() != null) {
                        fields.put("date", DATE_FORMAT_CUSTOM.format(supp.getCalendarDate()));

                        summary = "";

                        if (supp.getSections() != null) {
                            Iterator<Section> itSections = supp.getSections()
                                    .iterator();
                            while (itSections.hasNext()) {
                                Section section = itSections.next();

                                summary += section.getName() + ": ";
                                summary += section.getCalendarEntries().size() + " items;";
                            }
                        }
                    } else if (supp.getSequences() != null && supp.getSequences().size() > 0) {

                        fields.put("date", DATE_FORMAT_CUSTOM.format(supp.getSequences().get(0).getActCalDate()));

                        int total = 0;
                        for(Sequence seq:supp.getSequences()) {
                            total += seq.getCalendarEntries().size();
                        }
                        summary = total + " item(s)";

                    }
View Full Code Here

    {
        if (node.isNull()) {
            return null;
        }
        else {
            Supplemental supplemental = new Supplemental();
            supplemental.setId(node.get("id").asText());
            supplemental.setSupplementalId(node.get("supplementalId").asText());
            supplemental.setCalendarDate(makeDate(node.get("calendarDate")));
            supplemental.setReleaseDateTime(makeDate(node.get("releaseDateTime")));

            supplemental.setSections((List<Section>)makeList(Section.class, node.get("sections")));
            for(Section section : supplemental.getSections()) {
                section.setSupplemental(supplemental);
            }

            supplemental.setSequences((List<Sequence>)makeList(Sequence.class, node.get("sequences")));
            for(Sequence sequence : supplemental.getSequences()) {
                sequence.setSupplemental(supplemental);
            }

            return supplemental;
        }
View Full Code Here

TOP

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

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.