Package gov.nysenate.openleg.model

Examples of gov.nysenate.openleg.model.Transcript


                        }
                        summary = total + " item(s)";

                    }
                } else if (type.equals("transcript")) {
                    Transcript transcript = (Transcript) resultObj;

                    if (transcript.getTimeStamp() != null)
                        title = new SimpleDateFormat("MMM d, yyyy h:mm aa").format(transcript.getTimeStamp());
                    else
                        title = "Transcript - " + transcript.getLocation();

                    summary = TextFormatter.append(transcript.getType(), ": ", transcript.getLocation());

                    fields.put("location", transcript.getLocation());

                } else if (type.equals("meeting")) {
                    Meeting meeting = (Meeting) resultObj;
                    title = TextFormatter.append(meeting.getCommitteeName(), " (",
                            new SimpleDateFormat("MMM d, yyyy - h:mm a").format(meeting.getMeetingDateTime()), ")");
View Full Code Here


    public TranscriptProcessor() {
        this.logger = Logger.getLogger(this.getClass());
    }

    public void process(File file, Storage storage) throws IOException {
        Transcript transcript = new Transcript();
        StringBuffer fullText = new StringBuffer();
        StringBuffer fullTextProcessed = new StringBuffer();

        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "latin1"));
        String lineText;
        TranscriptLine line;
        String date = null;
        String time = null;
        boolean firstPageParsed = false;
        boolean firstLineParsed = false;
        boolean skipFirstThreeLines = false;
        int numSkipped = 0;

        while ((lineText = reader.readLine()) != null) {
            line = new TranscriptLine(lineText);

            if (!firstPageParsed) {

                // Handle transcripts with 3 incorrect lines at start of transcript.
                if (!firstLineParsed) {
                    if (lineText.contains("SESSION")) {
                        skipFirstThreeLines = true;
                        numSkipped = 1;
                        continue;
                    }
                }
                if (skipFirstThreeLines == true && numSkipped <= 3) {
                    numSkipped++;
                    continue;
                }

                if (line.isLocation())
                    transcript.setLocation(line.removeLineNumber().trim());

                if (line.isDate())
                    date = line.getDateString();

                if (line.isTime())
                    time = line.getTimeString();

                if (line.isSession())
                    transcript.setType(line.removeLineNumber().trim());

                if (transcript.getLocation() != null && date != null && time != null && transcript.getType() != null)
                    firstPageParsed = true;
            }

            firstLineParsed = true;

            fullText.append(line.fullText()).append("\n");

            if (line.removeLineNumber().trim().length() > 0) {
                fullTextProcessed.append(line.removeLineNumber().trim()).append("\n");
            }
        }

        reader.close();

        try {
            transcript.setTimeStamp(TRANSCRIPT_DATE_PARSER.parse(date+" "+time));
        } catch (ParseException e) {
            logger.error(file.getName()+": unable to parse transcript datetime " + date+" "+time, e);
        }

        transcript.setTranscriptText(fullText.toString());
        transcript.setTranscriptTextProcessed(fullTextProcessed.toString());
        String oid = transcript.getType().replaceAll(" ""-")+"-"+new SimpleDateFormat("MM-dd-yyyy_HH:mm").format(transcript.getTimeStamp());
        transcript.setId(oid);
        transcript.setModifiedDate(transcript.getTimeStamp());
        transcript.setPublishDate(transcript.getTimeStamp());
        transcript.addDataSource(file.getName());

        // Save the transcript
        String key = transcript.getYear()+"/transcript/"+transcript.getId();
        storage.set(transcript);

        // Make an entry in the change log
        ChangeLogger.setContext(file, transcript.getTimeStamp());
        ChangeLogger.record(key, storage);
    }
View Full Code Here

    }

    public Transcript readTranscript(Reader reader) throws JsonProcessingException, IOException
    {
        JsonNode node = objectMapper.readTree(reader);
        Transcript transcript = new Transcript();
        transcript.setId(node.get("id").asText());
        transcript.setTimeStamp(makeDate(node.get("timeStamp")));
        transcript.setLocation(node.get("location").asText());
        transcript.setType(node.get("type").asText());
        transcript.setTranscriptText(node.get("transcriptText").asText());
        transcript.setTranscriptTextProcessed(node.get("transcriptTextProcessed").asText());
        transcript.setRelatedBills((List<Bill>)makeList(Bill.class, node.get("relatedBills")));

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

                resultNode.setAttribute("committee", meeting.getCommitteeName());
                resultNode.setAttribute("location", meeting.getLocation());
                resultNode.setAttribute("chair", meeting.getCommitteeChair());
            }
            else if (result.getOtype().equals("transcript")) {
                Transcript transcript = (Transcript)result.getObject();
                resultNode.setAttribute("location", transcript.getLocation());
            }
            else if (result.getOtype().equals("calendar")) {
                // no additional fields.
            }
            root.addContent(resultNode);
View Full Code Here

TOP

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

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.