//determine frequency of particular Dewey Decimal ranges void calculateDeweys(int month) { // } float average(ArrayList trans) { return 0; } public ArrayList loadTransactions(String nameOfDataFileWithinDataDirectory) { ArrayList transactions = new ArrayList(); String[] lines = loadStrings(nameOfDataFileWithinDataDirectory); int j=0; for (int i = 0; i < lines.length; i++) { DetailedTransaction tmp = new DetailedTransaction(); tmp = parseTransaction(lines[i]); if(tmp != null){ transactions.add(tmp); if( Arrays.binarySearch(formats,tmp.format)<0){ formats[j] = tmp.format; j++; formats = sort(formats); } } } formatsPresent = --j; println(formatsPresent+1 + " Item Formats"); return transactions; } // This function returns all the files in a directory as an array of File objects // This is useful if you want more info about the file public File[] listFiles(String dir) { File file = new File(dir); if (file.isDirectory()) { File[] files = file.listFiles(); return files; } else { // If it's not a directory return null; } } //create a new tran //create a new transaction obejct from a comma separated line. //create a new transaction obejct from a comma separated line. public DetailedTransaction parseTransaction(String line) { String sections[] = split(line, ","); ItemListing info = null; DetailedTransaction t = new DetailedTransaction(); //store all fields // t.itemNumber = sections[0]; // t.bibNumber = sections[1]; t.ckodate = sections[0]; t.ckotime = sections[1]; t.ckidate = sections[2]; t.ckitime = sections[3]; // t.collcode = sections[6]; t.label = sections[4]; // t.barcode = sections[8]; // t.title = sections[9]; // t.callNumber = sections[10]; // t.deweyClass = sections[5]; // add to the hashmap of itemtypes //if... check if this entry belongs in graph if (itemTypes.containsKey(t.label)){ info = (ItemListing) itemTypes.get(t.label); t.type = info.type; t.format = info.format; t.category = info.category; } else println("error with itemtype: " + t.label ); String[] dateO = split(t.ckodate, '-'); //year-month-day String[] timeO = split(t.ckotime, ':'); //hours-mins-seconds String[] dateI = split(t.ckidate, '-'); //year-month-day String[] timeI = split(t.ckitime, ':'); //hours-mins-seconds t.checkOutTimeH = Integer.parseInt(timeO[0]); t.checkOutTimeM = Integer.parseInt(timeO[1]); //assuming all seconds are0 t.checkOutDay = Integer.parseInt(dateO[2]); t.checkOutMonth = Integer.parseInt(dateO[1]); t.checkOutYear = Integer.parseInt(dateO[0]); t.checkOutTime = t.checkOutTimeH + t.checkOutTimeM/60; Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("y-M-d"); try { Date date = sdf.parse(t.ckodate); cal.setTime(date); t.dayOfWeekOut = cal.get(Calendar.DAY_OF_WEEK); if (t.dayOfWeekOut == 1) //we want to shift to represent a business week t.dayOfWeekOut = 7; else t.dayOfWeekOut--; } catch (Exception e) { //do anything you want to handle the exception println("Unable to parse date stamp"); t.dayOfWeekOut = -1; } t.checkInTimeH = Integer.parseInt(timeI[0]); t.checkInTimeM = Integer.parseInt(timeI[1]); //assuming all seconds are0 t.checkInDay = Integer.parseInt(dateI[2]); t.checkInMonth = Integer.parseInt(dateI[1]); t.checkInYear = Integer.parseInt(dateI[0]); t.checkInTime = t.checkInTimeH + t.checkInTimeM/60; try { Date datei = sdf.parse(t.ckidate); cal.setTime(datei); t.dayOfWeekIn = cal.get(Calendar.DAY_OF_WEEK); if (t.dayOfWeekIn == 1) //we want to shift to represent a business week t.dayOfWeekIn = 7; else t.dayOfWeekIn--; } catch (Exception e) { //do anything you want to handle the exception println("Unable to parse date stamp"); t.dayOfWeekIn = -1; } // println("out:\t" + "\t" + checkOutYear + "\t" + checkOutMonth + "\t" + checkOutDay + "\t" + checkOutTime); // println("in:\t" + "\t" + checkInYear + "\t" + checkInMonth + "\t" + checkInDay + "\t" + checkInTime); long dur_ms; SimpleDateFormat sdf_l = new SimpleDateFormat("y-M-d-H-m"); try { Date dateOut = sdf_l.parse(t.ckodate + "-" + t.checkOutTimeH + "-" + t.checkOutTimeM ); Date dateIn = sdf_l.parse(t.ckidate + "-" + t.checkInTimeH + "-" + t.checkInTimeM ); dur_ms = dateIn.getTime() - dateOut.getTime(); } catch (Exception e) { //do anything you want to handle the exce ption println("Unable to parse date stamp2"); dur_ms = 1; } t.durDays = ((float)dur_ms/ (1000*60*60*24)); if(t.durDays > 700) return null; else return t; } HashMap getItemTable(String fileName) { println("Collecting Item Table"); HashMap internalItemTable = new HashMap(); String[] itemEntry = new String[4]; String[] tmpEntry; String[] collLoc = { "85", "197" , "328", "503" }; String[] lines = loadStrings(fileName); for (int i = 0; i < lines.length; i++) { String[] item_labels = null; for (int j = 0; j<=3; j++) { item_labels = match(lines[i], ";left:" + collLoc[j] + "\">[A-Za-z\\-/ ]*"); if(item_labels != null){ tmpEntry = splitTokens(item_labels[0], ">"); itemEntry[j] = tmpEntry[1]; if (j !=3) i++; } else{ itemEntry[j] = null; if(j == 3 && itemEntry[j-1] != null) i--; } } if (itemEntry[0] != null){ ItemListing I = new ItemListing(itemEntry[0], itemEntry[1], itemEntry[2], itemEntry[3]); // println(itemEntry[0] + "\t\t" + itemEntry[1] + "\t\t" + itemEntry[2] + "\t\t" + itemEntry[3]); internalItemTable.put(itemEntry[0], I); } } println("entries found: "+ internalItemTable.size()); return internalItemTable; } int[] getColor(String label){ int[] rgb; rgb = new int[]{ 0,0,0 }; if (label.endsWith("cas")) // audio tape rgb = new int[]{ 255,0,77 }; else if (label.endsWith("bk")) // book rgb = new int[]{ 255, 0, 204 }; else if (label.endsWith("cd")) rgb = new int[]{ 204 , 255 ,0 }; else if (label.endsWith("cdrom")) rgb = new int[]{ 0, 204, 255 }; else if (label.endsWith("disk")) rgb = new int[]{ 0, 76, 255 }; else if (label.endsWith("dvd")) rgb = new int[]{ 255 ,110,0 }; else if (label.endsWith("fold")) rgb = new int[]{ 220, 254,0 }; else if (label.endsWith("art")) rgb = new int[]{ 0,21,254 }; else if (label.endsWith("illb")) rgb = new int[]{ 97,0,254 }; else if (label.endsWith("illl")) rgb = new int[]{ 254,30,0 }; else if (label.endsWith("kit")) rgb = new int[]{ 255,255,51 }; else if (label.endsWith("per")) rgb = new int[]{ 153,255,51 }; else if (label.endsWith("map")) rgb = new int[]{ 51,255,102 }; else if (label.endsWith("mfc")) rgb = new int[]{ 51,255,255 }; else if (label.endsWith("mfm")) rgb = new int[]{ 102,51,255 }; else if (label.endsWith("mus")) rgb = new int[]{ 255,51,119 }; else if (label.endsWith("np")) rgb = new int[]{ 163,206,235 }; else if (label.endsWith("ord")) rgb = new int[]{ 253,190,166 }; else if (label.endsWith("pam")) rgb = new int[]{ 246,22,22 }; else if (label.endsWith("photo")) rgb = new int[]{ 231,71,191 }; else if (label.endsWith("post")) rgb = new int[]{ 153,255,51 }; else if (label.endsWith("rec")) rgb = new int[]{ 255,255,51 }; else if (label.endsWith("slide")) rgb = new int[]{ 6,139,227 }; else if (label.endsWith("vhs")) rgb = new int[]{ 117,246,127 }; else if (label.endsWith("med")) rgb = new int[]{ 204,34,31 }; else if (label.endsWith("vid")) rgb = new int[]{ 204,66,242 }; else if (label.endsWith("web")) rgb = new int[]{ }; else rgb = new int[]{ 255,255,255 }; return rgb; }