Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ public enum ArtifactType {
XSLT_RESOURCE,
XQUERY_VARIABLE,
SWAGGER,
CONNECTOR,
CONNECTION
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.eclipse.lemminx.customservice.synapse.dependency.tree.pojo;

import org.eclipse.lemminx.customservice.synapse.dependency.tree.ArtifactType;

public class ConnectorDependency extends Dependency {

private String operationName;

public ConnectorDependency(String name, ArtifactType type,
Comment thread
thuva9872 marked this conversation as resolved.
Outdated
String path) {

super(name, type, path);
}

public String getOperationName() {

return operationName;
}

public void setOperationName(String operationName) {

this.operationName = operationName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.lemminx.customservice.synapse.dependency.tree.ArtifactType;
import org.eclipse.lemminx.customservice.synapse.dependency.tree.DependencyLookUp;
import org.eclipse.lemminx.customservice.synapse.dependency.tree.DependencyVisitorUtils;
import org.eclipse.lemminx.customservice.synapse.dependency.tree.pojo.ConnectorDependency;
import org.eclipse.lemminx.customservice.synapse.dependency.tree.pojo.Dependency;
import org.eclipse.lemminx.customservice.synapse.syntaxTree.pojo.connector.ai.AIAgent;
import org.eclipse.lemminx.customservice.synapse.syntaxTree.pojo.connector.ai.AIChat;
Expand Down Expand Up @@ -181,6 +182,14 @@ protected void visitConnector(Connector node) {
if (node.getConfigKey() != null) {
addSimpleDependency(node.getConfigKey(), "connector", ArtifactType.CONNECTION);
}
addConnectorUsageDependency(node);
}

private void addConnectorUsageDependency(Connector node) {

ConnectorDependency dependency = new ConnectorDependency(node.getConnectorName(), ArtifactType.CONNECTOR, null);
dependency.setOperationName(node.getMethod());
dependencies.add(dependency);
}

@Override
Expand Down Expand Up @@ -737,6 +746,7 @@ protected void visitAIAgent(AIAgent node) {
}
}
}
addConnectorUsageDependency(node);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.lemminx.customservice.synapse.dependency.tree.DependencyScanner;
import org.eclipse.lemminx.customservice.synapse.dependency.tree.pojo.ConnectorDependency;
import org.eclipse.lemminx.customservice.synapse.dependency.tree.pojo.Dependency;
import org.eclipse.lemminx.customservice.synapse.dependency.tree.pojo.DependencyTree;
import org.eclipse.lemminx.customservice.synapse.directoryTree.DirectoryMapResponse;
import org.eclipse.lemminx.customservice.synapse.directoryTree.DirectoryTreeBuilder;
import org.eclipse.lemminx.customservice.synapse.parser.config.ConfigParser;
import org.eclipse.lemminx.customservice.synapse.utils.Constant;
import org.eclipse.lemminx.customservice.synapse.utils.Utils;
import org.eclipse.lsp4j.WorkspaceFolder;

import java.util.ArrayList;
Expand All @@ -35,6 +40,7 @@
public class OverviewPage {

private static final Logger LOGGER = Logger.getLogger(OverviewPage.class.getName());
private static final List<String> AI_AGENT_SUPPORTED_ARTIFACTS = List.of(Constant.API_ARTIFACTS, Constant.SEQUENCE);

public static OverviewPageDetailsResponse getDetails(String projectUri) {
OverviewPageDetailsResponse pomDetailsResponse = new OverviewPageDetailsResponse();
Expand Down Expand Up @@ -71,10 +77,56 @@ public static List<String> getProjectIntegrationType(WorkspaceFolder projectFold
}
}
}

if (hasAIAgent(projectFolder, artifacts)) {
integrationTypes.add(Constant.AI_AGENT);
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Error occurred while checking project integration type.", e);
}
}
return integrationTypes;
}

private static boolean hasAIAgent(WorkspaceFolder projectFolder, JsonNode artifacts) {

String projectPath = Utils.getAbsolutePath(projectFolder.getUri());
if (projectPath == null) {
Comment thread
thuva9872 marked this conversation as resolved.
Outdated
return false;
}
DependencyScanner dependencyScanner = new DependencyScanner(projectPath);

for (String artifactType : AI_AGENT_SUPPORTED_ARTIFACTS) {
if (hasAIAgent(dependencyScanner, artifacts, artifactType)) {
return true;
}
}
return false;
}

private static boolean hasAIAgent(DependencyScanner dependencyScanner, JsonNode artifacts, String artifactType) {

if (!artifacts.has(artifactType) || artifacts.path(artifactType).isEmpty()) {
return false;
}
JsonNode artifactList = artifacts.path(artifactType);
for (JsonNode apiArtifact : artifactList) {
String path = apiArtifact.path(Constant.PATH).asText();
DependencyTree dependencyTree = dependencyScanner.analyzeArtifact(path);
boolean result = dependencyTree.getDependencyList()
.stream()
.anyMatch(OverviewPage::isAIAgent);
if (result) {
return true;
}
}
return false;
}

private static boolean isAIAgent(Dependency dependency) {

return dependency instanceof ConnectorDependency &&
Constant.AI.equalsIgnoreCase(dependency.getName()) &&
Constant.AGENT.equalsIgnoreCase(((ConnectorDependency) dependency).getOperationName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,8 @@ public class Constant {
public static final String AI = "AI";
public static final String AGENT_ID = "agentID";
public static final String RESULT_EXPRESSION = "resultExpression";
public static final String AI_AGENT = "AI_AGENT";
public static final String AGENT = "agent";

static {
// AI Connection to Display Name bi-Mapping
Expand Down