Loading TapSchemaManager/src/main/webapp/expired.xhtml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -4,7 +4,7 @@ xmlns:f="http://java.sun.com/jsf/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" > xmlns:ui="http://java.sun.com/jsf/facelets" > <ui:define name="title">TapSchema Manager - Credentials insertion page</ui:define> <ui:define name="title">TapSchema Manager - Session Expired</ui:define> <ui:define name="content"> <ui:define name="content"> <br/> <br/> <div class="container"> <div class="container"> Loading TapSchemaManagerDL/src/main/java/it/inaf/oats/ia2/tapschemamanager/datalayer/TapSchemaHandler.java +31 −11 Original line number Original line Diff line number Diff line package it.inaf.oats.ia2.tapschemamanager.datalayer; package it.inaf.oats.ia2.tapschemamanager.datalayer; import java.io.Closeable; import java.io.Closeable; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; import java.io.Serializable; import java.sql.Connection; import java.sql.Connection; import java.sql.SQLException; import java.sql.SQLException; Loading Loading @@ -67,9 +69,9 @@ class ColumnsInfo implements Serializable { } } /** /** * This class manage load of TAP_SCHEMA entities and other database schemas informations. * This class manage load of TAP_SCHEMA entities and other database schemas * IMPORTANT: If you use this class inside another object remember to call the * informations. IMPORTANT: If you use this class inside another object remember * close method to release the occupied resources. * to call the close method to release the occupied resources. * * * @author Sonia Zorba <zorba at oats.inaf.it> * @author Sonia Zorba <zorba at oats.inaf.it> */ */ Loading Loading @@ -373,13 +375,31 @@ public class TapSchemaHandler implements Serializable, Closeable { @Override @Override public void close() { public void close() { if (entityManager.isOpen()) { EntityManagerFactory efFactory = entityManager.getEntityManagerFactory(); EntityManagerFactory efFactory = entityManager.getEntityManagerFactory(); entityManager.close(); entityManager.close(); if (efFactory.isOpen()) { efFactory.close(); efFactory.close(); } } try { try { closeConnection(); closeConnection(); } catch (SQLException e) { } catch (SQLException e) { e.printStackTrace(System.err); e.printStackTrace(System.err); } } } } /** * Automatic closing on serialization * @param stream * @throws IOException */ private void writeObject(ObjectOutputStream stream) throws IOException { close(); stream.defaultWriteObject(); } } } TapSchemaManagerDL/src/test/java/TestQuery.java +26 −0 Original line number Original line Diff line number Diff line Loading @@ -7,6 +7,10 @@ import it.inaf.oats.ia2.tapschemamanager.datalayer.KeyEntity; import it.inaf.oats.ia2.tapschemamanager.datalayer.SchemaEntity; import it.inaf.oats.ia2.tapschemamanager.datalayer.SchemaEntity; import it.inaf.oats.ia2.tapschemamanager.datalayer.TableEntity; import it.inaf.oats.ia2.tapschemamanager.datalayer.TableEntity; import it.inaf.oats.ia2.tapschemamanager.datalayer.TapSchemaHandler; import it.inaf.oats.ia2.tapschemamanager.datalayer.TapSchemaHandler; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.sql.Connection; import java.sql.Connection; import java.sql.SQLException; import java.sql.SQLException; import java.sql.Statement; import java.sql.Statement; Loading Loading @@ -109,6 +113,28 @@ public class TestQuery { } } } } @Test public void testSerialization() throws Exception { TapSchemaHandler tapSchemaHandler = new TapSchemaHandler(credentials, "vlkb_voinfo_schema", true); System.out.println("schemas size = " + tapSchemaHandler.getSchemas().size()); FileOutputStream fileOut = new FileOutputStream("/home/sonia/test.ser"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(tapSchemaHandler); out.close(); fileOut.close(); FileInputStream fileIn = new FileInputStream("/home/sonia/test.ser"); ObjectInputStream in = new ObjectInputStream(fileIn); tapSchemaHandler = (TapSchemaHandler) in.readObject(); in.close(); fileIn.close(); tapSchemaHandler.save(); System.out.println("schemas size = " + tapSchemaHandler.getSchemas().size()); } @Ignore @Ignore @Test @Test public void loadSchema() throws SQLException { public void loadSchema() throws SQLException { Loading Loading
TapSchemaManager/src/main/webapp/expired.xhtml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -4,7 +4,7 @@ xmlns:f="http://java.sun.com/jsf/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" > xmlns:ui="http://java.sun.com/jsf/facelets" > <ui:define name="title">TapSchema Manager - Credentials insertion page</ui:define> <ui:define name="title">TapSchema Manager - Session Expired</ui:define> <ui:define name="content"> <ui:define name="content"> <br/> <br/> <div class="container"> <div class="container"> Loading
TapSchemaManagerDL/src/main/java/it/inaf/oats/ia2/tapschemamanager/datalayer/TapSchemaHandler.java +31 −11 Original line number Original line Diff line number Diff line package it.inaf.oats.ia2.tapschemamanager.datalayer; package it.inaf.oats.ia2.tapschemamanager.datalayer; import java.io.Closeable; import java.io.Closeable; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; import java.io.Serializable; import java.sql.Connection; import java.sql.Connection; import java.sql.SQLException; import java.sql.SQLException; Loading Loading @@ -67,9 +69,9 @@ class ColumnsInfo implements Serializable { } } /** /** * This class manage load of TAP_SCHEMA entities and other database schemas informations. * This class manage load of TAP_SCHEMA entities and other database schemas * IMPORTANT: If you use this class inside another object remember to call the * informations. IMPORTANT: If you use this class inside another object remember * close method to release the occupied resources. * to call the close method to release the occupied resources. * * * @author Sonia Zorba <zorba at oats.inaf.it> * @author Sonia Zorba <zorba at oats.inaf.it> */ */ Loading Loading @@ -373,13 +375,31 @@ public class TapSchemaHandler implements Serializable, Closeable { @Override @Override public void close() { public void close() { if (entityManager.isOpen()) { EntityManagerFactory efFactory = entityManager.getEntityManagerFactory(); EntityManagerFactory efFactory = entityManager.getEntityManagerFactory(); entityManager.close(); entityManager.close(); if (efFactory.isOpen()) { efFactory.close(); efFactory.close(); } } try { try { closeConnection(); closeConnection(); } catch (SQLException e) { } catch (SQLException e) { e.printStackTrace(System.err); e.printStackTrace(System.err); } } } } /** * Automatic closing on serialization * @param stream * @throws IOException */ private void writeObject(ObjectOutputStream stream) throws IOException { close(); stream.defaultWriteObject(); } } }
TapSchemaManagerDL/src/test/java/TestQuery.java +26 −0 Original line number Original line Diff line number Diff line Loading @@ -7,6 +7,10 @@ import it.inaf.oats.ia2.tapschemamanager.datalayer.KeyEntity; import it.inaf.oats.ia2.tapschemamanager.datalayer.SchemaEntity; import it.inaf.oats.ia2.tapschemamanager.datalayer.SchemaEntity; import it.inaf.oats.ia2.tapschemamanager.datalayer.TableEntity; import it.inaf.oats.ia2.tapschemamanager.datalayer.TableEntity; import it.inaf.oats.ia2.tapschemamanager.datalayer.TapSchemaHandler; import it.inaf.oats.ia2.tapschemamanager.datalayer.TapSchemaHandler; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.sql.Connection; import java.sql.Connection; import java.sql.SQLException; import java.sql.SQLException; import java.sql.Statement; import java.sql.Statement; Loading Loading @@ -109,6 +113,28 @@ public class TestQuery { } } } } @Test public void testSerialization() throws Exception { TapSchemaHandler tapSchemaHandler = new TapSchemaHandler(credentials, "vlkb_voinfo_schema", true); System.out.println("schemas size = " + tapSchemaHandler.getSchemas().size()); FileOutputStream fileOut = new FileOutputStream("/home/sonia/test.ser"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(tapSchemaHandler); out.close(); fileOut.close(); FileInputStream fileIn = new FileInputStream("/home/sonia/test.ser"); ObjectInputStream in = new ObjectInputStream(fileIn); tapSchemaHandler = (TapSchemaHandler) in.readObject(); in.close(); fileIn.close(); tapSchemaHandler.save(); System.out.println("schemas size = " + tapSchemaHandler.getSchemas().size()); } @Ignore @Ignore @Test @Test public void loadSchema() throws SQLException { public void loadSchema() throws SQLException { Loading