Skip to content

Commit

Permalink
Fixed search by id bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
BabyCakes13 committed Jan 25, 2021
1 parent d33e448 commit 477d326
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
20 changes: 12 additions & 8 deletions src/main/java/STPTMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import core.VehiclesInteractor;
import org.apache.camel.main.Main;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import parsers.ParserUtils;

Expand All @@ -21,16 +22,19 @@ public static void main(String args[]) throws Exception {
VehiclesInteractor vehiclesInteractor = new VehiclesInteractor("data/vehicles.xml");
TimeTablesInteractor timetablesInteractor = new TimeTablesInteractor("data/timetables.xml");

NodeList allStations = stationsInteractor.getAllStations();
NodeList allVehicles = vehiclesInteractor.getAllVehicles();
NodeList allTimetables = timetablesInteractor.getAllTimeTables();
// NodeList allStations = stationsInteractor.getAllStations();
// NodeList allVehicles = vehiclesInteractor.getAllVehicles();
// NodeList allTimetables = timetablesInteractor.getAllTimeTables();
//
// stationsInteractor.prettyPrintNodeList(allStations);
// vehiclesInteractor.prettyPrintNodeList(allVehicles);
// timetablesInteractor.prettyPrintNodeList(allTimetables);

stationsInteractor.prettyPrintNodeList(allStations);
vehiclesInteractor.prettyPrintNodeList(allVehicles);
timetablesInteractor.prettyPrintNodeList(allTimetables);
Node foundStation = stationsInteractor.getStation(2810);
stationsInteractor.prettyPrintNode(foundStation);

// System.out.println(s.getStation(2810));
// System.out.println(v.getVehicle(158));
Node foundVehicle = vehiclesInteractor.getVehicle(158);
vehiclesInteractor.prettyPrintNode(foundVehicle);

// Main main = new Main();
// main.configure().addRoutesBuilder(new CamelREST());
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/core/Interactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,19 @@ public void prettyPrintNodeList(NodeList nodeList) {
}

for (int i = 0; i < length; i++) {
if (nodeList.item(i).getNodeType() == Node.ELEMENT_NODE) {
Element el = (Element) nodeList.item(i);
System.out.println(el.getNodeName() + " " +
nodeList.item(i).getAttributes().item(0) + " " +
nodeList.item(i).getTextContent());
}
Node currentNode = nodeList.item(i);
prettyPrintNode(currentNode);
}

System.out.println();
}

public void prettyPrintNode(Node node) {
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element el = (Element) node;
System.out.println(el.getNodeName() + " " +
el.getAttributes().item(0) + " " +
el.getTextContent());
}
}
}

0 comments on commit 477d326

Please sign in to comment.