Commit 5d381737 authored by Johannes Mey's avatar Johannes Mey
Browse files

fix issue #6

parent 0f40a1a4
Pipeline #2993 passed with stage
in 45 seconds
......@@ -281,7 +281,7 @@ aspect BackendBidirectionalAPI {
r.generateBiOneOne(sb, true);
} else if (r.multiplicityMany()) {
l.generateBiOneMany(sb, false);
r.generateBiManyOne(sb);
r.generateBiManyOne(sb, l);
}
} else if (l.multiplicityOpt()) {
if (r.multiplicityOne()) {
......@@ -292,18 +292,18 @@ aspect BackendBidirectionalAPI {
r.generateBiOneOne(sb, true);
} else if (r.multiplicityMany()) {
l.generateBiOneMany(sb, true);
r.generateBiManyOne(sb);
r.generateBiManyOne(sb, l);
}
} else if (l.multiplicityMany()) {
if (r.multiplicityOne()) {
l.generateBiManyOne(sb);
l.generateBiManyOne(sb, r);
r.generateBiOneMany(sb, false);
} else if (r.multiplicityOpt()) {
l.generateBiManyOne(sb);
l.generateBiManyOne(sb, r);
r.generateBiOneMany(sb, true);
} else if (r.multiplicityMany()) {
l.generateBiManyMany(sb);
r.generateBiManyMany(sb);
l.generateBiManyMany(sb, r);
r.generateBiManyMany(sb, l);
}
}
}
......@@ -357,7 +357,7 @@ aspect BackendBidirectionalAPI {
}
}
public void RelationComponent.generateBiManyMany(StringBuilder sb) {
public void RelationComponent.generateBiManyMany(StringBuilder sb, RelationComponent opposite) {
// Get
// getXs
sb.append(ind(1) + "public java.util.List<" + ofTypeDecl() + "> " + toTypeDecl());
......@@ -379,12 +379,12 @@ aspect BackendBidirectionalAPI {
sb.append(ind(5) + "changed = true;\n");
sb.append(ind(5) + ofTypeDecl() + " resolvedElement = resolve" + nameCapitalized() + "ByToken(element.asUnresolved().get__token(), i);\n");
sb.append(ind(5) + "if (resolvedElement != null) {\n");
sb.append(ind(6) + ASTNode.listClass + "<" + toTypeDecl() + "> otherList = resolvedElement.get" + getImplAttributeName() + "();\n");
sb.append(ind(6) + ASTNode.listClass + "<" + toTypeDecl() + "> otherList = resolvedElement.get" + opposite.getImplAttributeName() + "();\n");
sb.append(ind(6) + "if (otherList == null) {\n");
sb.append(ind(7) + "otherList = new ArrayList<>();\n");
sb.append(ind(6) + "}\n");
sb.append(ind(6) + "otherList.add(this);\n");
sb.append(ind(6) + "resolvedElement.set" + getImplAttributeName() + "(otherList);\n");
sb.append(ind(6) + "resolvedElement.set" + opposite.getImplAttributeName() + "(otherList);\n");
sb.append(ind(5) + "}\n");
sb.append(ind(5) + "l.set(i, resolvedElement);\n");
sb.append(ind(4) + "}\n");
......@@ -432,7 +432,7 @@ aspect BackendBidirectionalAPI {
}
public void RelationComponent.generateBiManyOne(StringBuilder sb) {
public void RelationComponent.generateBiManyOne(StringBuilder sb, RelationComponent opposite) {
// Get
// getXs
sb.append(ind(1) + "public java.util.List<" + ofTypeDecl() + "> " + toTypeDecl());
......@@ -453,7 +453,7 @@ aspect BackendBidirectionalAPI {
sb.append(ind(4) + "if (element.unresolved()) {\n");
sb.append(ind(5) + "changed = true;\n");
sb.append(ind(5) + ofTypeDecl() + " resolvedElement = resolve" + nameCapitalized() + "ByToken(element.asUnresolved().get__token(), i);\n");
sb.append(ind(5) + toTypeDecl() + " oldTarget = resolvedElement.get" + getImplAttributeName() + "();\n");
sb.append(ind(5) + toTypeDecl() + " oldTarget = resolvedElement.get" + opposite.getImplAttributeName() + "();\n");
sb.append(ind(5) + "if (oldTarget != null && oldTarget != this) {\n");
sb.append(ind(6) + "oldTarget.get" + getImplAttributeName() + "().remove(resolvedElement);\n");
sb.append(ind(5) + "}\n");
......@@ -461,7 +461,7 @@ aspect BackendBidirectionalAPI {
sb.append(ind(6) + "l.remove(i);\n");
sb.append(ind(6) + "i--;\n");
sb.append(ind(5) + "} else {\n");
sb.append(ind(6) + "resolvedElement.set" + getImplAttributeName() + "(this);\n");
sb.append(ind(6) + "resolvedElement.set" + opposite.getImplAttributeName() + "(this);\n");
sb.append(ind(6) + "l.set(i, resolvedElement);\n");
sb.append(ind(5) + "}\n");
sb.append(ind(4) + "}\n");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment