Skip to content

Commit

Permalink
Add dependencies into component model
Browse files Browse the repository at this point in the history
  • Loading branch information
madushajg committed Jun 28, 2023
1 parent 329d876 commit ba0dd17
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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.Dependency;
import io.ballerina.architecturemodelgenerator.core.model.service.Service;
import io.ballerina.projects.Package;

Expand All @@ -42,16 +43,20 @@ public class ArchitectureModel {
private final Map<String, Entity> entities;
private final FunctionEntryPoint functionEntryPoint;

private final List<Dependency> dependencies;

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

public String getVersion() {
Expand Down Expand Up @@ -82,6 +87,10 @@ public boolean hasCompilationErrors() {
return hasCompilationErrors;
}

public List<Dependency> getDependencies() {
return dependencies;
}

/**
* Represent current package information.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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.Dependency;
import io.ballerina.architecturemodelgenerator.core.model.service.Service;
import io.ballerina.projects.Package;
import io.ballerina.projects.PackageCompilation;
Expand Down Expand Up @@ -97,7 +98,14 @@ public ArchitectureModel constructComponentModel(Package currentPackage, Package
}
});

List<Dependency> allDependencies = new ArrayList<>();

for (Service service : services.values()) {
List<Dependency> dependencies = service.getDependencies();
allDependencies.addAll(dependencies);
}

return new ArchitectureModel(Constants.MODEL_VERSION, packageId, diagnostics, services, entities,
functionEntryPoint.get(), hasDiagnosticErrors.get());
functionEntryPoint.get(), hasDiagnosticErrors.get(), allDependencies);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public CompletableFuture<PersistERModelResponse> getPersistERModels(PersistERMod
}

ArchitectureModel architectureModel = new ArchitectureModel(Constants.MODEL_VERSION, null,
response.getDiagnostics(), new HashMap<>(), entities, null, hasDiagnosticErrors.get());
response.getDiagnostics(), new HashMap<>(), entities, null, hasDiagnosticErrors.get(), null);
Gson gson = new GsonBuilder().serializeNulls().create();
JsonObject persistERModel = (JsonObject) gson.toJsonTree(architectureModel);

Expand Down

0 comments on commit ba0dd17

Please sign in to comment.