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

[Tooling BE model revamp] Move dependencies into component level #262

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
83eedb5
Migrate to Java 17
gabilang Jul 2, 2023
dcc824e
Merge pull request #258 from gabilang/java_17_migration
warunalakshitha Jul 4, 2023
90d6f9b
Add required dependencies
gabilang Jul 4, 2023
a440da5
Merge pull request #259 from gabilang/java17_migr
warunalakshitha Jul 4, 2023
f970093
[Gradle Release Plugin] - pre tag commit: 'v1.2.0'.
Jul 4, 2023
6343c69
[Gradle Release Plugin] - new version commit: 'v1.2.1-SNAPSHOT'.
Jul 4, 2023
82d3068
Merge pull request #261 from ballerina-platform/release-1.2.0
NipunaRanasinghe Jul 12, 2023
44f6a83
Change gradle version to 7.6.2
gabilang Jul 16, 2023
97f6c56
Merge pull request #268 from gabilang/fix-download-links
gabilang Jul 16, 2023
12f2d28
Update log version to latest time-stamp
warunalakshitha Jul 18, 2023
ad25037
Merge branch 'main' into java_17_migration
gabilang Jul 26, 2023
488698b
Add git attribute file
gabilang Jul 26, 2023
596dcbe
Update lang version
gabilang Jul 26, 2023
3df3cee
Update lang version
gabilang Jul 26, 2023
9c12817
Upgrade gradle to version 8.2.1
gabilang Jul 28, 2023
742f505
Merge pull request #272 from gabilang/upgrade-gradle
gabilang Jul 28, 2023
0169497
Add doNotTrackState to omit incremental builds
gabilang Jul 28, 2023
0b7473d
Add doNotTrackState to omit incremental builds
gabilang Jul 28, 2023
6f87361
Merge pull request #271 from ballerina-platform/java_17_migration
warunalakshitha Jul 31, 2023
de475cc
Update Java version to 17.0.7 in workflows
gabilang Aug 14, 2023
6f6c6d9
Update source compatibility java version
gabilang Aug 15, 2023
6ea7c1f
Update git actions and node version
gabilang Aug 15, 2023
2e7a928
Specify jdk distribution in workflows
gabilang Aug 15, 2023
c48cbd0
Use node version 16.15.1
gabilang Aug 15, 2023
d5d56b6
Revert node version change
gabilang Aug 15, 2023
5fe3c8d
Revert setup-node action version
gabilang Aug 15, 2023
c6d4848
Merge pull request #277 from gabilang/update-worflow-java-ver
warunalakshitha Aug 15, 2023
c251aa3
Bump react script version
gayaldassanayake Aug 17, 2023
3063dd0
Merge pull request #279 from gayaldassanayake/bump-ts-version
gayaldassanayake Aug 18, 2023
9fa10fe
Add dependencies into component model
madushajg Jun 28, 2023
acb6678
Include dependencyIDs in Service model instead of dependencies
madushajg Jun 28, 2023
7931dcc
Update simple_service_sample.json
madushajg Jul 6, 2023
96b6a87
Update expected jsons in architecture-model-generator-ls-extension tests
madushajg Jul 6, 2023
fd61b54
Bump the model version
madushajg Jul 6, 2023
cfa3a69
Update FunctionEntryPoint to keep dependencyIDs
madushajg Jul 13, 2023
6c345ea
Allow packageId to contain string values
madushajg Jul 13, 2023
f701d7f
Remove EntrypointID composite key
madushajg Jul 13, 2023
40d3123
Update expected jsons
madushajg Jul 13, 2023
4c146b4
Derive serviceId from the service itself
madushajg Jul 17, 2023
b5ed937
Drop servicePath from Service model
madushajg Jul 17, 2023
cb6e8c6
Update expected jsons
madushajg Jul 17, 2023
d412743
Remove PackageId and stick with String typed componentId
madushajg Jul 26, 2023
c2855a7
Add orgName and version to ArchitectureModel
madushajg Jul 26, 2023
cb60bf4
Refactor the architecture model
madushajg Aug 11, 2023
1b584c4
Update tests
madushajg Aug 22, 2023
de6f85f
Stop generating UUIDs as serviceIds
madushajg Aug 24, 2023
8a138a1
Add serviceId to interactions
madushajg Aug 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ensure all Java files use LF.
*.java eol=lf
9 changes: 5 additions & 4 deletions .github/workflows/build-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '10.22.1'

