[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-schemafuzz] branch master updated: Finished clearing
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-schemafuzz] branch master updated: Finished clearing the code, also fixed the same value mutation bugg |
Date: |
Wed, 23 May 2018 13:02:23 +0200 |
This is an automated email from the git hooks/post-receive script.
erwan-ulrich pushed a commit to branch master
in repository schemafuzz.
The following commit(s) were added to refs/heads/master by this push:
new 9fa28db Finished clearing the code, also fixed the same value
mutation bugg
9fa28db is described below
commit 9fa28dbab49b88227d27ee9709193d4a3dfc089d
Author: Feideus <address@hidden>
AuthorDate: Wed May 23 13:02:14 2018 +0200
Finished clearing the code, also fixed the same value mutation bugg
---
src/main/java/org/schemaspy/DBFuzzer.java | 95 ++++------
src/main/java/org/schemaspy/Main.java | 5 +-
src/main/java/org/schemaspy/model/GenericTree.java | 47 +++--
.../java/org/schemaspy/model/GenericTreeNode.java | 204 ++++++++++++---------
.../java/org/schemaspy/model/QueryResponse.java | 14 +-
.../org/schemaspy/model/QueryResponseParser.java | 6 +-
.../java/org/schemaspy/model/SingleChange.java | 29 +--
7 files changed, 201 insertions(+), 199 deletions(-)
diff --git a/src/main/java/org/schemaspy/DBFuzzer.java
b/src/main/java/org/schemaspy/DBFuzzer.java
index f65602d..da6bfea 100644
--- a/src/main/java/org/schemaspy/DBFuzzer.java
+++ b/src/main/java/org/schemaspy/DBFuzzer.java
@@ -52,7 +52,7 @@ public class DBFuzzer
}
- //Evalutation
+ //Evaluation
try
{
int mark;
@@ -87,9 +87,11 @@ public class DBFuzzer
Row randomRow = pickRandomRow();
GenericTreeNode currentMutation = new
GenericTreeNode(randomRow,nextId());
currentMutation.setChosenChange(currentMutation.getPotential_changes().get(0));
+ currentMutation.initPostChangeRow();
mutationTree.setRoot(currentMutation);
- processFirstMutation(currentMutation);
+ if(!processFirstMutation(currentMutation))
+ return false;
/*
* Main loop. Picks and inject a mutation chosen based on its weight
(currently equal to its mark)
* After injecting and retrieving the marking for the evaluator,
@@ -99,7 +101,7 @@ public class DBFuzzer
{
//Choosing next mutation
currentMutation = chooseNextMutation();
- while(!this.isNewMutation(currentMutation,mutationTree.getRoot()))
+ while(!this.isNewMutation(currentMutation))
{
System.out.println("this GenericTreeNode has already been tried ");
currentMutation = chooseNextMutation();
@@ -299,80 +301,57 @@ public class DBFuzzer
*/
public GenericTreeNode chooseNextMutation()
{
- GenericTreeNode nextMut = null;
- GenericTreeNode previousMutation = mutationTree.getLastMutation();
- int markingDiff = previousMutation.getInterest_mark();
- Random rand = new Random();
-
-
- if(mutationTree.getNumberOfNodes() > 1) // first mutation does;n;t have
a predecessor
- {
- markingDiff =
previousMutation.getInterest_mark()-mutationTree.find(mutationTree.getLastId()).getInterest_mark();
- }
-
+ GenericTreeNode nextMut = null;
+ GenericTreeNode previousMutation = mutationTree.getLastMutation();
+ int markingDiff = previousMutation.getInterest_mark();
+ Random rand = new Random();
- if(mutationTree.getRoot() != null)
- {
- if(markingDiff > 0) //
+ if (mutationTree.getNumberOfNodes() > 1) // first mutation does;n;t
have a predecessor
{
- int randNumber =
rand.nextInt(previousMutation.getPotential_changes().size());
- nextMut = new
GenericTreeNode(previousMutation.getPost_change_row(),nextId(),mutationTree.getRoot(),previousMutation);
-
nextMut.setChosenChange(previousMutation.getPotential_changes().get(randNumber));
+ markingDiff = previousMutation.getInterest_mark() -
mutationTree.find(mutationTree.getLastId()).getInterest_mark();
}
- else if(markingDiff == 0 || markingDiff < 0)
- {
- SingleChange tmp =
mutationTree.getRoot().singleChangeBasedOnWeight();
- nextMut = new
GenericTreeNode(tmp.getattachedToMutation().getPost_change_row(),nextId(),mutationTree.getRoot(),tmp.getattachedToMutation());
- nextMut.setChosenChange(tmp);
- }
- else
+
+ if (mutationTree.getRoot() != null)
{
- System.out.println("I mean What Da Heck");
+ if (markingDiff > 0) //
+ {
+ int randNumber =
rand.nextInt(previousMutation.getPotential_changes().size());
+ nextMut = new
GenericTreeNode(previousMutation.getPost_change_row(), nextId(),
mutationTree.getRoot(), previousMutation);
+
nextMut.setChosenChange(previousMutation.getPotential_changes().get(randNumber));
+ nextMut.initPostChangeRow();
+ }
+ else if (markingDiff == 0 || markingDiff < 0)
+ {
+ SingleChange tmp =
mutationTree.getRoot().singleChangeBasedOnWeight();
+ nextMut = new
GenericTreeNode(tmp.getattachedToMutation().getPost_change_row(), nextId(),
mutationTree.getRoot(), tmp.getattachedToMutation());
+ nextMut.setChosenChange(tmp);
+ nextMut.initPostChangeRow();
+ }
+ else
+ System.out.println("I mean What Da Heck");
}
-
- }
- return nextMut;
+ return nextMut;
}
-// public boolean isNewMutation(GenericTreeNode newMut) //iterative shitty
implementation.
-// {
-//
if(newMut.getChosenChange().getNewValue().equals(newMut.getChosenChange().getOldValue()))
-// return false;
-//
-// for(int i = 1; i <= mutationTree.getNumberOfNodes(); i++)
-// {
-// if(mutationTree.find(i).compare(newMut) ||
newMut.isSingleChangeOnCurrentPath())
-// return false;
-// }
-//
-// return true;
-// }
-
- public boolean isNewMutation(GenericTreeNode newMut,GenericTreeNode
rootMutation)
+ public boolean isNewMutation(GenericTreeNode newMut)
{
- boolean res = true;
-
- if(rootMutation.compare(newMut) ||
newMut.isSingleChangeOnCurrentPath())
+ if(mutationTree.getRoot().compare(newMut) ||
newMut.isSingleChangeOnCurrentPath(mutationTree.getRoot()))
return false;
- for(GenericTreeNode child : rootMutation.getChildren())
- {
- res = isNewMutation(newMut,child);
- }
-
- return res;
+ SingleChange chosenChange = newMut.getChosenChange();
+ return !chosenChange.compareValues();
}
public void printMutationTree()
{
- String displayer = "";
+ String displayer = null ;
for(int i = 1; i <= mutationTree.getNumberOfNodes();i++)
{
for(int j = 0; j < mutationTree.find(i).getDepth();j++)
{
- displayer = displayer+"--";
+ displayer = displayer+("--");
}
- displayer = displayer+mutationTree.find(i).toString()+"\n";
+ displayer = displayer+(mutationTree.find(i).toString()+"\n");
}
System.out.println(displayer);
}
diff --git a/src/main/java/org/schemaspy/Main.java
b/src/main/java/org/schemaspy/Main.java
index 61c6030..5bbbfd4 100644
--- a/src/main/java/org/schemaspy/Main.java
+++ b/src/main/java/org/schemaspy/Main.java
@@ -44,15 +44,14 @@ public class Main implements CommandLineRunner {
@Autowired
private SchemaAnalyzer analyzer;
+ private DBFuzzer dbFuzzer;
+
@Autowired
private CommandLineArguments arguments;
@Autowired
private CommandLineArgumentParser commandLineArgumentParser;
-
- private DBFuzzer dbFuzzer;
-
@Autowired
private ApplicationContext context;
diff --git a/src/main/java/org/schemaspy/model/GenericTree.java
b/src/main/java/org/schemaspy/model/GenericTree.java
index 3946277..ea53bd1 100644
--- a/src/main/java/org/schemaspy/model/GenericTree.java
+++ b/src/main/java/org/schemaspy/model/GenericTree.java
@@ -1,14 +1,6 @@
package org.schemaspy.model;
-import org.schemaspy.*;
-import org.schemaspy.model.SingleChange;
-
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import java.util.*;
-
public class GenericTree {
private GenericTreeNode root;
@@ -36,10 +28,12 @@ public class GenericTree {
}
- private int auxiliaryGetNumberOfNodes(GenericTreeNode node) {
+ private int auxiliaryGetNumberOfNodes(GenericTreeNode node)
+ {
int numberOfNodes = node.getNumberOfChildren();
- for (GenericTreeNode child : node.getChildren()) {
+ for (GenericTreeNode child : node.getChildren())
+ {
numberOfNodes += auxiliaryGetNumberOfNodes(child);
}
@@ -47,19 +41,22 @@ public class GenericTree {
}
//finds a node in the tree recursivly. used as testing and code ease
purposes. should not be sued in loop to much.
- public GenericTreeNode find(Integer id) {
- if (root == null) {
- return null;
- }
+ public GenericTreeNode find(Integer id)
+ {
+ if (root == null)
+ return null;
+
return auxiliaryFind(root, id);
}
- private GenericTreeNode auxiliaryFind(GenericTreeNode currentNode, Integer
id) {
+ private GenericTreeNode auxiliaryFind(GenericTreeNode currentNode, Integer
id)
+ {
if (currentNode.getId().equals(id))
return currentNode;
if (!currentNode.hasChildren())
return null;
- for (GenericTreeNode child : currentNode.getChildren()) {
+ for (GenericTreeNode child : currentNode.getChildren())
+ {
GenericTreeNode returnNode = auxiliaryFind(child, id);
if (null != returnNode)
return returnNode;
@@ -84,25 +81,25 @@ public class GenericTree {
}
//finds first mutation that hasnt explored the singleChange. not to be
used any more as the picking patern.
- public GenericTreeNode findFirstMutationWithout(GenericTreeNode mutation,
SingleChange chosenChange) {
- int i, j;
+ public GenericTreeNode findFirstMutationWithout(GenericTreeNode mutation,
SingleChange chosenChange)
+ {
boolean noSonHasChosenChange = true;
GenericTreeNode res = null;
- if (mutation.getChildren().isEmpty()) {
+ if (mutation.getChildren().isEmpty())
return mutation;
- }
- for (i = 0; i < mutation.getChildren().size(); i++) {
- if
(mutation.getChildren().get(i).getChosenChange().compare(chosenChange))
+ for(GenericTreeNode child : mutation.getChildren())
+ {
+ if (child.getChosenChange().compare(chosenChange))
noSonHasChosenChange = false;
}
-
if (noSonHasChosenChange)
return mutation;
- for (j = 0; j < mutation.getChildren().size(); j++) {
- res = findFirstMutationWithout(mutation.getChildren().get(j),
chosenChange);
+ for(GenericTreeNode child : mutation.getChildren())
+ {
+ res = findFirstMutationWithout(child, chosenChange);
}
return res; // should never be null unless the algorithm is not
looking for something precise
}
diff --git a/src/main/java/org/schemaspy/model/GenericTreeNode.java
b/src/main/java/org/schemaspy/model/GenericTreeNode.java
index 70cfcab..fea85b8 100644
--- a/src/main/java/org/schemaspy/model/GenericTreeNode.java
+++ b/src/main/java/org/schemaspy/model/GenericTreeNode.java
@@ -1,63 +1,53 @@
package org.schemaspy.model;
import java.sql.PreparedStatement;
-import java.sql.ResultSet;
+
import java.util.*;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.schemaspy.*;
-import java.util.*;
-import java.util.ArrayList;
-import java.util.regex.Matcher;
-import java.sql.PreparedStatement;
-
public class GenericTreeNode {
private final Integer id;
- private GenericTreeNode rootMutation;
private Integer interest_mark;
private Integer weight;
private Integer subTreeWeight;
+ private int depth;
private final Row initial_state_row;
private Row post_change_row;
private ArrayList<SingleChange> potential_changes = new
ArrayList<SingleChange>();
private ArrayList<SingleChange> cascadeFK = new ArrayList<SingleChange>();
// a integrer
- private SingleChange chosenChange;
- private ArrayList<GenericTreeNode> children = new
ArrayList<GenericTreeNode>();
- private GenericTreeNode parent;
private boolean cascadingFK;
- private int depth;
+ private GenericTreeNode parent;
+ private ArrayList<GenericTreeNode> children = new
ArrayList<GenericTreeNode>();
+ private SingleChange chosenChange;
/**
* Default GenericTreeNode constructor
*/
public GenericTreeNode(Row initial_state_row, int id) { // used only for
rootMutation
- this.id = id;
- this.initial_state_row = initial_state_row;
this.cascadingFK = false;
- this.potential_changes = discoverMutationPossibilities();
- this.weight = 1;
this.subTreeWeight = 0;
- this.depth = 0;
this.parent = null;
+ this.weight = 1;
+ this.depth = 0;
+ this.id = id;
+ this.initial_state_row = initial_state_row;
+ this.potential_changes = discoverMutationPossibilities(this);
}
public GenericTreeNode(Row initial_state_row, int id, GenericTreeNode
rootMutation, GenericTreeNode parentMutation) {
- this.id = id;
- this.initial_state_row = initial_state_row;
- this.cascadingFK = false;
- this.rootMutation = rootMutation;
this.parent = parentMutation;
- initDepth();
- this.potential_changes = discoverMutationPossibilities();
- this.weight = 1;
+ this.cascadingFK = false;
this.subTreeWeight = 0;
+ this.weight = 1;
+ this.id = id;
+ initDepth();
+ this.initial_state_row = initial_state_row;
+ this.potential_changes = discoverMutationPossibilities(rootMutation);
}
public Integer getId() {
@@ -110,16 +100,20 @@ public class GenericTreeNode {
/**
*
*/
- public SingleChange singleChangeBasedOnWeight() {
+ public SingleChange singleChangeBasedOnWeight()
+ {
final Random r = new Random();
+
checkWeightConsistency();
if (this.potential_changes.isEmpty() && (0 == subTreeWeight))
System.out.println("ERROR PICKING : no potential_changes AND
subtreeweight = 0");
int rnd = r.nextInt(subTreeWeight + potential_changes.size());
assert (rnd >= 0);
+
if (rnd < potential_changes.size()) // checking if currentNode is the
pick
- return potential_changes.remove(rnd);
+ return potential_changes.remove(rnd);
+
rnd -= potential_changes.size(); // removing the potential changes
"weight" of the current node to match subtree Weight
for (GenericTreeNode n : children) // launching on every child if
current node wasnt picked.
{
@@ -129,6 +123,7 @@ public class GenericTreeNode {
}
rnd -= w;
}
+
System.out.println("ici2");
throw new Error("This should be impossible to reach");
}
@@ -172,13 +167,6 @@ public class GenericTreeNode {
return potential_changes;
}
- /**
- * @return the rootMutation
- */
- public GenericTreeNode getRootMutation() {
- return rootMutation;
- }
-
public void setChosenChange(SingleChange sc) {
this.chosenChange = sc;
this.chosenChange.setAttachedToMutation(this);
@@ -194,33 +182,40 @@ public class GenericTreeNode {
this.parent = parent;
}
- public ArrayList<SingleChange> discoverMutationPossibilities() {
+ public ArrayList<SingleChange>
discoverMutationPossibilities(GenericTreeNode rootMutation) {
int i;
ArrayList<SingleChange> possibilities = new ArrayList<SingleChange>();
//TRYING TO DISCOVER RAW POSSIBILITIES
- for (Map.Entry<String, String> content :
initial_state_row.getContent().entrySet()) {
- try {
+ for (Map.Entry<String, String> content :
initial_state_row.getContent().entrySet())
+ {
+ try
+ {
TableColumn parentColumn =
initial_state_row.getParentTable().findTableColumn(content.getKey());
- possibilities.addAll(discoverFieldPossibilities(parentColumn,
content.getValue()));
- } catch (Exception e) {
+ possibilities.addAll(discoverFieldPossibilities(parentColumn,
content.getValue(),rootMutation));
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
}
}
//REMOVING POSSIBILITIES THAT DONT MATCH CONSTRAINTS
- for (i = 0; i < possibilities.size(); i++) {
- if (!possibilities.get(i).respectsConstraints())
- possibilities.remove(possibilities.get(i));
+ for(SingleChange singleChange : possibilities)
+ {
+ if (!singleChange.respectsConstraints())
+ possibilities.remove(singleChange);
}
return possibilities;
}
- public ArrayList<SingleChange> discoverFieldPossibilities(TableColumn
tableColumn, String column_value) throws Exception //listing of the mutation
possibilities on the specified row
+ public ArrayList<SingleChange> discoverFieldPossibilities(TableColumn
tableColumn, String column_value,GenericTreeNode rootMutation) throws Exception
//listing of the mutation possibilities on the specified row
{
ArrayList<SingleChange> oneChange = new ArrayList<SingleChange>();
String typeName = tableColumn.getTypeName();
+
switch (typeName) {
case "int2":
int tmp =
Integer.parseInt(rootMutation.getInitial_state_row().getContent().get(tableColumn.getName()));
@@ -229,12 +224,12 @@ public class GenericTreeNode {
oneChange.add(new SingleChange(tableColumn, this,
column_value, Integer.toString(1)));
break;
case "varchar":
- if (this.getRootMutation() == null) {
+ if (rootMutation == null) {
char tmp2 = column_value.charAt(0);
oneChange.add(new SingleChange(tableColumn, this,
column_value, (Character.toString(tmp2++) + column_value.substring(1))));
oneChange.add(new SingleChange(tableColumn, this,
column_value, (Character.toString(tmp2--) + column_value.substring(1))));
} else {
- char tmp2 = (char)
this.getRootMutation().getInitial_state_row().getContent().get(tableColumn.getName()).charAt(0);
+ char tmp2 = (char)
rootMutation.getInitial_state_row().getContent().get(tableColumn.getName()).charAt(0);
char nextChar = (char) (tmp2 + 1);
char prevChar = (char) (tmp2 - 1);
oneChange.add(new SingleChange(tableColumn, this,
column_value, (Character.toString(nextChar) + column_value.substring(1))));
@@ -272,33 +267,42 @@ public class GenericTreeNode {
return oneChange;
}
- public boolean inject(SchemaAnalyzer analyzer, boolean undo) {
+ public boolean inject(SchemaAnalyzer analyzer, boolean undo)
+ {
if (undo)
System.out.println("UNDOING");
else
System.out.println("INJECT");
+
String theQuery = updateQueryBuilder(undo);
- try {
+ try
+ {
PreparedStatement stmt =
analyzer.getSqlService().prepareStatement(theQuery, analyzer.getDb(), null);
stmt.execute();
- initPostChangeRow();
return true;
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
e.printStackTrace();
return false;
}
}
- private void initPostChangeRow() {
+ public void initPostChangeRow()
+ {
this.post_change_row = this.initial_state_row.clone();
this.post_change_row.setValueOfColumn(chosenChange.getParentTableColumn().getName(),
chosenChange.getNewValue());
}
- public boolean undo(SchemaAnalyzer analyzer) {
- try {
- return this.inject(analyzer, true);
- } catch (Exception e) {
+ public boolean undo(SchemaAnalyzer analyzer)
+ {
+ try
+ {
+ return this.inject(analyzer, true);
+ }
+ catch(Exception e)
+ {
e.printStackTrace();
return false;
}
@@ -308,39 +312,48 @@ public class GenericTreeNode {
{
String theQuery;
- if (undo) {
+ if (undo)
+ {
if
(chosenChange.getParentTableColumn().getTypeName().equals("varchar") ||
chosenChange.getParentTableColumn().getTypeName().equals("bool"))
theQuery = "UPDATE " +
initial_state_row.getParentTable().getName() + " SET " +
chosenChange.getParentTableColumn().getName() + "='" +
chosenChange.getOldValue() + "', ";
else
theQuery = "UPDATE " +
initial_state_row.getParentTable().getName() + " SET " +
chosenChange.getParentTableColumn().getName() + " = " +
chosenChange.getOldValue() + ", ";
- } else {
+ }
+ else
+ {
if
(chosenChange.getParentTableColumn().getTypeName().equals("varchar") ||
chosenChange.getParentTableColumn().getTypeName().equals("bool"))
theQuery = "UPDATE " +
initial_state_row.getParentTable().getName() + " SET " +
chosenChange.getParentTableColumn().getName() + "='" +
chosenChange.getNewValue() + "', ";
else
theQuery = "UPDATE " +
initial_state_row.getParentTable().getName() + " SET " +
chosenChange.getParentTableColumn().getName() + "=" +
chosenChange.getNewValue() + ", ";
}
- for (Map.Entry<String, String> entry :
initial_state_row.getContent().entrySet()) {
- if
(!entry.getKey().equals(chosenChange.getParentTableColumn().getName())) {
+ for (Map.Entry<String, String> entry :
initial_state_row.getContent().entrySet())
+ {
+ if
(!entry.getKey().equals(chosenChange.getParentTableColumn().getName()))
+ {
if
(chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("varchar")
||
chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("bool"))
theQuery = theQuery + (entry.getKey() + "='" +
entry.getValue() + "', ");
else
theQuery = theQuery + (entry.getKey() + "=" +
entry.getValue() + ", ");
}
-
}
theQuery = theQuery.substring(0, theQuery.lastIndexOf(","));
theQuery = theQuery + " WHERE ";
// USING ALL VALUES TO TRIANGULATE THE ROW TO UPDATE (no primary key)
- if (initial_state_row.getParentTable().getPrimaryColumns().isEmpty()) {
- for (Map.Entry<String, String> entry :
initial_state_row.getContent().entrySet()) {
- if
(!entry.getKey().equals(chosenChange.getParentTableColumn().getName())) {
+ if (initial_state_row.getParentTable().getPrimaryColumns().isEmpty())
+ {
+ for (Map.Entry<String, String> entry :
initial_state_row.getContent().entrySet())
+ {
+ if
(!entry.getKey().equals(chosenChange.getParentTableColumn().getName()))
+ {
if
(chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("varchar")
||
chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("bool"))
theQuery = theQuery + (entry.getKey() + "='" +
entry.getValue() + "' AND ");
else
theQuery = theQuery + (entry.getKey() + "=" +
entry.getValue() + " AND ");
- } else {
+ }
+ else
+ {
if (undo)
theQuery = theQuery + (entry.getKey() + "='" +
chosenChange.getNewValue() + "' AND ");
else
@@ -348,7 +361,8 @@ public class GenericTreeNode {
}
}
theQuery = theQuery.substring(0, theQuery.lastIndexOf(" AND "));
- } else
+ }
+ else
theQuery = theQuery + (" " +
initial_state_row.getParentTable().getPrimaryColumns().get(0).getName() + "=" +
initial_state_row.getValueOfColumn(initial_state_row.getParentTable().getPrimaryColumns().get(0).getName()));
@@ -392,7 +406,8 @@ public class GenericTreeNode {
// }
- public boolean compare(GenericTreeNode genericTreeNode) {
+ public boolean compare(GenericTreeNode genericTreeNode)
+ {
boolean res = false;
if (this.getId() == genericTreeNode.getId())
res = true;
@@ -403,17 +418,21 @@ public class GenericTreeNode {
return res;
}
- public boolean undoToMutation(GenericTreeNode target, SchemaAnalyzer
analyzer) throws Exception {
+ public boolean undoToMutation(GenericTreeNode target, SchemaAnalyzer
analyzer)
+ {
ArrayList<GenericTreeNode> goingUp = findPathToMutation(target).get(0);
ArrayList<GenericTreeNode> goingDown =
findPathToMutation(target).get(1);
- ;
- for (int i = 0; i < goingUp.size(); i++) {
- goingUp.get(i).undo(analyzer);
+ for(GenericTreeNode node : goingUp )
+ {
+ node.undo(analyzer);
}
- for (int i = 0; i < goingDown.size(); i++) {
- goingDown.get(i).inject(analyzer, false);
+
+ for(GenericTreeNode node : goingDown )
+ {
+ node.inject(analyzer, false);
}
+
return true;
}
@@ -433,45 +452,55 @@ public class GenericTreeNode {
return (getNumberOfChildren() > 0);
}
- public void setChildren(ArrayList<GenericTreeNode> children) {
- for (GenericTreeNode child : children) {
+ public void setChildren(ArrayList<GenericTreeNode> children)
+ {
+ for (GenericTreeNode child : children)
+ {
child.parent = this;
}
this.children = children;
}
- public void addChild(GenericTreeNode child) {
+ public void addChild(GenericTreeNode child)
+ {
child.parent = this;
children.add(child);
}
- public String toString() {
+ public String toString()
+ {
return "[ MUT ID " + this.getId() + " Depth = " + this.getDepth() + "
SG " + this.chosenChange + "]";
}
- public ArrayList<ArrayList<GenericTreeNode>>
findPathToMutation(GenericTreeNode target) {
+ public ArrayList<ArrayList<GenericTreeNode>>
findPathToMutation(GenericTreeNode target)
+ {
ArrayList<ArrayList<GenericTreeNode>> finalPath = new
ArrayList<ArrayList<GenericTreeNode>>();
ArrayList<GenericTreeNode> thisPath = new ArrayList<GenericTreeNode>();
ArrayList<GenericTreeNode> targetPath = new
ArrayList<GenericTreeNode>();
GenericTreeNode tmpTarget = target;
GenericTreeNode tmpThis = this;
+
int depthOffset = -1;
- while (depthOffset != 0) {
+ while (depthOffset != 0)
+ {
depthOffset = tmpThis.getDepth() - tmpTarget.getDepth();
- if (depthOffset > 0) {
+ if (depthOffset > 0)
+ {
thisPath.add(tmpThis);
tmpThis = tmpThis.getParent();
-
- } else if (depthOffset < 0) {
+ }
+ else if (depthOffset < 0)
+ {
targetPath.add(tmpTarget);
tmpTarget = tmpTarget.getParent();
}
}
- while (!tmpThis.compare(tmpTarget)) {
+ while (!tmpThis.compare(tmpTarget))
+ {
thisPath.add(tmpThis);
targetPath.add(tmpTarget);
@@ -492,12 +521,14 @@ public class GenericTreeNode {
setWeight(this.interest_mark); // eventually consider depth?
}
- public boolean isSingleChangeOnCurrentPath() {
+ public boolean isSingleChangeOnCurrentPath(GenericTreeNode rootMutation)
+ {
ArrayList<GenericTreeNode> finalPath = new
ArrayList<GenericTreeNode>();
finalPath.addAll(this.findPathToMutation(rootMutation).get(0));
finalPath.addAll(this.findPathToMutation(rootMutation).get(1));
- for (GenericTreeNode mutOnPath : finalPath) {
+ for (GenericTreeNode mutOnPath : finalPath)
+ {
if (mutOnPath.getChosenChange().compare(this.getChosenChange()))
return false;
}
@@ -505,9 +536,10 @@ public class GenericTreeNode {
}
- public void propagateWeight() {
-
+ public void propagateWeight()
+ {
this.updateSubTreeWeight();
+
if (this.getParent() != null)
this.getParent().propagateWeight();
}
diff --git a/src/main/java/org/schemaspy/model/QueryResponse.java
b/src/main/java/org/schemaspy/model/QueryResponse.java
index 0317364..33b6aa6 100644
--- a/src/main/java/org/schemaspy/model/QueryResponse.java
+++ b/src/main/java/org/schemaspy/model/QueryResponse.java
@@ -17,12 +17,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
*/
package org.schemaspy.model;
-import java.sql.ResultSet;
-import java.sql.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.util.ArrayList;
-import java.util.*;
+
public class QueryResponse
{
@@ -43,11 +39,9 @@ public class QueryResponse
public QueryResponse(ArrayList<Row> rows, Integer nbRows)
{
this.rows = new ArrayList<Row>();
- this.rows = rows;
+ this.rows = rows;
this.nbRows = nbRows;
}
-
-
/**
* Returns value of rows
* @return
@@ -56,7 +50,7 @@ public class QueryResponse
return rows;
}
- public void addRow(Row row)
+ public void addRow(Row row)
{
rows.add(row);
}
@@ -85,7 +79,7 @@ public class QueryResponse
this.nbRows = nbRows;
}
- public String toString()
+ public String toString()
{
return "Rows = "+rows.toString();
}
diff --git a/src/main/java/org/schemaspy/model/QueryResponseParser.java
b/src/main/java/org/schemaspy/model/QueryResponseParser.java
index 931b13a..ddbe655 100644
--- a/src/main/java/org/schemaspy/model/QueryResponseParser.java
+++ b/src/main/java/org/schemaspy/model/QueryResponseParser.java
@@ -19,10 +19,8 @@
package org.schemaspy.model;
import java.sql.ResultSet;
import java.sql.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.util.*;
-import java.lang.invoke.MethodHandles;
+
/**
* Represents a <a href='http://en.wikipedia.org/wiki/Foreign_key'>
* Foreign Key Constraint</a> that "ties" a child table to a parent table
@@ -32,7 +30,6 @@ public class QueryResponseParser
{
private ResultSetMetaData resultMeta;
private QueryResponse formatedResponse;
- private final static Logger LOGGER =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public QueryResponseParser() {
@@ -43,7 +40,6 @@ public class QueryResponseParser
return formatedResponse;
}
-
public void setFormatedResponse(QueryResponse formatedResponse) {
this.formatedResponse = formatedResponse;
}
diff --git a/src/main/java/org/schemaspy/model/SingleChange.java
b/src/main/java/org/schemaspy/model/SingleChange.java
index b8374ed..460eba1 100644
--- a/src/main/java/org/schemaspy/model/SingleChange.java
+++ b/src/main/java/org/schemaspy/model/SingleChange.java
@@ -10,9 +10,10 @@ public class SingleChange
private String newValue;
- public SingleChange(TableColumn parentColumn ,GenericTreeNode
attachedToMutation, String oldValue, String newValue) {
- this.parentTableColumn = parentColumn;
- this.attachedToMutation = attachedToMutation;
+ public SingleChange(TableColumn parentColumn ,GenericTreeNode
attachedToMutation, String oldValue, String newValue)
+ {
+ this.attachedToMutation = attachedToMutation;
+ this.parentTableColumn = parentColumn;
this.oldValue = oldValue;
this.newValue = newValue;
}
@@ -23,25 +24,21 @@ public class SingleChange
{
case "serial":
if(Integer.parseInt(newValue) <
Math.pow(2,parentTableColumn.getLength()))
- return true;
+ return true;
return false;
case "numeric":
if(Integer.parseInt(newValue) <
Math.pow(2,parentTableColumn.getLength()))
- return true;
+ return true;
return false;
case "int2":
- if(Integer.parseInt(newValue) <= 32767)
- {
- return true;
- }
- return false;
+ if(Integer.parseInt(newValue) <= 32767)
+ return true;
+ return false;
default:
return true;
-
}
}
-
@Override
public String toString()
{
@@ -86,4 +83,12 @@ public class SingleChange
{
this.attachedToMutation = attachedToMutation;
}
+
+ public boolean compareValues()
+ {
+ if(this.getNewValue().equals(this.getOldValue()))
+ return true;
+
+ return false;
+ }
}
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-schemafuzz] branch master updated: Finished clearing the code, also fixed the same value mutation bugg,
gnunet <=