[Fix] Fix version loading from PostgreSql with Json
This commit is contained in:
parent
0bcdbe1f5d
commit
20eec25137
|
@ -41,7 +41,7 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
|
|||
|
||||
private boolean flat;
|
||||
private boolean withoutElementName;
|
||||
private boolean withVersion;
|
||||
private boolean withoutVersion;
|
||||
private boolean withoutPolicies;
|
||||
private int activityDepth = Integer.MAX_VALUE;
|
||||
|
||||
|
@ -56,7 +56,11 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
|
|||
}
|
||||
|
||||
public boolean isWithVersion() {
|
||||
return this.withVersion;
|
||||
return !this.withoutVersion;
|
||||
}
|
||||
|
||||
public boolean isWithoutVersion() {
|
||||
return this.withoutVersion;
|
||||
}
|
||||
|
||||
public boolean isWithoutElementName() {
|
||||
|
@ -68,7 +72,12 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
|
|||
}
|
||||
|
||||
public StrolchElementToJsonVisitor withVersion() {
|
||||
this.withVersion = true;
|
||||
this.withoutVersion = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StrolchElementToJsonVisitor withoutVersion() {
|
||||
this.withoutVersion = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -645,7 +654,7 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
|
|||
protected void addVersion(StrolchRootElement element, JsonObject rootJ) {
|
||||
if (!element.hasVersion())
|
||||
return;
|
||||
if (!isWithVersion())
|
||||
if (isWithoutVersion())
|
||||
return;
|
||||
|
||||
Version version = element.getVersion();
|
||||
|
|
|
@ -53,6 +53,11 @@ public class StrolchRootElementToJsonVisitor implements StrolchRootElementVisito
|
|||
return this;
|
||||
}
|
||||
|
||||
public StrolchRootElementToJsonVisitor withoutVersion() {
|
||||
this.visitor.withoutVersion();
|
||||
return this;
|
||||
}
|
||||
|
||||
public StrolchRootElementToJsonVisitor withoutElementName() {
|
||||
this.visitor.withoutElementName();
|
||||
return this;
|
||||
|
|
|
@ -32,7 +32,7 @@ public class ModelToJsonTest extends ModelMarshallingTest {
|
|||
|
||||
@Override
|
||||
protected Order formatAndParseOrder(Order order) {
|
||||
StrolchRootElementToJsonVisitor jsonVisitor = new StrolchRootElementToJsonVisitor().withVersion();
|
||||
StrolchRootElementToJsonVisitor jsonVisitor = new StrolchRootElementToJsonVisitor();
|
||||
JsonObject jsonObject = order.accept(jsonVisitor).getAsJsonObject();
|
||||
|
||||
Order parsedOrder = new OrderFromJsonVisitor().visit(jsonObject);
|
||||
|
@ -47,7 +47,7 @@ public class ModelToJsonTest extends ModelMarshallingTest {
|
|||
@Override
|
||||
protected Resource formatAndParseResource(Resource resource) {
|
||||
|
||||
StrolchRootElementToJsonVisitor jsonVisitor = new StrolchRootElementToJsonVisitor().withVersion();
|
||||
StrolchRootElementToJsonVisitor jsonVisitor = new StrolchRootElementToJsonVisitor();
|
||||
JsonObject jsonObject = resource.accept(jsonVisitor).getAsJsonObject();
|
||||
|
||||
Resource parsedResource = new ResourceFromJsonVisitor().visit(jsonObject);
|
||||
|
@ -62,7 +62,7 @@ public class ModelToJsonTest extends ModelMarshallingTest {
|
|||
@Override
|
||||
protected Activity formatAndParseActivity(Activity activity) {
|
||||
|
||||
StrolchRootElementToJsonVisitor jsonVisitor = new StrolchRootElementToJsonVisitor().withVersion();
|
||||
StrolchRootElementToJsonVisitor jsonVisitor = new StrolchRootElementToJsonVisitor();
|
||||
JsonObject jsonObject = activity.accept(jsonVisitor).getAsJsonObject();
|
||||
|
||||
Activity parsedActivity = new ActivityFromJsonVisitor().visit(jsonObject);
|
||||
|
|
|
@ -415,7 +415,7 @@ public class Inspector {
|
|||
// build JSON response
|
||||
ResourceVisitor<JsonObject> visitor;
|
||||
if (overview == null || !overview) {
|
||||
visitor = new StrolchRootElementToJsonVisitor().withVersion().asResourceVisitor();
|
||||
visitor = new StrolchRootElementToJsonVisitor().asResourceVisitor();
|
||||
} else {
|
||||
visitor = e -> {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
|
@ -459,7 +459,7 @@ public class Inspector {
|
|||
// build JSON response
|
||||
OrderVisitor<JsonObject> visitor;
|
||||
if (overview == null || !overview) {
|
||||
visitor = new StrolchRootElementToJsonVisitor().withVersion().asOrderVisitor();
|
||||
visitor = new StrolchRootElementToJsonVisitor().asOrderVisitor();
|
||||
} else {
|
||||
visitor = e -> {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
|
@ -505,7 +505,7 @@ public class Inspector {
|
|||
// build JSON response
|
||||
ActivityVisitor<JsonObject> visitor;
|
||||
if (overview == null || !overview) {
|
||||
visitor = new StrolchRootElementToJsonVisitor().withVersion().asActivityVisitor();
|
||||
visitor = new StrolchRootElementToJsonVisitor().asActivityVisitor();
|
||||
} else {
|
||||
visitor = e -> {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
|
|
Loading…
Reference in New Issue