id
stringlengths 36
36
| text
stringlengths 1
1.25M
|
---|---|
6a2b31a8-cf25-4406-993f-1ff922cf74b7 | @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Vertex other = (Vertex) obj;
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
return true;
} |
6ab6b8a0-b48b-4f70-bd50-23841abb10e3 | @Override
public String toString() {
return name;
} |
e9510c12-df6b-44e8-85d1-f2e4d6fc85f2 | public DijkstraAlgorithm(Graph graph, DataStore ds) {
// Create a copy of the array so that we can operate on this array
this.nodes = new ArrayList<Vertex>(graph.getVertexes());
this.edges = new ArrayList<Edge>(graph.getEdges());
this.ds = ds;
} |
ae7a0387-a18b-4792-b7e0-b2011c095d5d | public void execute(Vertex source) {
//System.out.println("source.toString() " + source.toString());
settledNodes = new HashSet<Vertex>();
unSettledNodes = new HashSet<Vertex>();
distance = new HashMap<Vertex, Integer>();
predecessors = new HashMap<Vertex, Vertex>();
distance.put(source, 0);
unSettledNodes.add(source);
while (unSettledNodes.size() > 0) {
Vertex node = getMinimum(unSettledNodes);
//System.out.println("node.toString() " + node.toString());
settledNodes.add(node);
unSettledNodes.remove(node);
findMinimalDistances(node);
}
} |
cefcc079-0373-4020-8f54-ef8bc528e49d | private void findMinimalDistances(Vertex node) {
List<Vertex> adjacentNodes = getNeighbors(node);
Vertex lasttarget = null;
for (Vertex target : adjacentNodes) {
System.out.println("target.toString() " + target.toString());
if (getShortestDistance(target) > getShortestDistance(node)
+ getDistance(node, target)) {
distance.put(target, getShortestDistance(node)
+ getDistance(node, target));
predecessors.put(target, node);
unSettledNodes.add(target);
}
for (int i = 0; i < ds.notoknumber.length - 1; i++) {
if (predecessors.get(target) != null) {
if (ds.notoknumber[i + 1] == Integer.parseInt(predecessors.get(target).getId()) && ds.notoknumber[i] == Integer.parseInt(target.getId())) {
predecessors.remove(target);
predecessors.remove(lasttarget);
distance.remove(target);
distance.remove(lasttarget);
}
}
}
lasttarget = target;
//System.out.println("predecessors.get(target) " + predecessors.get(target));
//System.out.println("predecessors.get(predecessors.get(target) " + predecessors.get(predecessors.get(target)));
//System.out.println("predecessors.get(predecessors.get(predecessors.get(target))) " + predecessors.get(predecessors.get(predecessors.get(target))) + "\n");
}
} |
1836f22a-ece2-49ee-9133-6e37bea55b35 | private int getDistance(Vertex node, Vertex target) {
for (Edge edge : edges) {
if (edge.getSource().equals(node)
&& edge.getDestination().equals(target)) {
return edge.getWeight();
}
}
throw new RuntimeException("Should not happen");
} |
27b612ba-7dd0-4023-b488-8d1b1c32f72a | private List<Vertex> getNeighbors(Vertex node) {
List<Vertex> neighbors = new ArrayList<Vertex>();
for (Edge edge : edges) {
if (edge.getSource().equals(node)
&& !isSettled(edge.getDestination())) {
neighbors.add(edge.getDestination());
}
}
return neighbors;
} |
ec90dbe5-6318-4af0-a8bd-2fad81acdb6a | private Vertex getMinimum(Set<Vertex> vertexes) {
Vertex minimum = null;
for (Vertex vertex : vertexes) {
if (minimum == null) {
minimum = vertex;
} else {
if (getShortestDistance(vertex) < getShortestDistance(minimum)) {
minimum = vertex;
}
}
}
return minimum;
} |
d9bac947-4fe1-471e-9ef0-e5c6cd81eeb8 | private boolean isSettled(Vertex vertex) {
return settledNodes.contains(vertex);
} |
0a6a6cb6-9cbb-4c45-8875-e26f5559c55c | private int getShortestDistance(Vertex destination) {
Integer d = distance.get(destination);
if (d == null) {
return Integer.MAX_VALUE;
} else {
return d;
}
} |
46f7a0f1-096b-42a9-87c5-743b9cfca20e | public LinkedList<Vertex> getPath(Vertex target) {
LinkedList<Vertex> path = new LinkedList<Vertex>();
Vertex step = target;
// Check if a path exists
if (predecessors.get(step) == null) {
return null;
}
path.add(step);
while (predecessors.get(step) != null) {
step = predecessors.get(step);
path.add(step);
}
// Put it into the correct order
Collections.reverse(path);
return path;
} |
43ae1e2d-42ef-4c7d-9300-e2d920b8dac1 | public DataStore optorderlista(DataStore ds3, OptPlan op) {
//Massa bra variabler
LinkedList<Vertex> path;
DataStore ds4 = new DataStore();
ds4.orders = ds3.orders;
int start, stop, diff, mindiff;
//De orderpar som redan betjänats
int[] nextnode = new int[20];
Arrays.fill(nextnode, 50);
for (int i = 0; i < ds3.orders; i++) {
boolean notj;
int[] notja = new int[20];
Arrays.fill(notja, 50);
//Undviker att en otillåten ordning skapas då orderlistan optimeras.
//Ser med andra ord till att endast tomma hyllor används vid lämning
do {
notj = false;
mindiff = 1000000000;
for (int j = 0; j < ds3.orders; j++) {
boolean stopp = true;
for (int q = 0; q < nextnode.length; q++) {
//Ser till så onödiga beräkningar inte genomförs och på så sätt också onödiga diff räknas ut samt otillåtna kombinationer skapas
if (nextnode[q] == j || notja[q] == j) {
stopp = false;
}
}
if (stopp) {
diff = 0;
//Om första förflyttningen, kör från utlämningsplatsen
if (i == 0) {
//Erhåll start/stop nod
start = ds.shelfNode[0];
stop = ds.shelfNode[ds3.orderStart[j]];
if (start != stop) {
//System.out.println("Start " + start + " Stop " + stop);
//Planera via dijkstras färdvägen
path = op.createPlan(start, stop, 1, false);
//beräkna kostnaden för den optimala färdvägen mellan start och stop
for (int k = 0; k < path.size() - 1; k++) {
diff = diff + (int) Math.max(Math.abs(ds.nodeY[Integer.parseInt(path.get(k).getId()) - 1] - ds.nodeY[Integer.parseInt(path.get(k + 1).getId()) - 1]), Math.abs(ds.nodeX[Integer.parseInt(path.get(k).getId()) - 1] - ds.nodeX[Integer.parseInt(path.get(k + 1).getId()) - 1]));
//System.out.println("Integer.parseInt(path.get(k).getId()) " + Integer.parseInt(path.get(k).getId()));
}
} else if (start == stop && start == 24) {
diff = 0;
//System.out.println("Hej diff = 0 start");
}
} else {
//Om inte första gången, använd den senaste slutnoden som planerats
//System.out.println("i " + i);
//Erhåll start/stop nod
start = ds.shelfNode[ds4.orderEnd[i - 1]];
stop = ds.shelfNode[ds3.orderStart[j]];
if (start != stop) {
//System.out.println("Start " + start + " Stop " + stop);
//Planera via dijkstras färdvägen
path = op.createPlan(start, stop, 1, false);
//beräkna kostnaden för den optimala färdvägen mellan start och stop
for (int k = 0; k < path.size() - 1; k++) {
diff = diff + (int) Math.max(Math.abs(ds.nodeY[Integer.parseInt(path.get(k).getId()) - 1] - ds.nodeY[Integer.parseInt(path.get(k + 1).getId()) - 1]), Math.abs(ds.nodeX[Integer.parseInt(path.get(k).getId()) - 1] - ds.nodeX[Integer.parseInt(path.get(k + 1).getId()) - 1]));
//System.out.println("Integer.parseInt(path.get(k).getId()) " + Integer.parseInt(path.get(k).getId()));
}
} else if (start == stop && start == 24) {
diff = 0;
//System.out.println("Hej diff = 0 inte start");
}
}
System.out.println("Diff " + diff + " mindiff " + mindiff);
System.out.println("Start " + start + " stop " + stop);
System.out.println("i " + i + " j " + j);
if (diff < mindiff) {
//Kontrolerar att den valda start/stopp noden är ok med avseende på tomma/fulla hyllor
for (int k = 0; k < j - 1; k++) {
if (ds3.orderEnd[j] == ds3.orderStart[k]) {
notj = true;
notja[k] = j;
//System.out.println("CPCPCPCPCPCP! k " + k + " j " + j);
}
}
//System.out.println("Inne i mindiff");
mindiff = diff;
nextnode[i] = j;
ds4.orderStart[i] = ds3.orderStart[j];
ds4.orderEnd[i] = ds3.orderEnd[j];
//System.out.println(diff + " next node " + nextnode[i]);
//System.out.println("ds4.orderStart[i] " + ds4.orderStart[i]);
//System.out.println("ds4.orderEnd[i] " + ds4.orderEnd[i]);
}
}
}
} while (notj);
}
return ds4;
} |
d4bf9505-daaa-49c3-afe5-750ad1db367f | public DataStore onodigaforflytt(DataStore ds2) {
//Det här är bra skit, tar bort onödiga förflyttningar
boolean plockatorder = false;
for (int i = 0; i < ds3.orders; i++) {
System.out.println("\n\n\n" + "i " + i);
for (int j = i + 1; j < ds3.orders; j++) {
System.out.println("ds2.orderStart[j]\t" + ds2.orderStart[j]);
System.out.println("ds2.orderEnd[j]\t\t" + ds2.orderEnd[j]);
System.out.println(" j " + j);
if (ds2.orderStart[j] == ds2.orderEnd[i]) {
ds3.orderStart[j] = ds2.orderStart[i];
ds3.orderEnd[j] = ds2.orderEnd[j];
//Om onödig förflyttning tagits bort är det bra, därför ska man inte returnera ds2 :)
plockatorder = true;
break;
} else if (j == ds3.orders - 1) {
ds3.orderStart[i] = ds2.orderStart[i];
ds3.orderEnd[i] = ds2.orderEnd[i];
}
}
}
if (!plockatorder) {
return ds2;
}
return ds3;
} |
cce19b5b-6382-4c69-bca5-44e7d4b66ef4 | OverordnatSystem() {
ds = new DataStore();
DataStore ds2 = new DataStore();
DataStore ds4 = new DataStore();
DataStore ds5 = new DataStore();
DataStore ds6 = new DataStore();
ds3 = new DataStore();
//läser in lagernätet och orderlistan
ds.setFileName("C:/Users/Groggy/Documents/GitHub/bastaprojektarbetet/OverordnatSystem/Lagernatverk_20130213.csv");
ds.readNet();
ds.setFileName("C:/Users/Groggy/Documents/GitHub/bastaprojektarbetet/OverordnatSystem/orders_comb.csv");
ds.readOrders();
ds2.setFileName("C:/Users/Groggy/Documents/GitHub/bastaprojektarbetet/OverordnatSystem/orders1.csv");
ds2.readOrders();
ds5.setFileName("C:/Users/Groggy/Documents/GitHub/bastaprojektarbetet/OverordnatSystem/orders2.csv");
ds5.readOrders();
//startar det grafiska gränssnittet
cui = new ControlUI(ds);
cui.setVisible(true);
cui.showStatus();
GuiUpdate g1 = new GuiUpdate(ds, cui);
Thread t2 = new Thread(g1);
t2.start();
//Skriver ut den ej optimerade orderlistan
cui.jTextArea2.append("Ej optimerad orderlista:\n");
for (int j = 0; j < ds2.orders; j++) {
if (ds2.orderStart[j] != ds2.orderEnd[j]) {
cui.jTextArea2.append("" + ds2.orderStart[j]);
cui.jTextArea2.append(" " + ds2.orderEnd[j] + "\n");
System.out.println("");
}
}
cui.jTextArea4.append("Ej optimerad orderlista:\n");
for (int j = 0; j < ds5.orders; j++) {
if (ds5.orderStart[j] != ds5.orderEnd[j]) {
cui.jTextArea4.append("" + ds5.orderStart[j]);
cui.jTextArea4.append(" " + ds5.orderEnd[j] + "\n");
System.out.println("");
}
}
//Olika nödvändiga variabler tilldelas viktiga värden som de inte klarar sig utan
ds3.orders = ds2.orders;
ds3.fileName = ds2.fileName;
ds4.orders = ds2.orders;
ds4.fileName = ds2.fileName;
ds6.orders = ds5.orders;
ds6.fileName = ds5.fileName;
System.out.println("\n\n\n\n\n");
System.out.println("\n\n");
int start1 = 0, start2 = 0;
int stop1 = 0, stop2 = 0;
OptPlan op = new OptPlan(ds);
LinkedList<Vertex> path1 = null;
LinkedList<Vertex> path2;
//Optimerar orderlistan genom att ta bort onödiga förflyttningar och ordnar ordrarna på så sätt att avståndet som körs utan låda minimeras
ds6 = this.onodigaforflytt(ds5);
ds6 = this.optorderlista(ds6, op);
Arrays.fill(ds.notoknumber, 500);
ds3 = this.onodigaforflytt(ds2);
ds3 = this.optorderlista(ds3, op);
//skriv ut den optimerade orderlistan i orderlistafönstret
/*for(int i = 0; i < ds3.orders; i++) {
cui.jTextArea2.append(ds3.arcStart[i] + " " + ds3.arcEnd[i]);
}*/
//skriv ut den optimerade orderlistan i orderlistafönstret
cui.jTextArea2.append("Optimerad orderlista:\n");
for (int j = 0; j < ds3.orders; j++) {
if (ds3.orderStart[j] != ds3.orderEnd[j]) {
cui.jTextArea2.append("" + ds3.orderStart[j]);
cui.jTextArea2.append(" " + ds3.orderEnd[j] + "\n");
//System.out.println("");
cui.jTextArea2.setCaretPosition(cui.jTextArea2.getDocument().getLength());
}
}
cui.jTextArea4.append("Optimerad orderlista:\n");
for (int j = 0; j < ds6.orders; j++) {
if (ds6.orderStart[j] != ds6.orderEnd[j]) {
cui.jTextArea4.append("" + ds6.orderStart[j]);
cui.jTextArea4.append(" " + ds6.orderEnd[j] + "\n");
//System.out.println("");
cui.jTextArea4.setCaretPosition(cui.jTextArea4.getDocument().getLength());
}
}
System.out.println("\n\n");
//Loopa igenom orderlistan för att få fram GPS-koordinater till roboten
String GPS;
Arrays.fill(ds.arcColor, 0);
cui.repaint();
cui.jTextArea1.append("Optimering klar, tryck \"Start\" för att starta robotarna");
for (int i = 0; i < Math.max(ds3.orders, ds6.orders) + 1; i++) {
//stoppa roboten när den precis har lämnat en låda men bibehåll blåtands uppkopplingen
while (!ds.start) {
try {
Thread.sleep(5000);
} catch (Exception e) {
System.out.print(e.toString());
}
}
//Förflyttning mellan ordrar
GPS = "";
if (i == 0) {
//Om första, starta i A
start1 = ds.shelfNode[0];
stop1 = (int) ds.shelfNode[ds3.orderStart[i]];
start2 = ds.shelfNode[0];
stop2 = (int) ds.shelfNode[ds6.orderStart[i]];
cui.jTextArea3.setText("0 -> " + ds3.orderStart[i] + "\n");
cui.jTextArea5.setText("0 -> " + ds6.orderStart[i] + "\n");
} else {
//Annars starta där föregående flytt slutade
if (i < ds3.orders) {
start1 = (int) ds.shelfNode[ds3.orderEnd[i - 1]];
stop1 = (int) ds.shelfNode[ds3.orderStart[i]];
cui.jTextArea3.setText(ds3.orderEnd[i - 1] + " -> " + ds3.orderStart[i] + "\n");
} else {
start1 = stop1;
cui.jTextArea3.setText("Färdigt");
}
if (i < ds6.orders) {
start2 = (int) ds.shelfNode[ds6.orderEnd[i - 1]];
stop2 = (int) ds.shelfNode[ds6.orderStart[i]];
cui.jTextArea5.setText(ds6.orderEnd[i - 1] + " -> " + ds6.orderStart[i] + "\n");
} else {
start2 = stop2;
cui.jTextArea5.setText("Färdigt");
}
}
//Nollställer kartan
Arrays.fill(ds.arcColor, 0);
//Ser till att roboten står på rätt ställe på kartan som den gör i verkligheten så programlogiken pausas
ds.robot1X = ds.nodeX[start1 - 1];
ds.robot1Y = ds.nodeY[start1 - 1];
ds.robot2X = ds.nodeX[start2 - 1];
ds.robot2Y = ds.nodeY[start2 - 1];
//Uppdaterar kartan
cui.repaint();
if (start1 != stop1) {
path1 = op.createPlan(start1, stop1, 1, true);
//GPS = this.GPSkoordinater(path1, i, i);
} else if (start1 == stop1 && start1 == 24) {
GPS += "J";
}
boolean clear = false;
for (int j = 0; j < path1.size(); j++) {
if (Integer.parseInt(path1.get(i).getId()) == stop2) {
clear = true;
break;
}
}
if (clear) {
Arrays.fill(ds.notoknumber, 500);
Arrays.fill(ds.arcColor, 0);
}
if (start2 != stop2) {
path2 = op.createPlan(start2, stop2, 2, true);
//GPS = this.GPSkoordinater(path2, i, i);
} else if (start2 == stop2 && start2 == 24) {
GPS += "J";
}
if (start1 != stop1 && clear) {
path1 = op.createPlan(start1, stop1, 1, true);
//GPS = this.GPSkoordinater(path1, i, i);
} else if (start1 == stop1 && start1 == 24 && clear) {
GPS += "J";
}
//Skriver ut vad som ska skickas till roboten
//cui.jTextArea1.append("\nGPS utan låda:\n" + GPS + "\n\n");
//System.out.println("GPS.längd " + GPS.length() + "\n");
cui.jTextArea1.setCaretPosition(cui.jTextArea1.getDocument().getLength());
//Måla om kartan så roboten står på rätt ställe och planerad färdväg är målas röd
ds.robot1X = ds.nodeX[start1 - 1];
ds.robot1Y = ds.nodeY[start1 - 1];
ds.robot2X = ds.nodeX[start2 - 1];
ds.robot2Y = ds.nodeY[start2 - 1];
cui.repaint();
//Simuleringsskit
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
System.out.println("Fel");
}
//}
//Nollställ kartan
Arrays.fill(ds.arcColor, 0);
Arrays.fill(ds.notoknumber, 500);
//Räkna ut förflyttning av LÅDA!
GPS = "";
if (i < ds3.orders) {
start1 = (int) ds.shelfNode[ds3.orderStart[i]];
stop1 = (int) ds.shelfNode[ds3.orderEnd[i]];
cui.jTextArea3.setText(ds3.orderStart[i] + " -> " + ds3.orderEnd[i] + "\n");
} else {
start1 = stop1;
cui.jTextArea3.setText("Färdigt");
}
if (i < ds6.orders) {
start2 = (int) ds.shelfNode[ds6.orderStart[i]];
stop2 = (int) ds.shelfNode[ds6.orderEnd[i]];
cui.jTextArea5.setText(ds6.orderStart[i] + " -> " + ds6.orderEnd[i] + "\n");
} else {
start2 = stop2;
cui.jTextArea5.setText("Färdigt");
}
//Samma som för förflyttning utan låda
if (start1 != stop1) {
path1 = op.createPlan(start1, stop1, 1, true);
//GPS = this.GPSkoordinater(path1, i, i);
} else if (start1 == stop1 && start1 == 24) {
GPS += "J";
}
if (start2 != stop2) {
path2 = op.createPlan(start2, stop2, 2, true);
//GPS = this.GPSkoordinater(path2, i, i);
} else if (start2 == stop2 && start2 == 24) {
GPS += "J";
}
//Samma som för förflyttning utan låda
//cui.jTextArea1.append("\nGPS med låda:\n" + GPS + "\n\n");
//System.out.println("GPS.längd " + GPS.length() + "\n");
cui.jTextArea1.setCaretPosition(cui.jTextArea1.getDocument().getLength());
//Samma som för förflyttning utan låda
ds.robot1X = ds.nodeX[start1 - 1];
ds.robot1Y = ds.nodeY[start1 - 1];
ds.robot2X = ds.nodeX[start2 - 1];
ds.robot2Y = ds.nodeY[start2 - 1];
cui.repaint();
//Simuleringstrams
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
System.out.println("Fel");
}
//}
//Nollställer kartan
Arrays.fill(ds.arcColor, 0);
Arrays.fill(ds.notoknumber, 500);
//Ser till att roboten står på rätt ställe på kartan som den gör i verkligheten så programlogiken pausas
ds.robot1X = ds.nodeX[stop1 - 1];
ds.robot1Y = ds.nodeY[stop1 - 1];
ds.robot2X = ds.nodeX[stop2 - 1];
ds.robot2Y = ds.nodeY[stop2 - 1];
//Uppdaterar kartan
cui.repaint();
}
} |
1cb4b114-a620-4269-acc5-b10faf943c2e | public static void main(String[] args) {
// TODO code application logic here
OverordnatSystem x = new OverordnatSystem();
} |
a829bca5-73e4-43f8-846c-2070011eb4e9 | public Graph(List<Vertex> vertexes, List<Edge> edges) {
this.vertexes = vertexes;
this.edges = edges;
} |
4bed3dc2-0e5e-40a9-b0bd-20b420ba85c2 | public List<Vertex> getVertexes() {
return vertexes;
} |
e1677ad2-7b8a-41fc-9804-5d7893797819 | public List<Edge> getEdges() {
return edges;
} |
339f0e23-09dd-495c-b6e6-b7af302ab643 | public static void main( String[] args )
{
System.out.println( "Hi hello hello hello" );
tst1();
tst2();
} |
7a88e09d-21c1-438a-bb15-963064154feb | public static void tst1() {
TrackDto trackDto = new TrackDto();
List<Track> tracks1 = trackDto.getAllTracks();
for (Track track : tracks1) {
System.out.println(track);
}
System.out.println("------");
Track track11 = trackDto.getTrackByTitle("One");
System.out.println(track11);
System.out.println("------");
Track track12 = trackDto.getTrackById(12);
System.out.println(track12);
System.out.println("------");
Track track22 = new Track(22,"Jude","Beatles");
Track track23 = new Track(23,"Submarine","Beatles");
String result20 = trackDto.createTrack(track22);
System.out.println(result20);
result20 = trackDto.createTrack(track23);
System.out.println(result20);
tracks1 = trackDto.getAllTracks();
for (Track track : tracks1) {
System.out.println(track);
}
System.out.println("------");
Track track24 = new Track(13,"1999","Pineapples");
result20 = trackDto.updateTrack(track24);
System.out.println(result20);
trackDto.deleteTrackById(12);
tracks1 = trackDto.getAllTracks();
for (Track track : tracks1) {
System.out.println(track);
}
System.out.println("------");
} |
3e48a863-aaab-4e6e-ba96-3965dce1a042 | public static void tst2() {
PassReqApi reqApi = new PassReqApi();
System.out.println("sending post request");
String response = reqApi.sendingPost("023");
System.out.println(response);
System.out.println("------");
} |
6c5ecd54-8c14-40ad-829d-2940ae3517a9 | public Track() {
super();
} |
83c34cd6-aa76-43a9-abc1-49e83227c74b | public Track(Integer id, String title, String singer) {
super();
this.id = id;
this.title = title;
this.singer = singer;
} |
7fc12acd-9a13-46c2-b9b4-305ea6baf602 | public Integer getId() {
return id;
} |
cec8fba2-e549-4e79-8726-62c46a074886 | public void setId(Integer id) {
this.id = id;
} |
d9133b1d-c557-4bef-894f-bdfb2843c63a | public String getTitle() {
return title;
} |
cbfce0ce-06bb-4ffe-8955-c4829b1ec5ed | public void setTitle(String title) {
this.title = title;
} |
32fda37b-ce85-4cde-a508-d0723d80a9fb | public String getSinger() {
return singer;
} |
be47878e-f424-4164-9c4e-02ac8ceda8c3 | public void setSinger(String singer) {
this.singer = singer;
} |
a9020639-2726-491b-80a5-acad8a6a16e9 | @Override
public String toString() {
return "Track [ id=" + id + ", title=" + title + ", singer=" + singer + " ]";
} |
f417bfd3-4ad5-478d-88c8-7de0b0ff5b34 | public List<Track> getAllTracks() {
List<Track> trackList = new ArrayList<Track>();
for (Object value : tracks.values()) {
Track track = (Track)value;
trackList.add(track);
}
return trackList;
} |
474f3275-704f-4c70-91c8-40a6f4dcad4e | public Track getTrackById(Integer id) {
Track track = tracks.get(id);
return track;
} |
37c2be4d-7046-4f17-aae9-50b3df4c97ea | public Track getTrackByTitle(String name) {
for (Object value : tracks.values()) {
Track track = (Track)value;
if (name.equals(track.getTitle())) {
return track;
}
}
return null;
} |
87aeb18a-7dd3-4846-a0b3-19ccd4ad41c1 | public String createTrack(Track track) {
tracks.put(track.getId(), track);
String result = "Track saved : " + track;
return result;
} |
69d43854-135d-4724-9590-ef57ee9810e8 | public void deleteTrackById(Integer id) {
tracks.remove(id);
} |
4ed31e83-0004-4961-8026-56a68b6a437b | public String updateTrack(Track track) {
tracks.put(track.getId(), track);
String result = "Track updated : " + track;
return result;
} |
bab27445-f6ba-423d-921b-e40f1406e941 | public String getMorning(String msg) {
String output = "Good Morning " + msg;
return output;
} |
4017a10e-1f30-4a86-bd06-65edbbde19ee | public String getAfternoon(String msg) {
String output = "Good Afternoon " + msg;
return output;
} |
51939e78-9255-42de-af05-fb6f60b2607e | public ReqRunnable(String pid) {
this.pid = pid;
} |
8c54e6fa-b2fe-412d-abbd-52a70134a8bb | public void run() {
String response = "server not available";
try {
response = sendPost(pid);
} catch (Exception e) {
//e.printStackTrace();
}
System.out.println(response);
System.out.println("------");
} |
6025b361-3c5c-4036-b0c6-3fedf814e959 | public String sendingPost(String pid) {
String result = "message with pid "+pid+" was sent";
try {
ReqRunnable myRunnable = new ReqRunnable(pid);
Thread t = new Thread(myRunnable);
t.start();
} catch (Exception e) {
//e.printStackTrace();
}
return result;
} |
a43c5b6a-ce30-4a25-866d-007c4f870f0c | private String sendPost(String pid) throws Exception {
String url = "http://localhost:4567/person/"+pid;
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
Thread.sleep(3000);
//add reuqest header
con.setRequestMethod("POST");
con.setRequestProperty("User-Agent", USER_AGENT);
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
con.setRequestProperty("Content-Type", "application/json");
String urlParameters = "{ \"fname\": \"marco\", \"lname\": \"polo\", \"zip\": \"23844\" }";
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
System.out.println("Sending 'POST' request to URL : " + url);
System.out.println("Post parameters : " + urlParameters);
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
return response.toString();
} |
42f092a4-10a4-4b7b-9638-c2ff4c5b3ff3 | public AppTest( String testName )
{
super( testName );
System.out.println("starting AppTest");
} |
41f78826-4bf2-4ef7-9eb1-176d9f4291b0 | public static Test suite()
{
return new TestSuite( AppTest.class );
} |
76949af9-ad08-4607-9c94-ace76179a5dc | public void testApp()
{
assertTrue( true );
} |
356da1d7-55a7-45d7-9156-ddea7c0dfea2 | public SubSketch1(EmbeddedSketch parent, int xOrigin, int yOrigin,
int width, int height) {
mySketch = parent;
myXOrigin = xOrigin;
myYOrigin = yOrigin;
myWidth = width;
myHeight = height;
} |
5f062bf7-e82c-4e19-adbb-832a81df1873 | public void setup() {
defaultFontSize = 12;
font = mySketch.createFont("Helvetica", defaultFontSize);
mySketch.textFont(font);
searchX = myXOrigin + 20;
searchY = myYOrigin + 30;
tagsOfInterestX = searchX;
tagsOfInterestY = searchY + 30;
textFieldX = (int) (searchX + 65);
textFieldY = (int) searchY - 15;
textFieldWidth = (int) (myWidth / (float) 1.5);
textFieldHeight = (int) (defaultFontSize * 1.75);
ddlX = myXOrigin + 20;
ddlY = (int) tagsOfInterestY + 30;
ddlWidth = 140;
ddlHeight = 25;
highlightColor = 200;
cp5 = new ControlP5(mySketch);
tagSearchField = cp5.addTextfield("input")
.setPosition(textFieldX, textFieldY)
.setSize(textFieldWidth, textFieldHeight).setFont(font)
.setFocus(true).setColor(mySketch.color(0, 0, 0))
.setColorActive(mySketch.color(highlightColor))
.setColorCursor(mySketch.color(highlightColor))
.setColorBackground(mySketch.color(255));
} |
0dfed5f1-326a-425e-a0fb-f86d740a7824 | public void draw() {
drawTexts();
} |
7a70f641-688b-4393-948b-f9edb144a273 | public void keyPressed() {
if (tagSearchField.isActive()) {
// Re-Draw...
mySketch.loop();
}
} |
92ba318a-e19e-408a-9598-8c2ec26ca659 | private void drawTexts() {
mySketch.fill(0);
mySketch.textAlign(PApplet.LEFT);
mySketch.textSize(15);
String text = "Search:";
mySketch.text(text, searchX, searchY);
mySketch.textSize(12);
text = "Tags of Interest:";
mySketch.text(text, tagsOfInterestX, tagsOfInterestY);
} |
e8fe0a9f-9e93-4a24-b0f8-49cb6228d185 | public void input(String theText) {
theText = theText.toLowerCase();
usefulQuestions = QeAData.getQuestionToTags();
if (lists.size() != 0) {
clearList();
}
ArrayList<Integer> keys = new ArrayList<Integer>(QeAData
.getTagDictionary().keySet());
ArrayList<String> values = new ArrayList<String>(QeAData
.getTagDictionary().values());
int index = values.indexOf(theText);
if (index >= 0) {
int tagId = keys.get(index);
selectedTags.add(tagId);
selectedTagsNames.add(QeAData.getTagDictionary().get(tagId));
updateUsefulQuestions(tagId);
addDropDownList(tagId, relatedTags);
disableDDL(lists.size() - 1, tagId);
createRelatedTags();
addDropDownList(tagId, relatedTags);
}
} |
7364febb-6e49-4879-ba75-8cc2a6426dab | public void controlEvent(ControlEvent theEvent) {
if (theEvent.isGroup()) {
int tagId = (int) theEvent.getValue();
selectedTags.add(tagId);
selectedTagsNames.add(QeAData.getTagDictionary().get(tagId));
updateUsefulQuestions(tagId);
createRelatedTags();
// Disable the last list
disableDDL(lists.size() - 1, tagId);
if (relatedTags.size() > 0) {
// Add a new list
addDropDownList(tagId, relatedTags);
}
}
QeAData.setTagList(selectedTags, selectedTagsNames);
} |
45ce42b3-ac0c-494f-9e3d-339ff3d983b5 | private void addDropDownList(int tagId, ArrayList<Integer> newTags) {
float x = ddlX + ddlWidth + 10;
float y = ddlY;
// Create the new DropdownList
PFont font2 = mySketch.createFont("Helvetica", defaultFontSize);
DropdownList newD = cp5
.addDropdownList("Select Another Tag " + (lists.size() + 1))
.setLabel("Select Another Tag").setPosition(x, y)
.setBarHeight(20).setWidth(ddlWidth).setHeight((int)(myHeight - y + 30))
.setItemHeight(16).setColorBackground(mySketch.color(235))
.setColorForeground(mySketch.color(highlightColor))
.setColorLabel(0);
newD.getCaptionLabel().toUpperCase(false).setLetterSpacing(3)
.setFont(font2).setColor(0);
// Add the new tags
for (int tag : newTags) {
newD.addItem(QeAData.getTagDictionary().get(tag), tag);
}
// Add the list
lists.add(newD);
} |
be377a15-fa17-4aa4-b64a-d31e09659773 | private void disableDDL(int index, int tagId) {
// Set the TAG in the Tags of Interest list position
float newX = ddlX;
float newY = ddlY + ddlHeight * index;
lists.get(index).setPosition(newX, newY);
// Disable list
lists.get(index).disableCollapse();
// Set its name
lists.get(index).setLabel(QeAData.getTagDictionary().get(tagId));
} |
8c03d504-417e-4fa8-9bac-34899bb0c0ca | public void clearList() {
for (DropdownList list : lists) {
list.remove();
}
lists.clear();
relatedTags.clear();
selectedTags.clear();
selectedTagsNames.clear();
} |
c9c9b497-748a-4bd7-b93c-e5e50079d6ce | private void updateUsefulQuestions(Integer newTag) {
Hashtable<Integer, ArrayList<Integer>> result = new Hashtable<Integer, ArrayList<Integer>>();
for (int question : QeAData.getTagToQuestions().get(newTag)) {
if (usefulQuestions.keySet().contains(question)) {
result.put(question, usefulQuestions.get(question));
}
}
usefulQuestions = result;
} |
d1dcd65d-0d1b-4dc8-a861-dbb5169fc1a5 | private void createRelatedTags() {
relatedTags = new ArrayList<Integer>();
for (int question : usefulQuestions.keySet()) {
addRelatedTag(usefulQuestions.get(question));
}
} |
f3c90edb-dc7b-4a60-8271-c397f482697f | private void addRelatedTag(ArrayList<Integer> tagList) {
for (int tag : tagList) {
if (!selectedTags.contains(tag) && !relatedTags.contains(tag)) {
relatedTags.add(tag);
}
}
} |
5646b402-17da-4cd3-a0b5-c0d15598d16b | public void setup() {
try {
QeAData.setPApplet(this);
QeAData.readTagLinksFile();
QeAData.readTagDictionaryFile();
QeAData.readPostTagsFile();
// The QuestionData and QuestionAnswers are read by demand, but
// after demanded the first time, they are completely stored in
// memory as the others.
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
size(1200, 801);
setLayout(new GridLayout(2, 0));
mainFont = loadFont("Purisa-Bold-48.vlw");
textFont(MainTutorQeA.mainFont);
SketchPanel spTop = new SketchPanel(this, SKETCH_TOP);
spTop.setBounds(0, 0, 1250, 450);
add(spTop);
SKETCH_TOP.setIsActive(true);
SKETCH_TOP.setParentSketch(this);
SketchPanel spBottom = new SketchPanel(this, SKETCH_BOTTOM);
spBottom.setBounds(0, 450, 1250, 400);
add(spBottom);
SKETCH_BOTTOM.setIsActive(true);
SKETCH_BOTTOM.setParentSketch(this);
} |
22d13f2d-5310-4ae2-922a-5dd2857758e3 | @SuppressWarnings("unchecked")
public QuestionData(int id, String title, ArrayList<Float> values,
int cluster) {
if (values.size() <= 0
|| values.size() != QuestionData.featureNames.size()) {
throw new RuntimeException(
"The Values and Names of the features are not of the same size or are empty!");
}
this.id = id;
this.title = title;
this.cluster = cluster;
featureValues = (ArrayList<Float>) values.clone();
} |
7339cbd3-14ab-43fa-8d53-5619ee3a9c3d | @SuppressWarnings("unchecked")
public static void setFeatureNames(ArrayList<String> featureNames) {
QuestionData.featureNames = (ArrayList<String>) featureNames.clone();
} |
cc3d2c7a-f37d-4656-bce3-84e2f6c27e54 | @SuppressWarnings("unchecked")
public static void setFeaturePostNames(ArrayList<String> featurePostNames) {
QuestionData.featurePostNames = (ArrayList<String>) featurePostNames
.clone();
} |
17228ecf-9b84-4507-b31b-62cba1e50efd | public static void setSortByIndex(int sortByIndex) {
if (sortByIndex < QuestionData.featureNames.size()) {
QuestionData.sortByIndex = sortByIndex;
} else {
throw new RuntimeException(
"The sortByIndex is larger than the amount of features!");
}
} |
f4ac4634-9ac3-42f9-aa70-55314e7b6dd6 | public static String getFeatureNameOfSortIndex() {
return QuestionData.featureNames.get(sortByIndex);
} |
27b9f357-1552-496b-8cc5-28e5959840e6 | public static String getFeaturePostNameOfSortIndex() {
return QuestionData.featurePostNames.get(sortByIndex);
} |
c84b091b-217c-4ba4-9cc9-eae78595e08c | public static ArrayList<String> getFeatureNames() {
return QuestionData.featureNames;
} |
186f3d62-9703-46f7-b34d-a71d8ed6b014 | public static ArrayList<String> getFeaturePostNames() {
return featurePostNames;
} |
ec826dd8-684f-4c8b-ac1d-49be45c2093b | public static int getSortByIndex() {
return sortByIndex;
} |
02784ca1-e8b6-4d23-b914-6f5bbd90e002 | public int getId() {
return id;
} |
03ab677d-5fe4-4ca7-996c-cc31666951e8 | public String getTitle() {
return title;
} |
93a6dce1-fca6-4129-b99f-02f31c1a6b1d | public int getCluster() {
return cluster;
} |
4d15d4d6-dd94-4d5f-a7a1-60b207974e9d | public ArrayList<Float> getFeatureValues() {
return featureValues;
} |
259cc49f-5c38-4fbc-b1fc-c38ac646b821 | public Float getFeatureValueByName(String name) {
Float result = null;
for (int i = 0; i < QuestionData.featureNames.size(); i++) {
if (QuestionData.featureNames.get(i).equals(name)) {
result = featureValues.get(i);
break;
}
}
if (result == null) {
throw new RuntimeException("Unexistent FeatureName: " + name + ".");
}
return result;
} |
b8cba05e-8b14-4653-b8de-ea57d86c64bc | public Float getFeatureValueOfSortIndex() {
return featureValues.get(sortByIndex);
} |
780c3b3c-fcd4-4bc9-9a72-0e277a51373a | @Override
public int compareTo(QuestionData other) {
float diff = other.getFeatureValueOfSortIndex()
- this.getFeatureValueOfSortIndex();
if (diff == 0) {
return other.getTitle().compareTo(this.getTitle());
} else {
return (int) (diff * 1000000);// Decimal precision
}
} |
bce22a4a-c88c-4398-9430-526b3776a4dd | @Override
public String toString() {
return this.getId() + " - " + this.getFeatureValueOfSortIndex();
} |
63ab9323-2675-4875-99e3-c68153fe0682 | public CentroidData(int clusterId, int numFeatures) {
this.clusterId = clusterId;
questionIds = new ArrayList<Integer>();
sumAttributeValues = new ArrayList<Float>();
for (int i = 0; i < numFeatures; i++) {
sumAttributeValues.add((float) 0.0);
}
} |
d9cf466b-ef9c-40a7-b635-c9014b7cc117 | public void addQuestion(QuestionData qData) {
questionIds.add(qData.getId());
for (int i = 0; i < qData.getFeatureValues().size(); i++) {
sumAttributeValues.set(i, sumAttributeValues.get(i)
+ qData.getFeatureValues().get(i));
}
} |
808ce96a-8344-4ed8-9e08-7d3e64e01f6f | public int getClusterId() {
return clusterId;
} |
9bb83bbb-e21b-4f1b-9557-76330d57f35d | public ArrayList<Integer> getQuestionIds() {
return questionIds;
} |
ad77cc9b-ed13-4af5-9d07-065cacd0d0e5 | public int getClusterSize() {
return questionIds.size();
} |
dc8188d2-2c93-481d-9d79-6a23fd35481d | public float getMeanByIndex(int index) {
return (getClusterSize() > 0) ? this.sumAttributeValues.get(index)
/ getClusterSize() : 0;
} |
b76db6de-ee83-4571-883e-336366ad3f2b | public AnswerData(int id, int score, Date creationDate) {
this.id = id;
this.score = score;
this.creationDate = creationDate;
} |
6c1cf5c2-8372-4786-a12c-471481033689 | public AnswerData(int id, int score, Date creationDate, int commentsCount, boolean isAccepted) {
this.id = id;
this.score = score;
this.creationDate = creationDate;
this.commentsCount = commentsCount;
this.isAccepted = isAccepted;
} |
314684ce-926f-4d50-81d6-a17f00a61183 | public int getCommentsCount() {
return commentsCount;
} |
516b64cd-8075-491e-b50e-d5d326c06b54 | public boolean isAccepted() {
return isAccepted;
} |
7791f673-d9b8-4db1-a623-bf81812c70c6 | public int getId() {
return id;
} |
2a1b64e3-b91d-4eb3-aa85-e31e02cab301 | public Date getCreationDate() {
return creationDate;
} |
1a7a113a-6ba8-454b-9e5f-1b601488e980 | public int getScore() {
return score;
} |
1a36d3b8-c733-421d-84b3-fd3bd725c5ed | @SuppressWarnings("unchecked")
public static void setTagList(ArrayList<Integer> tagList,
ArrayList<String> tagNameList) {
if (tagList.size() == tagNameList.size()
&& !tagList.equals(chosenTagIds)) {
// CLEAR everything
chosenTagIds.clear();
chosenTagNames.clear();
chosenQuestions.clear();
centroidIdsToData.clear();
ArrayList<Integer> nextChosenQuestions;
int tagId;
String tagName;
for (int i = 0; i < tagList.size(); i++) {
tagId = tagList.get(i);
tagName = tagNameList.get(i);
if (!tagToQuestions.containsKey(tagId)) {
System.err.println("Unexistent Tag ID: " + tagList);
System.exit(1);
}
chosenTagIds.add(tagId);
chosenTagNames.add(tagName);
int qId;
// If there is any chosen question
if (!chosenQuestions.isEmpty()) {
nextChosenQuestions = new ArrayList<Integer>();
for (int j = 0; j < chosenQuestions.size(); j++) {
qId = chosenQuestions.get(j);
// For each old question check if it contains the new
// tag and remove it if doesn't
if (questionToTags.get(qId).contains(tagId)) {
nextChosenQuestions.add(qId);
}
}
chosenQuestions = (ArrayList<Integer>) nextChosenQuestions
.clone();
if (chosenQuestions.isEmpty()) {
// Avoiding the repetition of the emptiness initial
// condition below...
break;
}
} else {
chosenQuestions = (ArrayList<Integer>) tagToQuestions.get(
tagId).clone();
}
}
// READ THE QUESTION_DATA file if it was not read yet...
if (questionIdsToData.size() == 0) {
try {
readQuestionsDataFile();
} catch (IOException e) {
System.err.println("Error reading the QUESTION_DATA_FILE!");
}
}
// Define the Centroids Data (based on the QuestionData)
QuestionData questionDataTmp;
for (Integer qId : chosenQuestions) {
questionDataTmp = questionIdsToData.get(qId);
if (!centroidIdsToData
.containsKey(questionDataTmp.getCluster())) {
centroidIdsToData.put(questionDataTmp.getCluster(),
new CentroidData(questionDataTmp.getCluster(),
QuestionData.getFeatureNames().size()));
}
// TODO: Change this! The addQuestion will receive the
// questionDataTmp and will iterate over the values summing up
// The names are going to be the same of QuestionData and all
// the other classes that uses the features, should do it
// anonymously
centroidIdsToData.get(questionDataTmp.getCluster())
.addQuestion(questionDataTmp);
}
}
} |
00f383b3-5ed9-480c-9068-513cd71b60a8 | public static ArrayList<Integer> getQuestionIdsByCluster(int cluster) {
ArrayList<Integer> clusterQuestions = new ArrayList<Integer>();
for (Integer qId : chosenQuestions) {
if (questionIdsToData.get(qId).getCluster() == cluster) {
clusterQuestions.add(qId);
}
}
return (clusterQuestions);
} |
3f802aef-6f45-4feb-aa32-c0147cb31c37 | @SuppressWarnings("unchecked")
public static void readPostTagsFile() throws IOException {
String[] reader = pApplet.loadStrings(POST_TAGS_FILE);
int question, tag;
ArrayList<Integer> tmpList;
// Reads the file header
for (int i = 1;i<reader.length;i++) {
String[] nextLine = reader[i].replace("\"", "").split(",");
question = Integer.valueOf(nextLine[0]);
tag = Integer.valueOf(nextLine[1]);
// TAG -> QUESTIONS
if (tagToQuestions.containsKey(tag)) {
tmpList = tagToQuestions.get(tag);
if (tmpList == null) {
tmpList = new ArrayList<Integer>();
}
} else {
tmpList = new ArrayList<Integer>();
}
tmpList.add(question);
tagToQuestions.put(tag, ((ArrayList<Integer>) tmpList.clone()));
// QUESTIONS -> TAG
if (questionToTags.containsKey(question)) {
tmpList = questionToTags.get(question);
if (tmpList == null) {
tmpList = new ArrayList<Integer>();
}
} else {
tmpList = new ArrayList<Integer>();
}
tmpList.add(tag);
questionToTags
.put(question, ((ArrayList<Integer>) tmpList.clone()));
}
} |
a967ca91-80ff-444d-b255-1bed230e4925 | public static void readTagLinksFile() throws IOException {
String[] reader = pApplet.loadStrings(TAG_LINKS_FILE);
for (int i = 1;i<reader.length;i++) {
String[] nextLine = reader[i].replace("\"", "").split(",");
int key = Integer.valueOf(nextLine[0]);
if (tagLinks.containsKey(key)) {
tagLinks.put(Integer.valueOf(nextLine[0]),
tagLinks.get(Integer.valueOf(nextLine[0])) + ","
+ nextLine[1]);
} else {
tagLinks.put(Integer.valueOf(nextLine[0]), nextLine[1]);
}
}
} |
42ac4111-d340-4e8f-b1fe-65516db2f342 | public static void readTagDictionaryFile() throws IOException {
String[] reader = pApplet.loadStrings(TAGS_FILE);
for (int i = 1;i<reader.length;i++) {
String[] nextLine = reader[i].replace("\"", "").split(",");
tagDictionary.put(Integer.valueOf(nextLine[0]), nextLine[1]);
}
} |
c6f2863a-eadf-4a69-bd31-765f5899b3a5 | public static void readQuestionsDataFile() throws IOException {
String[] reader = pApplet.loadStrings(QUESTIONS_DATA_FILE);
// Unique columns used... At this moment...
int questionId, cluster;
String title;
ArrayList<Float> values = new ArrayList<Float>();
ArrayList<String> names = new ArrayList<String>();
ArrayList<String> postNames = new ArrayList<String>();
// Reads the file header and set the names
String[] nextLine = parseQuestion(reader[0].replace("\"",""));
names.add(nextLine[2]);
names.add(nextLine[3]);
names.add(nextLine[4]);
names.add(nextLine[5]);
QuestionData.setFeatureNames(names);
// Set the postNames (HARDCODED...)
postNames.add("votes");
postNames.add("answers");
postNames.add("points");
postNames.add("points");
QuestionData.setFeaturePostNames(postNames);
// Set the initial index of the feature to sort by
QuestionData.setSortByIndex(0);
// Read the data
for (int i = 1;i<reader.length;i++) {
nextLine = parseQuestion(reader[i].replace("\"",""));
questionId = Integer.valueOf(nextLine[0]);
title = nextLine[1];
values.add(Float.valueOf(nextLine[2]));
values.add(Float.valueOf(nextLine[3]));
values.add(Float.valueOf(nextLine[4]));
values.add(Float.valueOf(nextLine[5]));
cluster = Integer.valueOf(nextLine[6]);
questionIdsToData.put(questionId, new QuestionData(questionId,
title, values, cluster));
values.clear();
}
} |
1638d779-de53-4b71-828b-cf9897ce7f8e | public static void readQuestionAnswersFile() throws IOException,
ParseException {
// Unique features used... At this moment...
int questionId;
int answerId;
int score;
Date creationDate;
int answerCommentsCount;
boolean isAccepted;
DateFormat format = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
String[] reader = pApplet.loadStrings(QUESTION_ANSWERS_FILE);
// Reads the file header
for (int i = 1;i<reader.length;i++) {
String[] nextLine = reader[i].replace("\"", "").split(",");
questionId = Integer.valueOf(nextLine[0]);
answerId = Integer.valueOf(nextLine[1]);
score = Integer.valueOf(nextLine[2]);
creationDate = format.parse(nextLine[3]);
answerCommentsCount = Integer.valueOf(nextLine[4]);
isAccepted = Boolean.parseBoolean(nextLine[5].toLowerCase());
if (!questionIdsToAnswers.containsKey(questionId)) {
questionIdsToAnswers.put(questionId,
new ArrayList<AnswerData>());
}
questionIdsToAnswers.get(questionId).add(
new AnswerData(answerId, score, creationDate,
answerCommentsCount, isAccepted));
}
} |
fa72b0db-3be0-415c-9db4-efc08737a575 | private static String[] parseQuestion(String line){
String[] result = new String[7];
String workingLine = line;
int index;
for (int i = 6; i>1;i--){
index = workingLine.lastIndexOf(",");
result[i] = workingLine.substring(index+1, workingLine.length());
workingLine = workingLine.substring(0, index);
}
index = workingLine.indexOf(",");
result[0] = workingLine.substring(0, index);
workingLine = workingLine.substring(index+1, workingLine.length());
result[1] = workingLine;
return result;
} |
ef7c33a2-24e8-4ae1-9d46-0084d822ed52 | public static Hashtable<Integer, ArrayList<Integer>> getTagToQuestions() {
return tagToQuestions;
} |
cc06206d-72bd-4ce2-9471-d0f10095fc8a | public static Hashtable<Integer, ArrayList<Integer>> getQuestionToTags() {
return questionToTags;
} |
17aa0faa-da5e-4806-97f1-54db764dacfb | public static Hashtable<Integer, QuestionData> getQuestionIdsToData() {
return questionIdsToData;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.