Skip to content

Commit

Permalink
Fix for meta generation (finos#832)
Browse files Browse the repository at this point in the history
* Fix

* Fix
  • Loading branch information
SimonCockx authored Sep 10, 2024
1 parent 64c4d0e commit 7b89343
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ class FunctionGenerator {
}

private def StringConcatenationClient inputsAsParameters(List<RAttribute> inputs, JavaScope scope) {
'''«FOR input : inputs SEPARATOR ', '»«input.toMetaJavaType» «scope.getIdentifierOrThrow(input)»«ENDFOR»'''
'''«FOR input : inputs SEPARATOR ', '»«input.toJavaType» «scope.getIdentifierOrThrow(input)»«ENDFOR»'''
}

private def JavaReferenceType shortcutJavaType(RShortcut feature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public JavaReferenceType operationToJavaType(ROperation op) {
List<RAttribute> segments = op.getPathTail();
attr = segments.get(segments.size() - 1);
}
return toMetaJavaType(attr);
return toJavaType(attr);
}
public JavaClass<?> operationToReferenceWithMetaType(ROperation op) {
RAttribute attr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,32 @@ class FunctionGeneratorTest {
@Inject extension ModelHelper
@Inject extension ValidationTestHelper

@Test
def void assignToMultiMetaFeature() {
val code = '''
type A:
a string (0..*)
[metadata reference]
func Test:
output:
result A (1..1)
add result -> a:
"Hello"
'''.generateCode

val classes = code.compileToClasses
val a = classes.createInstanceUsingBuilder("A", #{
"a" -> #[classes.createInstanceUsingBuilder(new RootPackage("com.rosetta.model.metafields"), "ReferenceWithMetaString", #{
"value" -> "Hello"
})]
})

val testOnlyExists = classes.createFunc("Test")
assertEquals(a, testOnlyExists.invokeFunc(a.class, #[]))
}

@Test
def void onlyExistsOnAbsentParent() {
val code = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,12 @@ class ConfigurableTypeTabulatorTest {
val model2 = '''
namespace model2
metaType scheme string
type Root:
engineSpecification EngineSpecification (1..1)
type Root:
engineSpecification EngineSpecification (1..1)
type EngineSpecification:
fuel string (1..*)
[metadata scheme]
type EngineSpecification:
fuel string (1..*)
[metadata scheme]
'''

val model2Code = model2.generateCodeForModel(Model2FileConfigProvider)
Expand Down

0 comments on commit 7b89343

Please sign in to comment.