- name: Set up JDK 11.0.7
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11.0.7
distribution: 'temurin'
java-version: 17.0.7

- name: Change to Timestamped Version
run: |
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/daily-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '10.22.1'

- name: Set up JDK 11.0.7
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11.0.7
distribution: 'temurin'
java-version: 17.0.7
- name: Build with Gradle
env:
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
Expand All @@ -32,17 +33,18 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '10.22.1'

- name: Set up JDK 11.0.7
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11.0.7
distribution: 'temurin'
java-version: 17.0.7
- name: Build with Gradle
env:
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ jobs:
publish-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '10.22.1'

- name: Set up JDK 11.0.7
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11.0.7
distribution: 'temurin'
java-version: 17.0.7
- name: Set version env variable
run: echo VERSION=$((grep -w "version" | cut -d= -f2) < gradle.properties | cut -d- -f1) >> $GITHUB_ENV
- name: Pre release depenency version update
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '10.22.1'

- name: Set up JDK 11.0.7
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11.0.7
distribution: 'temurin'
java-version: 17.0.7
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
Expand All @@ -36,15 +37,16 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '10.22.1'
- name: Set up JDK 11.0.7
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11.0.7
distribution: 'temurin'
java-version: 17.0.7
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import io.ballerina.architecturemodelgenerator.core.diagnostics.ArchitectureModelDiagnostic;
import io.ballerina.architecturemodelgenerator.core.model.entity.Entity;
import io.ballerina.architecturemodelgenerator.core.model.functionentrypoint.FunctionEntryPoint;
import io.ballerina.architecturemodelgenerator.core.model.service.Connection;
import io.ballerina.architecturemodelgenerator.core.model.service.Service;
import io.ballerina.projects.Package;

