secret
anonymous / Main.java
Created

  • Download Gist
Main.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package container;
 
import entities.Fraht;
import entities.Konosament;
import entities.Reciver;
import entities.Zayavka;
import entities.controllers.CoonteinersJpaController;
import entities.controllers.EnterpotsJpaController;
import entities.controllers.FrahtJpaController;
import entities.controllers.KonosamentJpaController;
import entities.controllers.ReciverJpaController;
import entities.controllers.SenderJpaController;
import entities.controllers.VedomostTmcJpaController;
import entities.controllers.ZayavkaJpaController;
import entities.controllers.exceptions.IllegalOrphanException;
import entities.controllers.exceptions.NonexistentEntityException;
import forms.MainForm;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Properties;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
 
 
/**
*
* @author alex
*/
public class Main {
public static EntityManagerFactory emf = Persistence.createEntityManagerFactory("ContainerPU"); ;
/**
* @param args the command line arguments
*/
static MainForm main = new MainForm();
public static ReciverJpaController getReciverJPAController(){
ReciverJpaController rjc=new ReciverJpaController(emf);
return rjc;
}
public static SenderJpaController getSenderJPAController(){
SenderJpaController sjc=new SenderJpaController(emf);
return sjc;
}
public static EnterpotsJpaController getEnterpotsJpaController(){
EnterpotsJpaController ejc = new EnterpotsJpaController(emf);
return ejc;
}
public static String getProperty(String propname){
Properties prop = new Properties();
try {
//load a properties file
prop.load(Main.class.getResourceAsStream("NamesRU.properties"));
return prop.getProperty(propname);
} catch (IOException ex) {
ex.printStackTrace();
return "";
}
}
public static void main(String[] args) throws IllegalOrphanException, NonexistentEntityException {
EntityManager em = emf.createEntityManager();//testing
main = new MainForm();
main.setVisible(true);
}
 
public static FrahtJpaController getFrahtController() {
return new FrahtJpaController(emf);
}
 
public static CoonteinersJpaController getCoonteinersJpaController() {
return new CoonteinersJpaController(emf);
}
 
public static VedomostTmcJpaController getVedomostTmcJpaController() {
return new VedomostTmcJpaController(emf);
}
 
public static ZayavkaJpaController getZayavkaController() {
return new ZayavkaJpaController(emf);
}
 
public static KonosamentJpaController getKonosamentJpaCpntroller() {
return new KonosamentJpaController(emf);
}
public static String getEnterpotTempl1(){
String s = "Ваш груз имеет закрытый коносамент kono"
+ ",это значит, что он прибыл в пункт enterpot числа data.\n" +
"Туда его доставил фраxт fraht\n";
return s;
}
public static String getEnterpotTempl3(){
String s =
"Ваш груз имеет не закрытый коносамент 'kono',"
+ "это значит, что из пункта 'enterpot', он отбыл числа 'data'\n и ещё в пути."
+ "В данный момент его перевозит фрахт 'fraht'" ;
return s;
}
public static String getEnterpotTempl2(){
String s =
"Ваш груз имеет коносамент 'kono2',это значит, что из пункта 'enterpot1',"
+ " он отбыл числа 'data1'.\n" +
" Таким образом он пробыл в пункте 'enterpot1' daycount дней.\n" +
" Информация о пункте 'enterpot1':\n" +
" Срок хранения : 'srok' дней\n" +
" Штраф за простой в 1 день 'price' у.е \n" +
" Штраф за простой в пункте enterpot1 составил 'shtraf' у.е.";
return s;
}
}
persistence.xml
XML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="ContainerPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>entities.Coonteiners</class>
<class>entities.Enterpots</class>
<class>entities.Fraht</class>
<class>entities.Konosament</class>
<class>entities.Reciver</class>
<class>entities.Sender</class>
<class>entities.VedomostTmc</class>
<class>entities.Zayavka</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/expeditor?zeroDateTimeBehavior=convertToNull"/>
<property name="javax.persistence.jdbc.password" value="onelife"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="root"/>
</properties>
</persistence-unit>
</persistence>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.