Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement datamapper #532

Merged
merged 40 commits into from
Jan 9, 2025

Conversation

KavinduZoysa
Copy link
Contributor

Purpose

$subject

@KavinduZoysa KavinduZoysa force-pushed the data-mapped-model branch 2 times, most recently from 82ff345 to 004da77 Compare January 6, 2025 15:42
@KavinduZoysa KavinduZoysa merged commit 9c82ad6 into ballerina-platform:main Jan 9, 2025
4 checks passed

resource function post getPerson(@http:Payload User user) returns Person|http:InternalServerError {
do {
// User1 user1 = {user2: {user3: {i3: user.name.length(), user4: {user5: {u: [user.name, user.name]}}}}, s1: user.name};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this line commented? I've noticed this in other test cases too.

Comment on lines +40 to +51
@DataProvider(name = "data-provider")
@Override
protected Object[] getConfigsList() {
return new Object[][]{
{Path.of("variable1.json")},
{Path.of("variable2.json")},
{Path.of("variable3.json")},
{Path.of("variable4.json")},
{Path.of("variable5.json")},
{Path.of("variable6.json")},
{Path.of("variable7.json")},
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, the method captures all the JSON files in the selected directory. No need to specify each JSON file.

DataMapManager dataMapManager = new DataMapManager(workspaceManager, semanticModel.get(),
document.get());
response.setSource(dataMapManager.addElement(request.flowNode(), request.propertyKey(),
Path.of(request.filePath()), request.targetField(), project, request.position()));
Copy link
Contributor

@nipunayf nipunayf Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are few occurrences of this

Suggested change
Path.of(request.filePath()), request.targetField(), project, request.position()));
filePath, request.targetField(), project, request.position()));

return null;
}

Type type = Type.fromSemanticSymbol(targetNode.typeSymbol());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are planning to deprecate this model. Is there a reason why we're sticking to this model instead of using the new types model?

return null;
}

private record TargetNode(TypeSymbol typeSymbol, String name, ExpressionNode expressionNode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we define this at the top?

Comment on lines +623 to +632
for (Map.Entry<String, Object> stringObjectEntry : mappings.entrySet()) {
sb.append(stringObjectEntry.getKey()).append(":");
sb.append(genSource(stringObjectEntry.getValue()));

if (i != len - 1) {
sb.append(",");
}
i = i + 1;
}
sb.append("}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (Map.Entry<String, Object> stringObjectEntry : mappings.entrySet()) {
sb.append(stringObjectEntry.getKey()).append(":");
sb.append(genSource(stringObjectEntry.getValue()));
if (i != len - 1) {
sb.append(",");
}
i = i + 1;
}
sb.append("}");
StringJoiner joiner = new StringJoiner(",");
mappings.forEach((key, value) -> joiner.add(key + ":" + genSource(value)));
sb.append(joiner);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants