Ejemplo n.º 1
0
 private static void getStudentPass(String facultyNumber)
     throws IOException, JAXBException, SAXException, TransformerException,
         ParserConfigurationException {
   if (Pattern.matches("\\d{5,6}", facultyNumber)) {
     InputStream inputStream = new FileInputStream(Constants.CONFIG_FILE_PATH.toString());
     properties.load(inputStream);
     File protocolFile = new File(properties.getProperty("protocol"));
     ReadWriteUtils utils = new ReadWriteUtils(Protocol.class);
     Protocol protocol = (Protocol) utils.readFromXml(protocolFile);
     StudentPass studentPass = protocol.getStudentPass(Integer.parseInt(facultyNumber));
     utils.setType(StudentPass.class);
     File outputFile =
         new File(properties.getProperty("output") + "\\StudentPass" + facultyNumber + ".xml");
     if (outputFile.createNewFile()) System.out.println("File created!");
     utils.writeXml(studentPass, outputFile);
     utils.writeXml(studentPass, System.out);
     System.out.println(
         "Do you want to open the generated XML Document with your default viewing program?");
     if (awaitResponse()) Desktop.getDesktop().open(outputFile);
     System.out.println(
         "Do you want to transform the generated XML Document to html file and open with your default viewing program?");
     if (awaitResponse()) {
       Desktop.getDesktop()
           .open(transformXML(outputFile, new File(Constants.STUDENT_STYLE.toString())));
     }
     inputStream.close();
   } else throw new IllegalArgumentException("Invalid faculty number is entered!");
 }
Ejemplo n.º 2
0
 private static void setProtocol(String protocolFilePath) throws IOException {
   File file = new File(protocolFilePath);
   if (!file.exists()) throw new FileNotFoundException("Protocol file was not found!");
   OutputStream outputStream = new FileOutputStream(Constants.CONFIG_FILE_PATH.toString());
   properties.setProperty("protocol", protocolFilePath);
   properties.store(outputStream, null);
   outputStream.close();
 }
Ejemplo n.º 3
0
 private static void setOutput(String outputFilePath) throws IOException {
   File file = new File(outputFilePath);
   if (file.createNewFile()) System.out.println("File created!");
   OutputStream outputStream = new FileOutputStream(Constants.CONFIG_FILE_PATH.toString());
   properties.setProperty("output", outputFilePath);
   properties.store(outputStream, null);
   outputStream.close();
 }
Ejemplo n.º 4
0
 private static void getProtocol()
     throws IOException, JAXBException, SAXException, ParserConfigurationException,
         TransformerException {
   InputStream inputStream = new FileInputStream(Constants.CONFIG_FILE_PATH.toString());
   properties.load(inputStream);
   File protocolFile = new File(properties.getProperty("protocol"));
   ReadWriteUtils utils = new ReadWriteUtils(Protocol.class);
   utils.writeXml(utils.readFromXml(protocolFile), System.out);
   System.out.println("Do you want to open protocol with your default viewing program?");
   if (awaitResponse()) Desktop.getDesktop().open(protocolFile);
   System.out.println(
       "Do you want to transform and open the protocol file with your default viewing program?");
   if (awaitResponse())
     Desktop.getDesktop()
         .open(transformXML(protocolFile, new File(Constants.PROTOCOL_STYLE.toString())));
 }