id
stringlengths 36
36
| text
stringlengths 1
1.25M
|
---|---|
3d2ee7fb-c02b-4dcc-b8d9-6481c162f4a2
|
public void sampleQueryMenu()
{
boolean wantToQuit = false;
while (!wantToQuit)
{
System.out.println("This is the sample query menu.");
System.out.println("1. List titles of all projects, and the number of commits they have done on them.");
System.out.println("2. List emails of all Contributors who are working on more than one project.");
System.out.println("3. List all contributors assigned to work on bugs, and number of bugs assigned to them.");
System.out.println("4. Find the most recent Post(s) of all the Projects.");
System.out.println("5. Find the name and phone numbers of all Managers of ongoing Projects.");
System.out.println("6. List the emails of all Contributors to projects that do not have managers.");
System.out.println("7. Return to main menu");
int option = userInput.nextInt();
switch (option)
{
case 1:
query1();
break;
case 2:
query2();
break;
case 3:
query3();
break;
case 4:
query4();
break;
case 5:
query5();
break;
case 6:
query6();
break;
case 7:
wantToQuit = true;
default:
System.out.println("Invalid input. Try again.");
}
}
}
|
8d807bfb-f251-4a87-9f98-e4e2e05c06a0
|
public static void main(String args[]) throws IOException
{
LOGGER.setLevel(Level.INFO);
Dot dot = new Dot();
dot.connectToDB();
MainMenu mainMenu = new MainMenu(LOGGER, dot.connection);
boolean wantToQuit = false;
while (!wantToQuit)
{
System.out.println("This is the administration tool for the DOT issue tracker");
System.out.println("and source control program. Before beginning, choose:");
System.out.println("1. Reinitialize the database with sample data");
System.out.println("2. Continue with the old database");
String input = dot.userInput.nextLine();
//check input
InputChecker in = new InputChecker(input);
if(in.hasAlpha())
{
System.out.println("That was not an int, returning to goals menu.");
return;
}
input = input.trim();
switch (input)
{
case "1": // COMMITS
dot.initializeDB();
mainMenu.commitToDatabaseMenu();
//dont need a break; here
case "2":
wantToQuit = true;
break;
default:
System.out.println("Invalid menu option");
break;
}
}
FileUtil.init();
mainMenu.mainMenu();
FileUtil.close();
}
|
b0e378b7-808b-4c03-bb08-bbad62116028
|
public Dot()
{
try {
Class.forName(DB_DRIVER);
} catch (ClassNotFoundException cnfe) {
LOGGER.log(Level.SEVERE, "Unable to load JDBC driver, due to error: {0}", cnfe);
System.exit(1);
}
}
|
95ea2c68-3754-4de8-9168-31c54f9b0608
|
private void initializeDB() throws IOException
{
String[] fileNames = new String[] {"dot-sql-drop-all-tables.sql", "dot-sql-create-and-insert-enum.sql",
"dot-sql-create-all-tables.sql", "dot-sql-insert-all-tables.sql"};
for (String fileName : fileNames)
{
String[] statements = FileUtil.readFile(fileName).split("; ");
for (String statementString : statements)
{
try
{
Statement statement = connection.createStatement();
statement.executeUpdate(statementString);
}
catch (SQLException sqe)
{
LOGGER.log(Level.SEVERE, "Unable to init database due to error {0}. In file "
+ fileName + ", offending statement was " + statementString, sqe.getMessage());
System.exit(1);
}
}
}
}
|
3039ecff-c338-4732-b1dd-5fad1be02259
|
private void connectToDB()
{
System.out.println("Connecting to the database.");
try
{
System.out.println("Enter the username. For testing purposes, username is: cecs323m16");
String username = userInput.nextLine().trim();
System.out.println("Enter the password. Password is aigoiY.");
String password = userInput.nextLine().trim();
connection = DriverManager.getConnection(databaseURL, username, password);
connection.setAutoCommit(false);
}
catch (SQLException sqe)
{
// this is for LOGGING purposes
LOGGER.log(Level.SEVERE, "Unable to establish a connection to the database due to error {0}", sqe.getMessage());
sqe.printStackTrace();
connection = null;
// this is for the PROGRAM's purpose. i.e., exit because we can't do anything
System.out.println("Unable to connect to database. Make sure you are connected to.");
System.out.println("the heart.cecs.csulb.edu server by SSH.");
System.exit(1);
}
}
|
496ab8e9-deaa-4143-80e5-79dfcba097dc
|
public ConfigFile(String file) {
this.fileName = file;
file = null;
map = new HashMap();
}
|
55a1cc29-afa6-4e84-9b79-5e231fad3d92
|
public void load() throws FileNotFoundException{
BufferedReader reader = null;
FileReader stream = null;
try {
File f = new File(fileName);
if(!f.exists())
f.createNewFile();
stream = new FileReader(fileName);
reader = new BufferedReader(stream);
String line;
String[] splited;
while ((line = reader.readLine()) != null) {
String key = null, value = "";
splited = line.split(": ");
if (splited.length < 2) {
continue;
}
value = splited[1];
for (int i = 2; i < splited.length; i++) {
value += ": " + splited[i];
}
key = splited[0];
map.put(key, value);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
//close file
try {
if (reader != null) {
reader.close();
}
} catch (IOException e2) {
e2.printStackTrace();
}
}
}
|
de562db5-4bbf-4e8b-b760-446581e1b35f
|
public void store(String key, String value) {
map.put(key, value);
}
|
13e2b3d7-a747-446f-b35c-4fbfe75101ac
|
public String get(String key) {
return map.get(key);
}
|
94ba4a4c-98f5-4793-bf7f-03b5b6d08972
|
public void save() {
FileWriter writer = null;
try {
writer = new FileWriter(fileName);
for (Map.Entry<String,String> pairs : map.entrySet()) {
writer.write(pairs.getKey() + ": " + pairs.getValue() + "\n");
}
} catch (IOException ex) {
Logger.getLogger(ConfigFile.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
writer.close();
} catch (IOException ex) {
Logger.getLogger(ConfigFile.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
|
1825cc2c-0353-4295-885d-8154b0f76aa4
|
public void print() {
for (Map.Entry<String,String> pairs : map.entrySet()) {
System.out.println(pairs.getKey() + " : " + pairs.getValue());
}
}
|
2aa64616-5391-4e8d-85d7-c6bddb2c955a
|
public static void main(String args[]) throws FileNotFoundException, IOException {
if(args.length != 1) {
System.out.println("Invalid argument");
return;
}
String file = args[0];
ConfigFile test = new ConfigFile(file);
test.load();
test.print();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line;
while((line = reader.readLine()) != null) {
String[] splited = line.split(" ");
switch(splited[0]) {
case "store":
case "s":
if(splited.length == 3)
test.store(splited[1], splited[2]);
break;
case "get":
case "g":
if(splited.length == 2)
System.out.println(test.get(splited[1]));
break;
case "print":
case "p":
test.print();
break;
case "save":
if(splited.length == 1)
test.save();
break;
case "quit":
case "q":
return;
}
}
}
|
ca41d5b8-9833-4c67-8140-d9c5e15e5866
|
public String getBody()
{
return body;
}
|
141125f3-d3e9-42f9-aecb-58cffa6e4827
|
protected void setBody(String body)
{
this.body = body;
}
|
3a73bef2-198d-4094-a51a-5466a2e3c4f9
|
public String getCreated_at()
{
return created_at;
}
|
8da63baa-13ee-4144-86f8-7df089a350df
|
protected void setCreated_at(String created_at)
{
this.created_at = created_at;
}
|
ad871ff7-0a5e-4cb1-a7b3-c2d08fa0979e
|
public int getId()
{
return id;
}
|
4beeab70-326c-462f-9392-97cb96758f0a
|
protected void setId(int id)
{
this.id = id;
}
|
4da03b1d-9012-4b8b-b839-0946437a2302
|
public int getTo_whom_user_id()
{
return to_whom_user_id;
}
|
de9ab324-fdc3-4c73-a923-79d46ea9b415
|
protected void setTo_whom_user_id(int to_whom_user_id)
{
this.to_whom_user_id = to_whom_user_id;
}
|
6a785788-4832-45c4-8b76-3a3444cebd0f
|
public User getUser()
{
return user;
}
|
4c500074-87c7-46b1-98a0-5b2641164cfe
|
protected void setUser(User user)
{
this.user = user;
}
|
b3a93578-e78c-434a-9c1a-4db9201e2f03
|
public int getUser_id()
{
return user_id;
}
|
2aa53610-bcb3-4ca9-a7c0-043ec251545f
|
protected void setUser_id(int user_id)
{
this.user_id = user_id;
}
|
56118570-3294-47cd-8d66-0179fa0f2595
|
public static Gson getGson()
{
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Integer.class, new ErrorIgnoringIntegerDeserializer());
builder.registerTypeAdapter(Date.class, new DateDeserializer());
return builder.create();
}
|
8d294256-6dce-49fb-bb50-ec364c048d81
|
@Override
public Date deserialize(JsonElement json, Type typeofT, JsonDeserializationContext context) throws JsonParseException
{
Date rtn = new Date();
String value = json.getAsString();
if ("0000-01-01T00:00:00-04:56".equals(value))
{
// this particular value messes things up.
// log or something
}
else
{
try
{
rtn = javax.xml.bind.DatatypeConverter.parseDateTime(value).getTime();
}
catch (Exception ignored)
{
// log or something
}
}
return rtn;
}
|
65e34bfb-e089-4fa8-a8f6-3cf9c06d448e
|
@Override
public Integer deserialize(JsonElement json, Type typeofT, JsonDeserializationContext context) throws JsonParseException
{
String value = json.getAsString();
try
{
Integer i = new Integer(value);
return i;
}
catch (NumberFormatException iggy)
{
}
return null;
}
|
08fd5b8a-9173-459f-abec-ccaddbafdf9c
|
private Category(int val, String catName)
{
this.val = val;
this.catName = catName;
}
|
a653fc47-e10e-4cf7-9a4a-7b0caccc692a
|
private Category(int val)
{
this.val = val;
this.catName = name();
}
|
18106d3a-1c94-46e3-9d4d-46bcda205da5
|
public int getCategoryValue()
{
return val;
}
|
ad3538e5-e1d9-4512-a915-27874b199c51
|
public String getCategoryName()
{
return catName;
}
|
940089cc-4b69-4324-9754-069aadd536db
|
public static Category parseInt(int categoryValue)
{
for (Category cat : Category.values())
{
if (cat.getCategoryValue() == categoryValue)
{
return cat;
}
}
return Category.None;
}
|
f0654225-2324-4d16-bbef-e05c4c26376f
|
public int getId()
{
return id;
}
|
e4b83f3b-cf06-45f7-a43e-8c5b78f9e1f6
|
protected void setId(int id)
{
this.id = id;
}
|
56ea64dd-e150-4f47-8b9d-4d4782b51a0a
|
public String getUsername()
{
return username;
}
|
2afa7e95-e7da-465c-82b3-a62b67316fba
|
protected void setUsername(String username)
{
this.username = username;
}
|
c618833f-d120-4ddf-b014-a881c7a1c859
|
public String getFirstname()
{
return firstname;
}
|
7231fde6-3dcd-4ce9-aece-18c50ec091fc
|
protected void setFirstname(String firstname)
{
this.firstname = firstname;
}
|
3ceb5e02-db6c-42d9-8587-c93949c4c898
|
public String getLastname()
{
return lastname;
}
|
8334a48f-76fd-44c5-8f28-a0ea6e49da6d
|
protected void setLastname(String lastname)
{
this.lastname = lastname;
}
|
85650c43-479a-408c-921e-bd6788103af2
|
public String getFullname()
{
return fullname;
}
|
14409dc2-208e-4e3b-89cc-5cf74fe254d7
|
protected void setFullname(String fullname)
{
this.fullname = fullname;
}
|
8dfe62f6-0e6a-4653-976d-a7a6aba2afa3
|
public String getUserpic_url()
{
return userpic_url;
}
|
aba8c4b8-cc16-43db-a3af-4c64006d81f1
|
protected void setUserpic_url(String userpic_url)
{
this.userpic_url = userpic_url;
}
|
f3651d71-f24b-4ed9-8812-377fd1bc1e3a
|
public String getSex()
{
return sex;
}
|
17b8ac96-0acd-406b-b4d6-be0ba404c2c1
|
protected void setSex(String sex)
{
this.sex = sex;
}
|
e07500c9-6767-4e51-8800-3042f3719d4d
|
public String getCity()
{
return city;
}
|
5c21fb7e-d20a-4b84-8c23-c19b4ff7b68e
|
protected void setCity(String city)
{
this.city = city;
}
|
f9a78547-974f-49c3-8c10-4a609b35442b
|
public String getState()
{
return state;
}
|
1cc0f3e3-4e04-4772-be6d-2320a51f5eeb
|
protected void setState(String state)
{
this.state = state;
}
|
babfb517-3185-47ea-ac3e-25a8dc0faba4
|
public String getCountry()
{
return country;
}
|
7d6c88cb-ad23-4ac7-9d4c-d28f1f1dd249
|
protected void setCountry(String country)
{
this.country = country;
}
|
7040a91f-9b27-4967-b3b6-849367921ff6
|
public String getRegistration_date()
{
return registration_date;
}
|
489482a6-55bd-4d54-ab2c-63a21025f8d7
|
protected void setRegistration_date(String registration_date)
{
this.registration_date = registration_date;
}
|
c5c75296-50d3-466b-a1d3-d6f203c7514f
|
public String getAbout()
{
return about;
}
|
08452f9c-7034-428d-ab83-62e4a23ca857
|
protected void setAbout(String about)
{
this.about = about;
}
|
86cd47e1-61f1-413d-af1a-2e18a894672b
|
public int getUpgrade_status()
{
return upgrade_status;
}
|
3ef57582-33f4-4da5-ba26-f6c397e56180
|
protected void setUpgrade_status(int upgrade_status)
{
this.upgrade_status = upgrade_status;
}
|
fbce19f7-d13b-4191-b6d2-28ba3ff4bac9
|
public String getDomain()
{
return domain;
}
|
176f6c38-511f-40d8-9549-20a592138ae1
|
protected void setDomain(String domain)
{
this.domain = domain;
}
|
b091aaec-8b7f-4f1e-b282-29ec223db063
|
public boolean isFotomoto_on()
{
return fotomoto_on;
}
|
2d74d223-fc12-4dd0-9daa-fb09b355f131
|
protected void setFotomoto_on(boolean fotomoto_on)
{
this.fotomoto_on = fotomoto_on;
}
|
ec08b2de-e2ab-487f-b3bf-c64b8f3be68d
|
public String getLocale()
{
return locale;
}
|
8dd3c9d2-b166-4e1a-be97-fd007b22f8ce
|
protected void setLocale(String locale)
{
this.locale = locale;
}
|
f65a42e4-53bb-4f46-8ce5-83712c928cfb
|
public boolean isShow_nude()
{
return show_nude;
}
|
978f66cb-bbe1-42fb-b004-2cdfc31d8fb4
|
protected void setShow_nude(boolean show_nude)
{
this.show_nude = show_nude;
}
|
00035418-2f42-44a9-b4e0-3dd0c201632d
|
public int getFriends_count()
{
return friends_count;
}
|
796af2b2-fa0b-4404-8927-4e714fdb9465
|
protected void setFriends_count(int friends_count)
{
this.friends_count = friends_count;
}
|
bc9e672b-5f44-4b7a-abda-9578b861d32f
|
public int getFollowers_count()
{
return followers_count;
}
|
1ccddb79-bb68-4e3d-96be-90e4e6ed4a50
|
protected void setFollowers_count(int followers_count)
{
this.followers_count = followers_count;
}
|
fce5016f-c17e-4b5f-a640-fcbe198a52ed
|
public int getPhotos_count()
{
return photos_count;
}
|
e8be686d-05ec-4915-83c9-0cc4aa97b0ae
|
protected void setPhotos_count(int photos_count)
{
this.photos_count = photos_count;
}
|
27c684f2-15cb-4fe5-a6aa-61c174abc385
|
public int getIn_favorites_count()
{
return in_favorites_count;
}
|
08ef7e5d-45a4-4fef-b71d-e208af3041b8
|
protected void setIn_favorites_count(int in_favorites_count)
{
this.in_favorites_count = in_favorites_count;
}
|
48b7d752-f61a-429c-b833-ef7abd3ae14f
|
public int getAffection()
{
return affection;
}
|
781d5ce5-8ad1-489f-8ab5-d8b821bd78ff
|
protected void setAffection(int affection)
{
this.affection = affection;
}
|
60641624-7d29-49cc-88ff-24aaed594af0
|
public Map<String, String> getContacts()
{
return contacts;
}
|
b5f8495c-f22b-4ca0-8052-2be8cfcce143
|
protected void setContacts(Map<String, String> contacts)
{
this.contacts = contacts;
}
|
35306b35-12a8-4770-9814-e8ea66d2debb
|
public Photo()
{
image_url = defaultImageUrl;
}
|
e5048b12-c01a-4c9a-9e63-8a8fddbccbfc
|
public int getId()
{
return id;
}
|
ef845385-5c66-45bd-904d-4a9dc5fa87e3
|
protected void setId(int id)
{
this.id = id;
}
|
1fb2d14c-d5c6-4f78-86bf-6a9da57bbda9
|
public String getName()
{
return name;
}
|
d209afc5-01fd-4561-9e30-f126413fe9b4
|
protected void setName(String name)
{
this.name = name;
}
|
72a50f56-c438-48b2-a9e0-1dc6d5cebc23
|
public String getDescription()
{
return description;
}
|
52ebf670-bedc-429a-98d7-e3c7c5fbff64
|
protected void setDescription(String description)
{
this.description = description;
}
|
b3450a0b-96d5-41ab-8399-4a2bbd979700
|
public Category getCategory()
{
return Category.parseInt(category);
}
|
67c2b967-c99c-4ec9-b074-088de4152be7
|
protected void setCategory(int category)
{
this.category = category;
}
|
c3434cf2-5105-43be-a191-6706e1ad186b
|
public String getImageUrl()
{
return image_url;
}
|
924984ae-5f30-4c7c-9e86-50a33aa71d1c
|
protected void setImage_url(String image_url)
{
this.image_url = image_url;
}
|
333545ab-cff0-4e87-a611-3ed4f3d8734e
|
public int getVotesCount()
{
return votes_count;
}
|
25af4e53-085c-4059-b289-d2f106b827f0
|
protected void setVotes_count(int votes_count)
{
this.votes_count = votes_count;
}
|
e06983f3-e4f6-47d3-9de4-653298522903
|
public int getFavoritesCount()
{
return favorites_count;
}
|
2aa8f849-7124-4145-8707-e164f9c61b33
|
protected void setFavorites_count(int favorites_count)
{
this.favorites_count = favorites_count;
}
|
db80ccc5-8dd3-4ad0-b2ba-fee8bafc93f0
|
public int getCommentsCount()
{
return comments_count;
}
|
71fe93f9-40e3-4287-9a71-cf854d8a2435
|
protected void setComments_count(int comments_count)
{
this.comments_count = comments_count;
}
|
0a87a9af-346c-42b6-805a-218cd6c1ed6c
|
public double getRating()
{
return rating;
}
|
7f5c72d6-9303-41ae-8248-b03f18b1dd4e
|
protected void setRating(double rating)
{
this.rating = rating;
}
|
655a6b48-eb1b-40da-b2fd-28c206528b8a
|
public Date getCreatedDate()
{
return created_at;
}
|
e1bb949f-ba05-4b96-a170-7adefc54ddd3
|
protected void setCreated_at(Date created_at)
{
this.created_at = created_at;
}
|
a4d4a91f-1159-4cdd-b39e-b5def7b1066d
|
public int getStatus()
{
return status;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.