Commit 45da8440 authored by Ondra's avatar Ondra
Browse files

Edit

parent 14fefa0e
No preview for this file type
----------------------------------------------------------------
Mon Jun 02 22:17:53 CEST 2014:
Booting Derby version The Apache Software Foundation - Apache Derby - 10.10.2.0 - (1582446): instance a816c00e-0146-5e3b-257a-000000b44820
on database directory C:\Users\Ondra\Documents\NetBeansProjects\Training diary\database with class loader sun.misc.Launcher$AppClassLoader@df6ccd
Mon Jun 02 22:36:56 CEST 2014:
Booting Derby version The Apache Software Foundation - Apache Derby - 10.10.2.0 - (1582446): instance a816c00e-0146-5e4c-96f8-000000a58d58
on database directory C:\Users\Ondra\Documents\NetBeansProjects\Training diary\database with class loader sun.misc.Launcher$AppClassLoader@601bb1
Loaded from file:/C:/Users/Ondra/Documents/NetBeansProjects/Training%20diary/libraries/derby.jar
java.vendor=Oracle Corporation
java.runtime.version=1.7.0_40-b43
......
......@@ -30,7 +30,9 @@ class LoginDialog extends JDialog {
private Connection connect;
private JPanel jPanel;
private JLabel jLabel;
private JFrame jFrame; //needed for dialogs
// Needed for dialogs
private JFrame jFrame;
public LoginDialog(JFrame jFrame) {
super(jFrame, "Loading Training activities...", true);
......@@ -102,7 +104,7 @@ class LoginDialog extends JDialog {
public void actionPerformed(ActionEvent event) {
String username = useridField.getText();
char[] password = passwordField.getPassword();
boolean success = true;
boolean success = false;
if ((isPasswordCorrect(password)) && (isUsernameCorrect(username))) {
success = true;
......@@ -165,7 +167,7 @@ class LoginDialog extends JDialog {
*/
private boolean isPasswordCorrect(char[] input) {
boolean isCorrect = true;
char[] correctPassword = {'a'};
char[] correctPassword = {'a','d','m','i','n' };
if (input.length != correctPassword.length) {
isCorrect = false;
......@@ -181,7 +183,7 @@ class LoginDialog extends JDialog {
private boolean isUsernameCorrect(String input) {
boolean isCorrect = true;
String correctString = "Ondra";
String correctString = "Admin";
if (input.length() != correctString.length()) {
isCorrect = false;
......
......@@ -17,7 +17,7 @@ public class Main {
public static void main(String[] args) throws Exception {
// Run program
Mainframe mainframe = new Mainframe();
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cz.cvut.fel.skoumond.utilities;
import cz.cvut.fel.skoumond.entities.RunEntity;
......@@ -17,17 +14,17 @@ import java.util.List;
*/
public class DatabaseSaver implements Serializable {
private List<RunEntity> re = RunRepository.getInstance().all();
private List<TypeEntity> te = TypeRepository.getInstance().all();
private List<RunEntity> rEntities = RunRepository.getInstance().all();
private List<TypeEntity> tEntities = TypeRepository.getInstance().all();
public DatabaseSaver() {
}
public List<RunEntity> getdList() {
return re;
return rEntities;
}
public List<TypeEntity> getvList() {
return te;
return tEntities;
}
}
package cz.cvut.fel.skoumond.utilities;
import cz.cvut.fel.skoumond.entities.RunEntity;
......@@ -13,7 +12,6 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.List;
......@@ -43,14 +41,13 @@ public class FileUtils {
*/
public void saveDatabase(String fileName) throws IOException {
DatabaseSaver dh = new DatabaseSaver();
DatabaseSaver dSaver = new DatabaseSaver();
try {
try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(fileName))) {
out.writeObject(dh);
out.writeObject(dSaver);
}
} catch (IOException e) {
System.err.println("Something got wrong in FileManager");
throw e;
}
}
......@@ -63,26 +60,25 @@ public class FileUtils {
* @throws ClassNotFoundException chyba pri nenalezeni tridy
*/
public void importDatabase(String fileName) throws IOException, ClassNotFoundException {
DatabaseSaver dh;
DatabaseSaver dSaver;
try {
try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(new File(fileName)))) {
dh = (DatabaseSaver) in.readObject();
List<RunEntity> pomD = dh.getdList();
List<TypeEntity> pomV = dh.getvList();
dSaver = (DatabaseSaver) in.readObject();
for (TypeEntity v : pomV) {
TypeRepository.getInstance().save(v);
List<RunEntity> activities = dSaver.getdList();
List<TypeEntity> aTypes = dSaver.getvList();
for (TypeEntity te : aTypes) {
TypeRepository.getInstance().save(te);
}
for (RunEntity r : activities) {
RunRepository.getInstance().save(r);
}
for (RunEntity d : pomD) {
RunRepository.getInstance().save(d);
}
}
} catch (IOException | ClassNotFoundException e) {
System.err.println("Something got wrong in FileManager");
throw e;
}
}
/**
......@@ -92,42 +88,18 @@ public class FileUtils {
*/
public void saveTablesToTxt() throws IOException {
String dTable = "";
String vTable = "";
List<RunEntity> pomD = RunRepository.getInstance().all();
List<TypeEntity> pomV = TypeRepository.getInstance().all();
String activities = "";
for (RunEntity e : pomD) {
dTable += e + "\n";
}
List<RunEntity> runEntities = RunRepository.getInstance().allJoin();
for (TypeEntity e : pomV) {
vTable += e + "\n";
for (RunEntity re : runEntities) {
activities += re + "\n";
}
//jTable += JourneyRepository.getInstance().all();
try {
try (Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("dTable.txt"), "UTF8"))) {
out.write(dTable);
}
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
System.out.println(e);
throw e;
}
try {
try (Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("vTable.txt"), "UTF8"))) {
out.write(vTable);
}
} catch (UnsupportedEncodingException e) {
throw e;
try (Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("Run activities.txt"), "UTF8"))) {
out.write(activities);
} catch (IOException e) {
System.out.println(e);
throw e;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment