Skip to content

anonymous /Main.java secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
/*
* 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;
}
}
<?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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.