Package gov.nysenate.openleg.model

Examples of gov.nysenate.openleg.model.Calendar


        }

        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 {
                    logger.warn("Unknown calendar subdocument found: "+obj);
                }
            }

            calendar.addDataSource(file.getName());
            calendar.setModifiedDate(modifiedDate);
            if (calendar.getPublishDate() == null) {
                calendar.setPublishDate(modifiedDate);
            }
            storage.set(calendar);
            ChangeLogger.record(storage.key(calendar), storage);
            removeObject = null;
        }
View Full Code Here


            removeObject = null;
        }
    }

    public Calendar getCalendar (Storage storage, String type, String no, String year, String sessYr) {
        Calendar calendar = null;

        StringBuffer calendarId = new StringBuffer();
        calendarId.append("cal-");
        calendarId.append(type);
        calendarId.append('-');
        calendarId.append(no);
        calendarId.append('-');
        calendarId.append(year);

        logger.info("getting calendar: " + calendarId.toString());

        String key = year+"/calendar/"+calendarId;
        calendar = (Calendar)storage.get(key, Calendar.class);

        if (calendar == null) {
            calendar = new Calendar(
                Integer.parseInt(no),
                Integer.parseInt(sessYr),
                Integer.parseInt(year),
                type
            );
View Full Code Here

            String otype = key.split("/")[1];
            String oid = key.split("/")[2];

            if (!otype.equals("agenda")) {
                if (otype.equals("calendar")) {
                    Calendar calendar = (Calendar)storage.get(key, Calendar.class);
                    oid = calendar.getOid();
                }
                else if (otype.equals("meeting")) {
                    Meeting meeting = (Meeting)storage.get(key, Meeting.class);
                    oid = meeting.getOid();
                }
View Full Code Here

                    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();

                    if (calendar.getType() == null)
                        fields.put("type", "");
                    else if (calendar.getType().equals("active"))
                        fields.put("type", "Active List");
                    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 = "";
View Full Code Here

    }

    public Calendar readCalendar(Reader reader) throws JsonProcessingException, IOException
    {
        JsonNode node = objectMapper.readTree(reader);
        Calendar calendar = new Calendar(
            node.get("no").asInt(),
            node.get("session").asInt(),
            node.get("year").asInt(),
            node.get("type").asText()
        );
        calendar.setSupplementals((List<Supplemental>)makeList(Supplemental.class, node.get("supplementals")));
        for(Supplemental supplemental : calendar.getSupplementals()) {
            supplemental.setCalendar(calendar);
        }

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

TOP

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

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.