Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove old development code from BillProcessor.

  • Loading branch information...
commit 46f0cc136f075baaf2e48bd8b2e8e73a7408ce1b 1 parent 5d273e8
@GraylinKim GraylinKim authored
Showing with 0 additions and 211 deletions.
  1. +0 −211 src/main/java/gov/nysenate/openleg/processors/BillProcessor.java
View
211 src/main/java/gov/nysenate/openleg/processors/BillProcessor.java
@@ -45,23 +45,6 @@
public static Pattern floorEventTextPattern = Pattern.compile("(REPORT CAL|THIRD READING|RULES REPORT)");
public static Pattern substituteEventTextPattern = Pattern.compile("SUBSTITUTED (FOR|BY) (.*)");
- public static void main(String[] args) {
- Matcher billEvent = billEventPattern.matcher("01/04/12 REFERRED TO LABOR");
- if (billEvent.find()) {
- System.out.println(billEvent.group(1));
- System.out.println(billEvent.group(2));
- Matcher committeeEventText = committeeEventTextPattern.matcher(billEvent.group(2));
- if (committeeEventText.find()) {
- System.out.println(committeeEventText.group(1));
- System.out.println(committeeEventText.group(2));
- } else {
- System.out.println("No match!");
- }
- } else {
- System.out.println("No Match!");
- }
- }
-
public static class ParseError extends Exception {
private static final long serialVersionUID = 276526760129242006L;
@@ -630,198 +613,4 @@ public void applySameAs(String data, Bill bill, Date date) throws ParseError {
}
}
}
-
- /*
- public void ingest(String sobiDirectory) throws Exception {
- // Loop through an ordered list of files in the sobiDirectory
- Collection<File> files = FileUtils.listFiles(new File(sobiDirectory), new String[] {"TXT"}, false);
- Collections.sort((List<File>) files);
-
- int count = 0;
- for(File sobiFile : files) {
-
- // Initialize file variables
- String oldBlock = "";
- String newBlock = "";
- StringBuffer blockData = new StringBuffer();
- String billYear = "";
- String billId = "";
- String billAmendment = "";
- String lineCode = "";
- String fileName = sobiFile.getName();
-
- Date date;
- try {
- date = BillProcessor.sobiDateFormat.parse(fileName);
- } catch (ParseException e) {
- logger.error("Unparseable date: "+fileName);
- continue;
- }
-
- // Loop through the lines in the file
- logger.info("Reading file: "+fileName);
- List<String> lines = FileUtils.readLines(sobiFile);
- lines.add(""); // Add a line to remove last line edge case
- for(int lineNum=0; lineNum<lines.size(); lineNum++) {
- String line = lines.get(lineNum);
-
- // Check to see if the current line is in the SOBI format
- Matcher sobiHeader = sobiHeaderPattern.matcher(line);
-
- // Supply a default newBlock identifier for non-matching lines
- newBlock = sobiHeader.find() ? sobiHeader.group(1) : "";
-
- // If we previously had a block and the new block is different
- // commit the old block before starting a new one.
- if (!oldBlock.equals("") && !newBlock.equals(oldBlock)) {
-
- try {
- // Get the original bill
- String oldkey;
- String amdkey;
- String key = billId+"-"+billYear;
- Bill bill = (Bill)storage.get(key, Bill.class);
-
- // If the bill wasn't found, make a new one
- if (bill == null) {
- if (billAmendment.isEmpty()) {
- bill = new Bill();
- bill.setYear(Integer.parseInt(billYear));
- bill.setSenateBillNo(billId);
- } else {
- throw new ParseError("Bill Ammendment filed without initial bill", oldBlock);
- }
- }
-
- if (!billAmendment.isEmpty()) {
- amdkey = billId+billAmendment+"-"+billYear;
- Bill amd = (Bill)storage.get(amdkey, Bill.class);
-
- if (amd == null) {
- if(blockData.toString().startsWith("DELETE")) {
- //If it is just a delete block just skip making the amendment
- //this happens quite frequently for some reason.
- throw new ParseError("New amendment with DELETE command only. Skipping", oldBlock+blockData);
- }
-
- // get the previous version and copy it by reading from file
- if(bill.ammendments.isEmpty()) {
- oldkey = billId+"-"+billYear;
- } else {
- oldkey = bill.ammendments.get(bill.ammendments.size()-1);
- }
-
- // now add ourselves to the bill amendments and commit before flushing
- bill.ammendments.add(amdkey);
- storage.set(key, bill);
- storage.flush();
-
- // now that we're synced with the file system, load from file
- amd = (Bill)storage.get(oldkey , Bill.class, false);
- if (amd==null) {
- throw new ParseError("Recorded amendment not found on filesystem", oldkey);
- }
-
- amd.setSenateBillNo(key.split("-")[0]);
- }
-
- bill = amd;
- key = amdkey;
-
- } else if(!bill.ammendments.isEmpty()) {
- amdkey = bill.ammendments.get(bill.ammendments.size()-1);
- Bill amd = (Bill)storage.get(amdkey, Bill.class);
- if (amd==null) {
- throw new ParseError("Recorded amendment not found on filesystem",amdkey);
- }
-
- amd.setSenateBillNo(key.split("-")[0]);
- bill = amd;
- key = amdkey;
- }
-
- // commit block
- switch (lineCode.charAt(0)) {
- case '1': applyBillData(blockData.toString(), bill, date); break;
- case '2': applyLawSection(blockData.toString(), bill, date); break;
- case '3': applyTitle(blockData.toString(), bill, date); break;
- case '4': applyBillEvent(blockData.toString(), bill, date); break;
- case '5': applySameAs(blockData.toString(), bill, date); break;
- case '6': applySponsor(blockData.toString(), bill, date); break;
- case '7': applyCosponsors(blockData.toString(), bill, date); break;
- case '8': applyMultisponsors(blockData.toString(), bill, date); break;
- case '9': applyProgramInfo(blockData.toString(), bill, date); break;
- case 'A': applyActClause(blockData.toString(), bill, date); break;
- case 'B': applyLaw(blockData.toString(), bill, date); break;
- case 'C': applySummary(blockData.toString(), bill, date); break;
- case 'M':
- case 'R':
- case 'T': applyText(blockData.toString(), bill, date); break;
- case 'V': applyVoteMemo(blockData.toString(), bill, date); break;
- default: throw new ParseError("Invalid Line Code", lineCode);
- }
-
- bill.setModified(date.getTime());
-
- storage.set(key, bill);
-
- } catch (ParseError e) {
- logger.error("ParseError at "+fileName+":"+lineNum, e);
- }
-
- // cleanup
- blockData = new StringBuffer();
- }
-
- // Move our identifier forward
- oldBlock = newBlock;
-
- // Skip lines that did not match the SOBI format
- if (newBlock.equals("")) continue;
-
-
- if (blockData.length()==0) {
- // If we're starting from a blank slate, initialize block values
- billYear = sobiHeader.group(2);
- billId = sobiHeader.group(3).replaceAll("([ASJK])0*", "$1");
- billAmendment = sobiHeader.group(4).trim();
- lineCode = sobiHeader.group(5);
- blockData.append(sobiHeader.group(6));
-
- } else {
- // Otherwise, build the data string, carry the new lines
- blockData.append("\r\n"+sobiHeader.group(6));
- }
-
- // Special case for the type 1 deletes!
- if (lineCode.equals("1") && sobiHeader.group(6).startsWith("DELETE")) {
- String key = billId+billAmendment+"-"+String.valueOf(billYear);
- storage.del(key);
-
- if (!billAmendment.isEmpty()) {
- // We need to remove all references to this amendment
- String oldKey = billId+"-"+billYear;
- Bill oldBill = (Bill)storage.get(oldKey, Bill.class);
- oldBill.ammendments.remove(key);
- storage.set(oldKey, oldBill);
- for (String ammendment : oldBill.ammendments) {
- Bill bill = (Bill)storage.get(ammendment, Bill.class);
- bill.ammendments.remove(key);
- storage.set(ammendment, bill);
- }
- }
-
- blockData = new StringBuffer();
- oldBlock = "";
- }
- }
-
- if ((++count % 2500) == 0) {
- storage.flush();
- storage.clearCache();
- }
- }
- storage.flush();
- }
- */
}
Please sign in to comment.
Something went wrong with that request. Please try again.