import java.util.List;
import java.util.Map;
Expand All @@ -34,32 +34,47 @@
*/
public class ArchitectureModel {

private final String modelVersion;
private final String id;
private final String orgName;
private final String version;
private final PackageId packageId;
private final boolean hasCompilationErrors;
private final List<ArchitectureModelDiagnostic> diagnostics;
private final Map<String, Service> services;
private final Map<String, Entity> entities;
private final FunctionEntryPoint functionEntryPoint;

public ArchitectureModel(String version, PackageId packageId, List<ArchitectureModelDiagnostic> diagnostics,
Map<String, Service> services, Map<String, Entity> entities,
FunctionEntryPoint functionEntryPoint, boolean hasCompilationErrors) {
private final List<Connection> connections;

public ArchitectureModel(String modelVersion, String id, String orgName, String version,
List<ArchitectureModelDiagnostic> diagnostics, Map<String, Service> services,
Map<String, Entity> entities, FunctionEntryPoint functionEntryPoint,
boolean hasCompilationErrors, List<Connection> dependencies) {
this.modelVersion = modelVersion;
this.id = id;
this.orgName = orgName;
this.version = version;
this.packageId = packageId;
this.diagnostics = diagnostics;
this.services = services;
this.entities = entities;
this.functionEntryPoint = functionEntryPoint;
this.hasCompilationErrors = hasCompilationErrors;
this.connections = dependencies;
}

public String getVersion() {
return version;
public String getModelVersion() {
return modelVersion;
}

public String getId() {
return String.format("%s/%s:%s", orgName, id, version);
}

public String getOrgName() {
return orgName;
}

public PackageId getPackageId() {
return packageId;
public String getVersion() {
return version;
}

public List<ArchitectureModelDiagnostic> getDiagnostics() {
Expand All @@ -82,31 +97,7 @@ public boolean hasCompilationErrors() {
return hasCompilationErrors;
}

/**
* Represent current package information.
*/
public static class PackageId {

private final String name;
private final String org;
private final String version;

public PackageId(Package currentPackage) {
this.name = currentPackage.packageName().value();
this.org = currentPackage.packageOrg().value();
this.version = currentPackage.packageVersion().value().toString();
}

public String getName() {
return name;
}

public String getOrg() {
return org;
}

public String getVersion() {
return version;
}
public List<Connection> getConnections() {
return connections;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package io.ballerina.architecturemodelgenerator.core;

import io.ballerina.architecturemodelgenerator.core.ArchitectureModel.PackageId;
import io.ballerina.architecturemodelgenerator.core.diagnostics.ArchitectureModelDiagnostic;
import io.ballerina.architecturemodelgenerator.core.diagnostics.DiagnosticMessage;
import io.ballerina.architecturemodelgenerator.core.diagnostics.DiagnosticNode;
Expand All @@ -27,6 +26,7 @@
import io.ballerina.architecturemodelgenerator.core.generators.service.ServiceModelGenerator;
import io.ballerina.architecturemodelgenerator.core.model.entity.Entity;
import io.ballerina.architecturemodelgenerator.core.model.functionentrypoint.FunctionEntryPoint;
import io.ballerina.architecturemodelgenerator.core.model.service.Connection;
import io.ballerina.architecturemodelgenerator.core.model.service.Service;
import io.ballerina.projects.Package;
import io.ballerina.projects.PackageCompilation;
Expand Down Expand Up @@ -54,9 +54,12 @@ public ArchitectureModel constructComponentModel(Package currentPackage, Package
// todo: Change to TypeDefinition
Map<String, Entity> entities = new HashMap<>();
List<ArchitectureModelDiagnostic> diagnostics = new ArrayList<>();
List<Connection> allDependencies = new ArrayList<>();
AtomicReference<FunctionEntryPoint> functionEntryPoint = new AtomicReference<>();
PackageId packageId = new PackageId(currentPackage);
AtomicBoolean hasDiagnosticErrors = new AtomicBoolean(false);
String packageOrg = currentPackage.packageOrg().value();
String packageName = currentPackage.packageName().value();
String packageVersion = currentPackage.packageVersion().value().toString();

currentPackage.modules().forEach(module -> {
PackageCompilation currentPackageCompilation = packageCompilation == null ?
Expand All @@ -67,7 +70,9 @@ public ArchitectureModel constructComponentModel(Package currentPackage, Package

ServiceModelGenerator serviceModelGenerator = new ServiceModelGenerator(currentPackageCompilation, module);
try {
services.putAll(serviceModelGenerator.generate());
serviceModelGenerator.generate();
services.putAll(serviceModelGenerator.getServices());
allDependencies.addAll(serviceModelGenerator.getDependencies());
} catch (Exception e) {
DiagnosticMessage message = DiagnosticMessage.failedToGenerate(DiagnosticNode.SERVICES,
e.getMessage());
Expand All @@ -91,13 +96,15 @@ public ArchitectureModel constructComponentModel(Package currentPackage, Package

FunctionEntryPointModelGenerator functionEntryPointModelGenerator =
new FunctionEntryPointModelGenerator(currentPackageCompilation, module);
FunctionEntryPoint generatedFunctionEntryPoint = functionEntryPointModelGenerator.generate();
functionEntryPointModelGenerator.generate();
FunctionEntryPoint generatedFunctionEntryPoint = functionEntryPointModelGenerator.getFunctionEntryPoint();
if (generatedFunctionEntryPoint != null) {
functionEntryPoint.set(functionEntryPointModelGenerator.generate());
functionEntryPoint.set(generatedFunctionEntryPoint);
allDependencies.addAll(functionEntryPointModelGenerator.getDependencies());
}
});

return new ArchitectureModel(Constants.MODEL_VERSION, packageId, diagnostics, services, entities,
functionEntryPoint.get(), hasDiagnosticErrors.get());
return new ArchitectureModel(Constants.MODEL_VERSION, packageName, packageOrg, packageVersion, diagnostics,
services, entities, functionEntryPoint.get(), hasDiagnosticErrors.get(), allDependencies);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public String getValue() {
}
}

public static final String MODEL_VERSION = "0.3.1";
public static final String MODEL_VERSION = "0.4.0";
public static final String COLON = ":";
public static final String FORWARD_SLASH = "/";
public static final String SERVICE_ANNOTATION = "choreo:Service";
Expand All @@ -71,6 +71,7 @@ public String getValue() {
public static final String CONSTRAINT_ARRAY = "Array";
public static final String MIN_LENGTH_FIELD = "minLength";
public static final String MAX_LENGTH_FIELD = "maxLength";
public static final String DEFAULT_SERVICE_BASE_PATH = "_defaultBasePath";

// REST Methods
public static final String GET_KEYWORD = "get";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

package io.ballerina.architecturemodelgenerator.core.generators;

import io.ballerina.architecturemodelgenerator.core.ArchitectureModel;
import io.ballerina.architecturemodelgenerator.core.model.ElementLocation;
import io.ballerina.architecturemodelgenerator.core.model.SourceLocation;
import io.ballerina.architecturemodelgenerator.core.model.common.DisplayAnnotation;
import io.ballerina.compiler.api.SemanticModel;
import io.ballerina.compiler.api.symbols.Annotatable;
Expand Down Expand Up @@ -70,29 +69,29 @@
*/
public class GeneratorUtils {

public static ElementLocation getElementLocation(String filePath, LineRange lineRange) {
public static SourceLocation getSourceLocation(String filePath, LineRange lineRange) {

ElementLocation.LinePosition startPosition = ElementLocation.LinePosition.from(
SourceLocation.LinePosition startPosition = SourceLocation.LinePosition.from(
lineRange.startLine().line(), lineRange.startLine().offset());
ElementLocation.LinePosition endLinePosition = ElementLocation.LinePosition.from(
SourceLocation.LinePosition endLinePosition = SourceLocation.LinePosition.from(
lineRange.endLine().line(), lineRange.endLine().offset()
);
return ElementLocation.from(filePath, startPosition, endLinePosition);
return SourceLocation.from(filePath, startPosition, endLinePosition);

}

public static DisplayAnnotation getServiceAnnotation(NodeList<AnnotationNode> annotationNodes, String filePath) {

String id = UUID.randomUUID().toString();
String id = "";
String label = "";
ElementLocation elementLocation = null;
SourceLocation elementLocation = null;
for (AnnotationNode annotationNode : annotationNodes) {
String annotationName = annotationNode.annotReference().toString().trim();
if (!(annotationName.equals(DISPLAY_ANNOTATION) && annotationNode.annotValue().isPresent())) {
continue;
}
SeparatedNodeList<MappingFieldNode> fields = annotationNode.annotValue().get().fields();
elementLocation = getElementLocation(filePath, annotationNode.lineRange());
elementLocation = getSourceLocation(filePath, annotationNode.lineRange());
for (MappingFieldNode mappingFieldNode : fields) {
if (mappingFieldNode.kind() != SyntaxKind.SPECIFIC_FIELD) {
continue;
Expand Down Expand Up @@ -121,7 +120,7 @@ public static DisplayAnnotation getServiceAnnotation(Annotatable annotableSymbol

String id = null;
String label = "";
ElementLocation elementLocation = null;
SourceLocation elementLocation = null;

List<AnnotationSymbol> annotSymbols = annotableSymbol.annotations();
List<AnnotationAttachmentSymbol> annotAttachmentSymbols = annotableSymbol.annotAttachments();
Expand All @@ -131,7 +130,7 @@ public static DisplayAnnotation getServiceAnnotation(Annotatable annotableSymbol
AnnotationAttachmentSymbol annotAttachmentSymbol = annotAttachmentSymbols.get(i);
String annotName = annotSymbol.getName().orElse("");
elementLocation = annotAttachmentSymbol.getLocation().isPresent() ?
getElementLocation(filePath, annotAttachmentSymbol.getLocation().get().lineRange()) : null;
getSourceLocation(filePath, annotAttachmentSymbol.getLocation().get().lineRange()) : null;
if (!annotName.equals(DISPLAY_ANNOTATION) || annotAttachmentSymbol.attachmentValue().isEmpty() ||
!(annotAttachmentSymbol.attachmentValue().get().value() instanceof LinkedHashMap) ||
!annotAttachmentSymbol.isConstAnnotation()) {
Expand Down Expand Up @@ -220,9 +219,8 @@ public static List<String> getReferencedType(TypeSymbol typeSymbol, Package curr

private static String getReferenceEntityName(TypeReferenceTypeSymbol typeReferenceTypeSymbol,
Package currentPackage) {
ArchitectureModel.PackageId packageId = new ArchitectureModel.PackageId(currentPackage);
String currentPackageName = String.format
("%s/%s:%s", packageId.getOrg(), packageId.getName(), packageId.getVersion());
String currentPackageName = String.format("%s/%s:%s", currentPackage.packageOrg().value(),
currentPackage.packageName().value(), currentPackage.packageVersion().value());
String referenceType = typeReferenceTypeSymbol.signature();
if (typeReferenceTypeSymbol.getModule().isPresent() &&
!referenceType.split(":")[0].equals(currentPackageName.split(":")[0])) {
Expand Down
Loading
Loading