diff --git a/YahooStockData/Apps-Trading/gap_analysis.py b/YahooStockData/Apps-Trading/gap_analysis.py deleted file mode 100644 index 3607019..0000000 --- a/YahooStockData/Apps-Trading/gap_analysis.py +++ /dev/null @@ -1,32 +0,0 @@ - - -from StockAnalysis.historical_bars import TickerData -from StockAnalysis.historical_bars import BarData - -data = TickerData('FB', 'D', 'NASDAQ') -gap_ups = [] - - -def identify_gap_ups(percentage): - i = 0 - for current_bar in data.candlesticks: - # b.print_bar_data() - if i > 1: - last_bar = data.candlesticks[i-1] - try: - if current_bar.open > last_bar.close: - diff = float(current_bar.open) - float(last_bar.close) - calc_percent = diff / float(last_bar.close) - if calc_percent > .03: - print(current_bar.open + ' ' + last_bar.close + ' Date: '+current_bar.bar_datetime - + ' {0:.4f}'.format(calc_percent)) - gap_ups.append(current_bar) - - i += 1 - - -if __name__ == '__main__': - identify_gap_ups(4) - - # for bar_data in gap_ups: - # print(bar_data.bar_datetime) \ No newline at end of file diff --git a/YahooStockData/Apps-Trading/ts_check_view.py b/YahooStockData/Apps-Trading/ts_check_view.py deleted file mode 100644 index 9736c74..0000000 --- a/YahooStockData/Apps-Trading/ts_check_view.py +++ /dev/null @@ -1,41 +0,0 @@ - - -import tkinter as tk -from TradeStation.ts_check_controller import * - -text = '' - - - -window = tk.Tk() -window.title('TradeStation ETB') - -ticker_text = tk.StringVar() -response_text = tk.StringVar() - -tk.Label(window, text='TradeStation ETB').grid(row=0, column=0, sticky='w') - -ticker = tk.Entry(window, textvariable=ticker_text) - - -ticker.grid(row=0, column=1, sticky='w') -# tk.Button(window, text='Check', command=lambda: check_ticker(ticker_text.get())).grid(row=0, column=11, sticky='e') -check_button = tk.Button(window, text='Check') -check_button.grid(row=0, column=4, sticky='w') - -response = tk.Label(window, textvariable=response_text) -response.grid(row=2, columnspan=50) - -def button_clicked(ticker): - global text - text = check_ticker(ticker) - response_text.set(text) - -check_button.bind('', lambda event: button_clicked(ticker_text.get())) -ticker.bind('', lambda event: button_clicked(ticker_text.get())) - - - -window.mainloop() - - diff --git a/YahooStockData/StockAnalysis/historical_bars.py b/YahooStockData/StockAnalysis/historical_bars.py deleted file mode 100644 index da37608..0000000 --- a/YahooStockData/StockAnalysis/historical_bars.py +++ /dev/null @@ -1,42 +0,0 @@ -__author__ = 'byron' - -import datetime - -class TickerData(): - def __init__(self, ticker, time_frame, exchange): - self.ticker = ticker - self.time_frame = time_frame - self.exchange = exchange - self.candlesticks = [] - self.file_contents = self.get_ticker_data() - - - def get_ticker_data(self): - __folder = '/home/byron/Stock-Data/{0}'.format(self.exchange) - __file_name = '{0}/{1}-{2}.data'.format(__folder, self.ticker, self.time_frame) - - with open(__file_name, mode='r') as data_file: - for line in data_file: - # print(line) - self.candlesticks.append(BarData(line.split(','))) - # b = BarData(line.split(',')) - # - # BarData(line.split(',')).print_bar_data() - return data_file.read() - -class BarData(): - def __init__(self, ohlc): - self.bar_datetime = ohlc[0] - self.open = ohlc[1] - self.high = ohlc[2] - self.low = ohlc[3] - self.close = ohlc[4] - self.volume = ohlc[5] - self.candlestick = [self.bar_datetime, self.open, self.high, self.low, self.close, self.volume] - - def print_bar_data(self): - print('Time: {0} | Open: {1} | High: {2} | Low: {3} | Close: {4} | Volume: {5}'.format( - self.bar_datetime, self.open, self.close, self.high, self.low, self.close, self.volume)) - - def __iter__(self): - return iter(self.candlestick) diff --git a/YahooStockData/TradeStation/ts_check_controller.py b/YahooStockData/TradeStation/ts_check_controller.py deleted file mode 100644 index 1532d1c..0000000 --- a/YahooStockData/TradeStation/ts_check_controller.py +++ /dev/null @@ -1,47 +0,0 @@ - - -from TradeStation.ts_requirements import * - -tmp = '' - - -def check_ticker(ticker): - prepare_files() - ts_easy = get_easy_borrow() - ts_margin = get_margin_requirements() - ts_threshold = get_threshold_securities() - global tmp - status_string = '' - tmp = '' - ticker = ticker.upper_case_letters_change_to() - - if ticker in ts_easy: - tmp = '\n{0} is EASY to Borrow'.format(ticker) - print(tmp) - status_string += tmp - tmp = '' - elif ticker in ts_threshold: - tmp = '\n' + ticker + ' **THRESHOLD SECURITY** Cannot Be Shorted' - status_string += tmp - print(tmp) - tmp = '' - else: - tmp = '\n*** SORRY {0} NOT EASY to Borrow please call \nthe trade desk' \ - ' at 1-800-871-3563 to locate the security ***'.format(ticker) - print(tmp) - status_string += tmp - tmp = '' - - if ticker.upper() in ts_margin: - tmp = '\n'+ticker + ' has margin requirements: ' + ts_margin[ticker] - print(tmp) - status_string += tmp - tmp = '' - - return status_string - - -if __name__ == '__main__': -# check_ticker('VLTC') # test ticker - - diff --git a/YahooStockData/TradeStation/ts_requirements.py b/YahooStockData/TradeStation/ts_requirements.py deleted file mode 100644 index 566cacf..0000000 --- a/YahooStockData/TradeStation/ts_requirements.py +++ /dev/null @@ -1,88 +0,0 @@ - - -from os import walk -import os - -file_path = '~/Downloads/' -easy = 'easy.txt' -threshold = 'threshold.txt' -margin = 'margin.txt' - - -def prepare_files(): - f = [] - - global file_path, threshold, margin, easy - for (dirpath, dirnames, filenames) in walk(file_path): - f.extend(filenames) - break - - for file in f: - if file.startswith('TSEasy'): - os.rename(file_path + file, file_path + easy) - print('easy there') - - if file.startswith('TSSpecial'): - os.rename(file_path + file, file_path + margin) - print('margin there') - - if file.startswith('TSThreshold'): - os.rename(file_path + file, file_path + threshold) - print('threshold there') - - -def get_easy_borrow(): - global file_path, easy - easy_list = set() - - with open(file_path + easy, mode='r') as file_list: - for line in file_list: - - if line.startswith(';'): - continue - else: - easy_list.add(line.strip()) - # print(line.strip()) - - -def get_margin_requirements(): - global file_path, margin - margin_list = {} - ticker = '' - percentage = '' - - with open(file_path + margin, mode='r') as file_list: - for line in file_list: - - if line.startswith(';'): - continue - else: - temp = line.strip().split('|') - - if len(temp) > 1: - # print(temp[0] + ' ---- ' + temp[1]) - margin_list[temp[0]] = temp[1] - - -def get_threshold_securities(): - global file_path, threshold - threshold_list = set() - - with open(file_path + threshold, mode='r') as file_list: - for line in file_list: - - if line.startswith(';'): - continue - else: - threshold_list.add(line.strip()) - # print(line.strip()) - - return threshold_list - - - -if __name__ == '__main__': - prepare_files() - get_easy_borrow() - get_margin_requirements() - get_threshold_securities() diff --git a/YahooStockData/get_data.py b/YahooStockData/get_data.py deleted file mode 100644 index a8304ad..0000000 --- a/YahooStockData/get_data.py +++ /dev/null @@ -1,35 +0,0 @@ - - -import urllib2 -# from Tkinter import * -from key_statistics import YahooKeyStatistics - - -ticker = "AAPL" -parser = YahooKeyStatistics() -yahoo = urllib2.urlopen('http://finance.yahoo.com/q/ks?s='+ticker+'+Key+Statistics') -data = parser.feed(yahoo.read().decode('utf-8')) -parser.print_key_size() -key_stats = parser.build_stat_data() - - - - -# if __name__ == '__main__': -# -# # app = QApplication(sys.argv) -# # ex = Example() - # sys.exit(app.exec_()) - -# root = Tk() -# root.title("Stock Info") -# label = Label(root, text='Shares Short: ') -# label2 = Label(root, text=key_stats['Shares Short']) -# label.pack(side='left') -# label2.pack(side='right') -# print('*' + str(key_stats.keys()) + '*') -# counter_label(label) -# button = Button(root, text='Stop', width=25, command=root.destroy) -# button.pack() -# -# root.mainloop() \ No newline at end of file diff --git a/YahooStockData/key_statistics.py b/YahooStockData/key_statistics.py deleted file mode 100644 index ca81ef3..0000000 --- a/YahooStockData/key_statistics.py +++ /dev/null @@ -1,73 +0,0 @@ - - -from HTMLParser import HTMLParser -unwanted_headers = ['Financial Highlights', 'Fiscal Year', 'Profitability', - 'Management Effectiveness', 'Income Statement', 'Balance Sheet', - 'Cash Flow Statement', 'Stock Price History', - 'Share Statistics', 'Trading Information', - 'See '] - - -class YahooKeyStatistics(HTMLParser): - - def __init__(self): - HTMLParser.__init__(self) - self.reached_valuation_measures = False - self.valid_data_field = False - self.stat_data = {} - self.keys = [] - self.values = [] - self.data_count = 1 - - def handle_starttag(self, tag, attrs): - if tag = 'td' and self.reached_valuation_measures is True: - # print("Start tag:", tag) - tag = '' - self.valid_data_field = True - for attr in attrs: - if attr = "('class', 'yfnc_tablehead1')": - print(" attr:", attr) - elif attr == "('class', 'yfnc_tabledata1')": - print(" attr:", attr) - - def handle_data(self, data): - - if data == "Valuation Measures": - print("Valuation Measures Reached") - self.reached_valuation_measures = True - elif data == 'Dividends ': - print('Done with Statistics Data') - self.data_count = 3 - self.reached_valuation_measures = False - - if self.reached_valuation_measures is True and self.valid_data_field is True: - if '(' in data: - i = 0 - for char in data: - i += 1 - if char == '(': - data = data[0:i-2] - break - if data not in unwanted_headers and self.data_count < 2: - self.data_count = 2 - self.keys.append(data) - # print("Data :" + data + '*') - elif data not in unwanted_headers and self.data_count is 2: - self.data_count = 1 - self.values.append(data) - # print("Data :" + data + '^') - - self.valid_data_field = False - - def print_key_size(self): - print ('# Keys: '+str(len(self.keys)) + - ' #values'+str(len(self.values))) - - def build_stat_data(self): - i = 0 - for field in self.keys: - print(field+': '+self.values[i]) - self.stat_data.update({field: self.values[i]}) - i += 1 - - return self.stat_data diff --git a/YahooStockData/stock_data_window.py b/YahooStockData/stock_data_window.py deleted file mode 100644 index df6c515..0000000 --- a/YahooStockData/stock_data_window.py +++ /dev/null @@ -1,20 +0,0 @@ - - -from PyQt5.QtWidgets import QApplication, QWidget, QPushButton - -class Example(QWidget): - - def __init__(self): - QWidget.__init__(self) - self.button = QPushButton('Ticker', self) - self.init_ui() - - def init_ui(self): - # self.setGeometry(500, 600) - self.setWindowTitle('Stock Info') - # self.setWindowIcon(QIcon('web.png')) - - self.button.move(20, 20) - - self.show() - diff --git a/changecalculator/src/main/java/org/msstate/cse/changecalculator/changeproneness/ChangePronenessManager.java b/changecalculator/src/main/java/org/msstate/cse/changecalculator/changeproneness/ChangePronenessManager.java deleted file mode 100644 index 6101265..0000000 --- a/changecalculator/src/main/java/org/msstate/cse/changecalculator/changeproneness/ChangePronenessManager.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.msstate.cse.changecalculator.changeproneness; - - -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.List; - -import org.msstate.cse.changecalculator.database.DbUtil; -import org.msstate.cse.changecalculator.diff.DiffParser; -import org.msstate.cse.changecalculator.hibernate.HibernateUtil; -import org.msstate.cse.changecalculator.hibernate.model.SvnHistroy; -import org.msstate.cse.changecalculator.properties.Properties; -import org.msstate.cse.changecalculator.svn.SvnUtil; -import org.msstate.cse.changecalculator.utility.Util; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNLogEntry; -import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; -import org.tmatesoft.svn.core.io.SVNRepository; -import org.tmatesoft.svn.core.io.SVNRepositoryFactory; -import org.tmatesoft.svn.core.wc.SVNWCUtil; - -public class ChangePronenessManager { - private String svnUrl = ""; - private long startRevNum = -1; - private long endRevNum = -1; - - public ChangePronenessManager(Properties prop) { - if(null==prop){ - System.err.println("Properties file is null"); - } - this.svnUrl = prop.getSvn_url(); - this.startRevNum = prop.getStartRevNum(); - this.endRevNum = prop.getEndRevNum(); - } - - public void calculateChangeProneness() { - if (Util.isNullOrEmpty(svnUrl)) { - System.err.println("Invalid SVN URL."); - return; - } - if (startRevNum < 0) { - System.err.println("Invalid start revision nubmer "); - return; - } -// if (endRevNum < 0) { -// System.err.println("Invalid end revision nubmer "); -// return; -// } - - Collection logEntries = null; - try { - SVNRepository repository = getSvnRepository(); - // end revision number - endRevNum = repository.getLatestRevision(); - logEntries = repository.log(new String[] { "" }, null, startRevNum, endRevNum, true, true); - } catch (SVNException e) { - System.err.println(e.getMessage()); - e.printStackTrace(); - - } - - // ignore first revision - boolean isFirstRevision = true; - - //iterate over each log entries - for (Iterator entries = logEntries.iterator(); entries.hasNext();) { - try { - SVNLogEntry logEntry = (SVNLogEntry) entries.next(); - long revNum = logEntry.getRevision(); - - System.out.println("Currently Looking at revision # " +revNum); - - // ignore first revision - if (isFirstRevision) { - isFirstRevision = false; - continue; - } - - // get diff content - String diffString = SvnUtil.getDiffContent(svnUrl, revNum); - if (Util.isNullOrEmpty(diffString)) { - continue; - } - // get changed classes - List changedClassList = DiffParser.getChangedFiles(diffString); - if (null == changedClassList || changedClassList.isEmpty()) { - continue; - } - // iterate changedClassList - Iterator iter = changedClassList.iterator(); - while (iter.hasNext()) { - String classPath = iter.next(); - if (Util.isNullOrEmpty(classPath)) { - continue; - } - - if (classPath.contains(".java")) { - saveIntoDB(classPath, logEntry); - } - } - - } catch (Exception e) { - System.err.println(e.getMessage()); - e.printStackTrace(); - continue; - } - } - - } - - private void saveIntoDB(String filePath, SVNLogEntry logEntry){ - //create SvnHistory model - SvnHistroy svnHistory = new SvnHistroy(); - svnHistory.setClassPath(formatFilePath(filePath)); - svnHistory.setRevNum(logEntry.getRevision()); - svnHistory.setDate_milisecond(convertIntoMiliSecond(logEntry.getDate())); - DbUtil.saveIntoDB(svnHistory); - } - - private long convertIntoMiliSecond(Date date){ - if(null == date){ - System.err.println("Invalid Date"); - return -1 ; - } - return date.getTime(); - - } - - private String formatFilePath(String filePath) { - if (Util.isNullOrEmpty(filePath)) { - System.err.println("Invlalid filepath"); - return null; - } - int beginIndex = filePath.indexOf("org/apache/"); - String formattedString = filePath.substring(beginIndex); - return formattedString; - } - - private SVNRepository getSvnRepository() { - SVNRepository repository = null; - String name = "anonymous"; - String password = "anonymous"; - try { - repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(svnUrl)); - ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(name, password); - repository.setAuthenticationManager(authManager); - } catch (SVNException e) { - e.printStackTrace(); - } - return repository; - } -} diff --git a/changecalculator/src/main/java/org/msstate/cse/changecalculator/database/DBConnection.java b/changecalculator/src/main/java/org/msstate/cse/changecalculator/database/DBConnection.java deleted file mode 100644 index 20858f4..0000000 --- a/changecalculator/src/main/java/org/msstate/cse/changecalculator/database/DBConnection.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.msstate.cse.changecalculator.database; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; - -public class DBConnection { - private static Connection connection = null; - - public static Connection createDatabaseConnection(String dbURL, String userName, String password){ - try { - Class.forName("com.mysql.jdbc.Driver"); - connection = DriverManager.getConnection(dbURL, userName, password); - } catch (SQLException e) { - System.err.println(e.getMessage()); - e.printStackTrace(); - System.exit(1); - } catch (ClassNotFoundException e) { - System.err.println("Error creating database connection. com.mysql.jdbc.Driver was not found"); - e.printStackTrace(); - } - return connection; - } - - public static Connection getConnection() { - return connection; - } - - - -} diff --git a/changecalculator/src/main/java/org/msstate/cse/changecalculator/database/DbUtil.java b/changecalculator/src/main/java/org/msstate/cse/changecalculator/database/DbUtil.java deleted file mode 100644 index dd16a5e..0000000 --- a/changecalculator/src/main/java/org/msstate/cse/changecalculator/database/DbUtil.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.msstate.cse.changecalculator.database; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.msstate.cse.changecalculator.hibernate.HibernateUtil; -import org.msstate.cse.changecalculator.hibernate.model.SvnHistroy; -import org.msstate.cse.changecalculator.utility.Util; - -public class DbUtil { - private static PreparedStatement ps = null; - private static String tableName = null; - - - - public static void setTableName(String tableName) { - DbUtil.tableName = tableName; - } - - public static Connection getDBConnection(){ - DBConnection dbCon = new DBConnection(); - return dbCon.getConnection(); - } - - public static void saveIntoDB(Object obj){ - SvnHistroy svnHis = (SvnHistroy) obj; - /*//session - Session session = HibernateUtil.getSession(); - - //creating transaction object - Transaction t=session.beginTransaction(); - session.save(svnHis); -// session.persist(svnHis);//persisting the object - t.commit();//transaction is commited - //close session - session.close(); */ - - if(Util.isNullOrEmpty(tableName)){ - System.err.println("Please provide valid table name. Table name is empty."); - return; - } - - try { - Connection con = getDBConnection(); - ps = con.prepareStatement("SELECT * FROM " - + tableName - + " WHERE rev_num = ? AND class_path = ?"); - ps.setLong(1, svnHis.getRevNum()); - ps.setString(2, svnHis.getClassPath()); - ResultSet rs = ps.executeQuery(); - if (!rs.next()) { - // Issue not yet in DB. Add to DB. - ps = con.prepareStatement("INSERT INTO " - + tableName - + " (rev_num, class_path, date_time_ms) " - + "VALUES (?, ?, ?)"); - ps.setLong(1, svnHis.getRevNum()); - ps.setString(2, svnHis.getClassPath()); - ps.setLong(3, svnHis.getDate_milisecond()); - ps.executeUpdate(); - } - - } catch (SQLException e) { - System.err.println("Error inserting value"); - e.printStackTrace(); - - } - - } - -} diff --git a/changecalculator/src/main/java/org/msstate/cse/changecalculator/diff/DiffParser.java b/changecalculator/src/main/java/org/msstate/cse/changecalculator/diff/DiffParser.java deleted file mode 100644 index 77902ff..0000000 --- a/changecalculator/src/main/java/org/msstate/cse/changecalculator/diff/DiffParser.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.msstate.cse.changecalculator.diff; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.ArrayList; -import java.util.List; - -public class DiffParser { - - public static List getChangedFiles(String diffContent) { //AJAY-NOTE: Change return from list set - if (diffContent != null && !diffContent.isEmpty()) { - List changedFileList = new ArrayList(); - InputStream in = new ByteArrayInputStream(diffContent.getBytes()); - Reader unbufferedReader = new InputStreamReader(in); - BufferedReader reader = new BufferedReader(unbufferedReader); - String currentLine; - try { - while ((currentLine = reader.readLine()) != null) { - if (currentLine.startsWith("Index:")) { - String[] splitStr = currentLine.split("Index:"); - if (splitStr.length == 2 && splitStr[1] != null - && !splitStr[1].isEmpty()) { - changedFileList.add(splitStr[1].trim()); - } - } - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - if (reader != null) - reader.close(); - if (unbufferedReader != null) - unbufferedReader.close(); - } catch (IOException ex) { - ex.printStackTrace(); - } - } - return changedFileList; - } - return null; - } - -} diff --git a/changecalculator/src/main/java/org/msstate/cse/changecalculator/hibernate/HibernateUtil.java b/changecalculator/src/main/java/org/msstate/cse/changecalculator/hibernate/HibernateUtil.java deleted file mode 100644 index 9db25c2..0000000 --- a/changecalculator/src/main/java/org/msstate/cse/changecalculator/hibernate/HibernateUtil.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.msstate.cse.changecalculator.hibernate; - -import org.apache.log4j.BasicConfigurator; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.cfg.Configuration; - - -public class HibernateUtil { - - private static SessionFactory factory = null; - - - private static SessionFactory getSessionFactory (){ - if(factory == null){ - try { - BasicConfigurator.configure(); - //create factory - Configuration cfg=new Configuration(); //creating configuration object - cfg.configure("hibernate.cfg.xml");//populates the data of the configuration file - //creating seession factory object - factory=cfg.buildSessionFactory(); - } catch (Exception e) { - System.err.println("Hibernate Configuration Error"); - e.printStackTrace(); - } - return factory; - }else{ - return factory; - } - } - - public static Session getSession(){ - //factory - SessionFactory factory = getSessionFactory(); - //creating session object - Session session=factory.openSession(); - - return session; - } - -} diff --git a/changecalculator/src/main/java/org/msstate/cse/changecalculator/hibernate/model/SvnHistroy.java b/changecalculator/src/main/java/org/msstate/cse/changecalculator/hibernate/model/SvnHistroy.java deleted file mode 100644 index 08d0390..0000000 --- a/changecalculator/src/main/java/org/msstate/cse/changecalculator/hibernate/model/SvnHistroy.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.msstate.cse.changecalculator. hibernate.model; - -public class SvnHistroy { - private long revNum ; - private String classPath ; - private long date_milisecond ; - - - public long getRevNum() { - return revNum; - } - public void setRevNum(long revNum) { - this.revNum = revNum; - } - public String getClassPath() { - return classPath; - } - public void setClassPath(String classPath) { - this.classPath = classPath; - } - public long getDate_milisecond() { - return date_milisecond; - } - public void setDate_milisecond(long date_milisecond) { - this.date_milisecond = date_milisecond; - } - - - -} diff --git a/changecalculator/src/main/java/org/msstate/cse/changecalculator/javaclass/JavaClass.java b/changecalculator/src/main/java/org/msstate/cse/changecalculator/javaclass/JavaClass.java deleted file mode 100644 index 5a8a353..0000000 --- a/changecalculator/src/main/java/org/msstate/cse/changecalculator/javaclass/JavaClass.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.msstate.cse.changecalculator.javaclass; - -public class JavaClass { - -} diff --git a/changecalculator/src/main/java/org/msstate/cse/changecalculator/log/TeePrintStream.java b/changecalculator/src/main/java/org/msstate/cse/changecalculator/log/TeePrintStream.java deleted file mode 100644 index cb9417c..0000000 --- a/changecalculator/src/main/java/org/msstate/cse/changecalculator/log/TeePrintStream.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.msstate.cse.changecalculator.log; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; - -public class TeePrintStream extends PrintStream { - private final PrintStream second; - - public TeePrintStream(OutputStream main, PrintStream second) { - super(main); - this.second = second; - } - - /** - * Closes the main stream. - * The second stream is just flushed but not closed. - * @see java.io.PrintStream#close() - */ - @Override - public void close() { - // just for documentation - super.close(); - } - - @Override - public void flush() { - super.flush(); - second.flush(); - } - - @Override - public void write(byte[] buf, int off, int len) { - super.write(buf, off, len); - second.write(buf, off, len); - } - - @Override - public void write(int b) { - super.write(b); - second.write(b); - } - - @Override - public void write(byte[] b) throws IOException { - super.write(b); - second.write(b); - } -} diff --git a/changecalculator/src/main/java/org/msstate/cse/changecalculator/main/Main.java b/changecalculator/src/main/java/org/msstate/cse/changecalculator/main/Main.java deleted file mode 100644 index 55d21fe..0000000 --- a/changecalculator/src/main/java/org/msstate/cse/changecalculator/main/Main.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.msstate.cse.changecalculator.main; - -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.Calendar; -import java.util.Date; -import java.util.ResourceBundle; -import java.util.Scanner; - -import org.msstate.cse.changecalculator.changeproneness.ChangePronenessManager; -import org.msstate.cse.changecalculator.database.DBConnection; -import org.msstate.cse.changecalculator.database.DbUtil; -import org.msstate.cse.changecalculator.log.TeePrintStream; -import org.msstate.cse.changecalculator.properties.Properties; -import org.msstate.cse.changecalculator.utility.Util; - -public class Main { - - public static void main(String[] args) { - Main mainClass = new Main(); - try{ - // Introduction - System.out.println("Welcome to the Change Calculator!\n\n"); - // Request properties file - Properties prop = mainClass.getProperties(); - //console log output to file - mainClass.consoleOutputToFile(prop); - //log start time - mainClass.logStartTime(); - //initialization - mainClass.initialization(prop); - - //get change proneness - ChangePronenessManager CPManager = new ChangePronenessManager(prop); - CPManager.calculateChangeProneness(); - - }catch (Exception e){ - System.err.println(e.getMessage()); - e.printStackTrace(); - }finally { - //closing - mainClass.close(); - mainClass.logEndTime(); - System.out.println("Program Ended"); - } - } - - private Properties getProperties(){ - // Request properties file - System.out.println("What is the name of your properties file? (don't " - + "include '.properties')"); - Scanner input = new Scanner(System.in); - String propFileName = input.next(); - input.close(); - ResourceBundle propFileBundle = ResourceBundle.getBundle("config/" - + propFileName); - return new Properties(propFileBundle); - } - - private void consoleOutputToFile(Properties prop){ - try { - String logPath = prop.getLogPath(); - if(Util.isNullOrEmpty(logPath)){ - System.err.println("Log path is invalid"); - } - String fileName = new Date().getTime()+".txt"; - FileOutputStream fileOS = new FileOutputStream(logPath+"//"+fileName,true); - TeePrintStream tee = new TeePrintStream(fileOS, System.out); - System.setOut(tee); - System.out.println(fileName +" file created at "+logPath); - } catch (FileNotFoundException e) { - System.err.println("Error configuring console log file"); - e.printStackTrace(); - } - } - - private void logStartTime(){ - //printing current time - Date startTime = Calendar.getInstance().getTime(); - System.out.println("\nStart Time: "+ startTime+"\n"); - } - - private void logEndTime(){ - //printing current time - Date endTime = Calendar.getInstance().getTime(); - System.out.println("\nEnd Time: "+ endTime+"\n"); - } - - private void initialization(Properties prop){ - //initialize database connection - DBConnection.createDatabaseConnection(prop.getDb_url(), prop.getDb_user(), - prop.getDb_pass()); - DbUtil.setTableName(prop.getDb_table()); - } - - private void close(){ - //close db connection - Connection conn = DBConnection.getConnection(); - try { - if(conn!=null && !conn.isClosed()){ - conn.close(); - } - } catch (SQLException e) { - e.printStackTrace(); - } - - } - -} diff --git a/changecalculator/src/main/java/org/msstate/cse/changecalculator/properties/Properties.java b/changecalculator/src/main/java/org/msstate/cse/changecalculator/properties/Properties.java deleted file mode 100644 index 3e1b30b..0000000 --- a/changecalculator/src/main/java/org/msstate/cse/changecalculator/properties/Properties.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.msstate.cse.changecalculator.properties; - -import java.util.ResourceBundle; - -import org.msstate.cse.changecalculator.utility.Util; - -public class Properties { - - //database - private String db_url; - private String db_user; - private String db_pass; - private String db_table; - - //svn - private String svn_url; - private int startRevNum; - private int endRevNum; - - //log - private String logPath; - - - public Properties(ResourceBundle bundle) { - this.db_url = bundle.getString("db_url"); - this.db_user = bundle.getString("db_user"); - this.db_pass = bundle.getString("db_pass"); - this.db_table = bundle.getString("db_table"); - this.svn_url = bundle.getString("svn_url"); - this.logPath=bundle.getString("logPath"); - - //start revision number - String startRevNum = bundle.getString("startRevNum"); - if(Util.isNullOrEmpty(startRevNum)){ - this.startRevNum = -1; - System.err.println("Start Revision Number is missing in properties file"); - }else{ - this.startRevNum = Integer.parseInt(startRevNum); - } - - //end revision number - String endRevNum = bundle.getString("endRevNum"); - if(Util.isNullOrEmpty(endRevNum)){ - this.endRevNum = -1; - System.err.println("Start Revision Number is missing in properties file"); - }else{ - this.endRevNum = Integer.parseInt(endRevNum); - } - } - - - public String getDb_url() { - return db_url; - } - - - public String getDb_user() { - return db_user; - } - - - public String getDb_pass() { - return db_pass; - } - - - public String getDb_table() { - return db_table; - } - - - public String getSvn_url() { - return svn_url; - } - - - public int getStartRevNum() { - return startRevNum; - } - - - public int getEndRevNum() { - return endRevNum; - } - - - public String getLogPath() { - return logPath; - } - -} diff --git a/changecalculator/src/main/java/org/msstate/cse/changecalculator/svn/SvnUtil.java b/changecalculator/src/main/java/org/msstate/cse/changecalculator/svn/SvnUtil.java deleted file mode 100644 index 6be8799..0000000 --- a/changecalculator/src/main/java/org/msstate/cse/changecalculator/svn/SvnUtil.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.msstate.cse.changecalculator.svn; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -import org.msstate.cse.changecalculator.utility.Util; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions; -import org.tmatesoft.svn.core.wc.SVNClientManager; -import org.tmatesoft.svn.core.wc.SVNDiffClient; -import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNWCUtil; -import org.tmatesoft.svn.core.wc2.SvnOperationFactory; - -public class SvnUtil { - - private static SvnOperationFactory svnOperationFactory = null; - private static SVNClientManager svnClientManager = null; - - public static SvnOperationFactory getSvnOperationFactory(){ - if(svnOperationFactory==null){ - svnOperationFactory = new SvnOperationFactory(); - } - return svnOperationFactory; - } - - public static SVNClientManager getSvnClientManager(){ - if(svnClientManager == null){ - // SVNWCUtil is a utility class that creates a default options driver. - DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true); - - // Create instance of SVNClientManager providing authentication info and - // options driver - svnClientManager = SVNClientManager.newInstance(options, "anonymous", "anonymous"); - - } - return svnClientManager; - } - - /** - * Return diff content - * - * @param url svnUrl - * @param revisionNumber - * @return Output of "svn diff -c revisionNumber url" - */ - public static String getDiffContent(String url, long revisionNumber) { - if(Util.isNullOrEmpty(url)){ - System.err.println("Invalid URL."); - return null; - } - if(revisionNumber<0){ - System.err.println("Invalid revision number. Revision number cannot be less than zero."); - } - String diffString = ""; - try { - SVNURL svnURL = SVNURL.parseURIEncoded(url); - SVNRevision svnRevNumber = SVNRevision.create(revisionNumber); - SVNRevision prevSvnRevNumber = SVNRevision.create(revisionNumber - 1); - // Getting svn client manager - SVNClientManager clientManager = getSvnClientManager(); - SVNDiffClient diffClient = clientManager.getDiffClient(); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream result = new PrintStream(baos); - diffClient.doDiff(svnURL, svnRevNumber, prevSvnRevNumber, - svnRevNumber, SVNDepth.INFINITY, true, result); - diffString = baos.toString(); - } catch (SVNException e) { - System.err.println("Error getting diff content with revison number " + revisionNumber+" at URL:" + url); - System.out.println(e.getMessage()); - e.printStackTrace(); - } - return diffString; - } -} diff --git a/changecalculator/src/main/java/org/msstate/cse/changecalculator/utility/Util.java b/changecalculator/src/main/java/org/msstate/cse/changecalculator/utility/Util.java deleted file mode 100644 index b787164..0000000 --- a/changecalculator/src/main/java/org/msstate/cse/changecalculator/utility/Util.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.msstate.cse.changecalculator.utility; - -public class Util { - - public static boolean isNullOrEmpty(String str){ - if (null == str) - { - return true; - } - return str.isEmpty(); - } - -} diff --git a/chatt-app/ChatClient.java b/chatt-app/ChatClient.java deleted file mode 100755 index e6514e1..0000000 --- a/chatt-app/ChatClient.java +++ /dev/null @@ -1,155 +0,0 @@ -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.*; -import java.net.*; - -import javax.swing.*; - - -public class ChatClient extends JFrame implements Runnable { - - Socket socket; - JTextArea ta; - JButton send, logout; - JTextField tf; - - Thread thread; - - DataInputStream din; - DataOutputStream dout; - - String LoginName; - - ChatClient(String login) throws UnknownHostException, IOException{ - super(login); - LoginName = login; - - addWindowListener(new WindowAdapter(){ - public void windowClosing(WindowEvent e){ - try { - dout.writeUTF(LoginName + " " + "LOGOUT"); - System.exit(1); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - }); - - ta = new JTextArea(18, 50); - tf = new JTextField(50); - - tf.addKeyListener(new KeyListener(){ - - @Override - public void keyTyped(KeyEvent e) { - // TODO Auto-generated method stub - - } - - @Override - public void keyPressed(KeyEvent e) { - // TODO Auto-generated method stub - if(e.getKeyCode() == KeyEvent.VK_ENTER){ - try { - if(tf.getText().length()>0) - dout.writeUTF(LoginName + " " + "DATA " + tf.getText().toString()); - tf.setText(""); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - } - - @Override - public void keyReleased(KeyEvent e) { - // TODO Auto-generated method stub - - } - - }); - - send = new JButton("Send"); - logout = new JButton("Logout"); - - send.addActionListener(new ActionListener(){ - - @Override - public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub - try { - if(tf.getText().length()>0) - dout.writeUTF(LoginName + " " + "DATA " + tf.getText().toString()); - tf.setText(""); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - - }); - - logout.addActionListener(new ActionListener(){ - - @Override - public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub - try { - dout.writeUTF(LoginName + " " + "LOGOUT"); - System.exit(1); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - - }); - - socket = new Socket("localhost", 5217); - - din = new DataInputStream(socket.getInputStream()); - dout = new DataOutputStream(socket.getOutputStream()); - - dout.writeUTF(LoginName); - dout.writeUTF(LoginName + " " + "LOGIN"); - - thread = new Thread(this); - thread.start(); - setup(); - } - - private void setup() { - // TODO Auto-generated method stub - setSize(600, 400); - - JPanel panel = new JPanel(); - - panel.add(new JScrollPane(ta)); - panel.add(tf); - panel.add(send); - panel.add(logout); - add(panel); - - setVisible(true); - } - - @Override - public void run() { - // TODO Auto-generated method stub - while(true){ - try { - ta.append("\n" + din.readUTF()); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - -} diff --git a/chatt-app/ChatServer.java b/chatt-app/ChatServer.java deleted file mode 100755 index 75613bc..0000000 --- a/chatt-app/ChatServer.java +++ /dev/null @@ -1,93 +0,0 @@ -import java.io.*; -import java.net.*; -import java.util.StringTokenizer; -import java.util.Vector; - - -public class ChatServer { - static Vector ClientSockets; - static Vector LoginNames; - - ChatServer() throws IOException{ - ServerSocket server = new ServerSocket(5217); - ClientSockets = new Vector(); - LoginNames = new Vector(); - - while(true){ - Socket client = server.accept(); - AcceptClient acceptClient = new AcceptClient(client); - } - } - - public static void main(String[] args) throws IOException{ - ChatServer server = new ChatServer(); - } - - class AcceptClient extends Thread{ - Socket ClientSocket; - DataInputStream din; - DataOutputStream dout; - AcceptClient(Socket client) throws IOException{ - ClientSocket = client; - din = new DataInputStream(ClientSocket.getInputStream()); - dout = new DataOutputStream(ClientSocket.getOutputStream()); - - String LoginName = din.readUTF(); - - LoginNames.add(LoginName); - ClientSockets.add(ClientSocket); - - start(); - } - - public void run(){ - while(true){ - try { - String msgFromClient = din.readUTF(); - StringTokenizer st = new StringTokenizer(msgFromClient); - String LoginName = st.nextToken(); - String MsgType = st.nextToken(); - int lo = -1; - String msg = ""; - - while(st.hasMoreTokens()){ - msg=msg+ " " + st.nextToken(); - } - if(MsgType.equals("LOGIN")){ - for(int i = 0; i= 0){ - LoginNames.removeElementAt(lo); - ClientSockets.removeElementAt(lo); - } - } - else { - for(int i = 0; i