Skip to content

Commit

Permalink
Updated stations and timetable with parent class.
Browse files Browse the repository at this point in the history
  • Loading branch information
BabyCakes13 committed Jan 25, 2021
1 parent 596dc73 commit 84d9943
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 49 deletions.
26 changes: 2 additions & 24 deletions src/main/java/core/StationsInteractor.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
package core;

import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import parsers.ParserUtils;
import parsers.XPathUtils;

import javax.xml.bind.JAXBException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.xpath.XPathExpressionException;

public class StationsInteractor {
private Document document;
private XPathUtils xputils;
private ParserUtils putils;
public class StationsInteractor extends Interactor {

public StationsInteractor(String path_to_doc) throws
ParserConfigurationException,
JAXBException {
this.putils = new ParserUtils(path_to_doc);
this.document = this.putils.parseJAXB();
this.xputils = new XPathUtils(this.document);
super(path_to_doc);
}

public NodeList getAllStations() throws XPathExpressionException {
Expand All @@ -30,17 +21,4 @@ public NodeList getAllStations() throws XPathExpressionException {
public NodeList getStation(Integer station_id) throws XPathExpressionException {
return xputils.QueryXPath(String.format("//TransportStation[@id=%s]", station_id));
}

public Document getDocument(){
return this.document;
}

public void SaveDocument(String location) throws TransformerException {
try{
this.putils.SaveDoc(this.document, location);
}
catch (TransformerException e){
System.out.println(e.getMessage());
}
}
}
27 changes: 2 additions & 25 deletions src/main/java/core/TimeTablesInteractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,21 @@

import Models.*;

import parsers.ParserUtils;
import parsers.XPathUtils;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import javax.xml.bind.JAXBException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.xpath.XPathExpressionException;
import java.util.ArrayList;

public class TimeTablesInteractor {
private Document document;
private XPathUtils xputils;
private ParserUtils putils;
public class TimeTablesInteractor extends Interactor {

public TimeTablesInteractor(String path_to_doc) throws
ParserConfigurationException,
JAXBException {
this.putils = new ParserUtils(path_to_doc);
this.document = this.putils.parseJAXB();
this.xputils = new XPathUtils(this.document);
super(path_to_doc);
}

public NodeList getAllTimeTables() throws XPathExpressionException {
Expand Down Expand Up @@ -83,17 +73,4 @@ public Node createTimeTable(Integer new_id, int vehicle_id, ArrayList<Direction>

return new_timetable;
}

public Document getDocument(){
return this.document;
}

public void SaveDocument(String location) throws TransformerException {
try{
this.putils.SaveDoc(this.document, location);
}
catch (TransformerException e){
System.out.println(e.getMessage());
}
}
}

0 comments on commit 84d9943

Please sign in to comment.