Skip to content

Commit da6dfcb

Browse files
Merge pull request #10 from Cloudrisk/feature/dsl-bundle-upgrade
revert to new DSL function changes
2 parents 179add6 + bcf4bff commit da6dfcb

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/main/java/com/regnosys/rosetta/generator/python/expressions/PythonExpressionGenerator.xtend

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,4 @@ class PythonExpressionGenerator {
434434
importsFound.add(import)
435435
}
436436
}
437-
}
437+
}

src/main/java/com/regnosys/rosetta/generator/python/func/PythonFunctionGenerator.xtend

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import com.regnosys.rosetta.rosetta.simple.Data
1212
import com.regnosys.rosetta.rosetta.simple.Function
1313
import com.regnosys.rosetta.rosetta.simple.Operation
1414
import com.regnosys.rosetta.rosetta.simple.Segment
15+
import com.regnosys.rosetta.rosetta.simple.ShortcutDeclaration
16+
import com.regnosys.rosetta.rosetta.simple.Condition
17+
import com.regnosys.rosetta.rosetta.RosettaFeature
18+
import com.regnosys.rosetta.rosetta.RosettaTyped
1519
import java.util.ArrayList
1620
import java.util.Collections
1721
import java.util.HashMap
@@ -283,7 +287,7 @@ class PythonFunctionGenerator {
283287
private def generateAddOperation(AssignPathRoot root, Operation operation, Function function, String expression) {
284288
val lineSeparator = System.getProperty("line.separator")
285289
val attribute = root as Attribute
286-
val fullPath = generateFullPath(operation.getPath().getReversedAttributes, root.name)
290+
val fullPath = generateFullPath(operation.getPath().getReversedFeatures, root.name)
287291

288292
var result = ""
289293
if (attribute.typeCall.type instanceof RosettaEnumeration) {
@@ -324,7 +328,7 @@ class PythonFunctionGenerator {
324328
var result = new StringBuilder()
325329
result.append("'")
326330
while (currentPath !== null) {
327-
result.append(currentPath.getAttribute().name)
331+
result.append(currentPath.getFeature().name)
328332
if (currentPath.next !== null) {
329333
result.append("->")
330334
}
@@ -336,8 +340,8 @@ class PythonFunctionGenerator {
336340

337341
private def getNextPathElementName(Segment path) {
338342
if (path !== null) {
339-
val attribute = path.getAttribute()
340-
return "'" + attribute.name + "'"
343+
val feature = path.getFeature()
344+
return "'" + feature.name + "'"
341345
}
342346
return null
343347
}
@@ -355,32 +359,32 @@ class PythonFunctionGenerator {
355359

356360
}
357361

358-
private def String generateFullPath(Iterable<Attribute> attrs, String root) {
359-
if (attrs.isEmpty) {
362+
private def String generateFullPath(Iterable<RosettaFeature> features, String root) {
363+
if (features.isEmpty) {
360364
return "self"
361365
}
362366

363-
val attr = attrs.head
364-
val remainingAttrs = attrs.tail.toList
367+
val attr = features.head
368+
val remainingAttrs = features.tail.toList
365369

366370
val nextPath = if (remainingAttrs.isEmpty) '''rune_resolve_attr(self, «root»)''' else generateFullPath(
367371
remainingAttrs, root)
368372

369373
return '''rune_resolve_attr(«nextPath», '«attr.name»')'''
370374
}
371375

372-
private def getReversedAttributes(Segment segment) {
373-
val attributes = new ArrayList<Attribute>();
376+
private def getReversedFeatures(Segment segment) {
377+
val features = new ArrayList<RosettaFeature>();
374378
var current = segment;
375379

376380
while (current !== null) {
377-
attributes.add(current.getAttribute());
381+
features.add(current.getFeature());
378382
current = current.getNext();
379383
}
380384

381-
Collections.reverse(attributes);
385+
Collections.reverse(features);
382386

383-
return attributes;
387+
return features;
384388
}
385389

386390
def addImportsFromConditions(String variable, String namespace) {
@@ -389,4 +393,4 @@ class PythonFunctionGenerator {
389393
importsFound.add(import)
390394
}
391395
}
392-
}
396+
}

0 commit comments

Comments
 (0)