Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -50,6 +50,7 @@ public class ConfigurationPropertiesConstants {
public static final String GRPC_SENDER_ELEMENT = "grpc-sender";
public static final String CHAIN_CALL_2_ELEMENT = "chain-call-2";
public static final String HTTP_TRIGGER_ELEMENT = "http-trigger";
public static final String MCP_TRIGGER_ELEMENT = "mcp-trigger";
public static final String SERVICE_CALL_ELEMENT = "service-call";
public static final String CHAIN_CALL_PROPERTY_OPTION = "chain-call";
public static final String HTTP_TRIGGER_FAILURE_HANDLER_ACTION = "handleChainFailureAction";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public void build(
streamWriter.writeAttribute("key", "id");
streamWriter.writeAttribute("value", element.getOriginalId());

streamWriter.writeEmptyElement("property");
streamWriter.writeAttribute("key", "snapshotElementId");
streamWriter.writeAttribute("value", element.getId());

streamWriter.writeEmptyElement("property");
streamWriter.writeAttribute("key", "name");
streamWriter.writeAttribute("value", element.getName());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.qubership.integration.platform.runtime.catalog.cr.sources.builders.xml.beans.builders.element;

import org.codehaus.stax2.XMLStreamWriter2;
import org.qubership.integration.platform.runtime.catalog.cr.sources.SourceBuilderContext;
import org.qubership.integration.platform.runtime.catalog.cr.sources.builders.xml.beans.ElementBeansBuilder;
import org.qubership.integration.platform.runtime.catalog.persistence.configs.entity.chain.element.ChainElement;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.List;
import java.util.Optional;

import static org.qubership.integration.platform.runtime.catalog.consul.ConfigurationPropertiesConstants.MCP_TRIGGER_ELEMENT;

@Component
public class McpTriggerBeansBuilder implements ElementBeansBuilder {
@Override
public boolean applicableTo(ChainElement element) {
String type = element.getType();
return MCP_TRIGGER_ELEMENT.equals(type);
}

@Override
public void build(XMLStreamWriter2 streamWriter, ChainElement element, SourceBuilderContext context) throws Exception {
streamWriter.writeStartElement("bean");
streamWriter.writeAttribute("name", "McpTriggerInfo-" + element.getId());
streamWriter.writeAttribute("type", "org.qubership.integration.platform.engine.metadata.McpTriggerInfo");

streamWriter.writeStartElement("properties");

Collection<String> propertyNames = List.of(
"name",
"title",
"description",
"inputSchema",
"outputSchema",
"readOnly",
"destructive",
"idempotent",
"openWorld",
"requiresLocal"
);

for (String propertyName : propertyNames) {
streamWriter.writeEmptyElement("property");
streamWriter.writeAttribute("key", propertyName);
streamWriter.writeAttribute("value", Optional.ofNullable(element.getProperties().get(propertyName))
.map(String::valueOf)
.orElse(""));
}

streamWriter.writeEndElement();
streamWriter.writeEndElement();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public final class CamelNames {
public static final String MAAS_CLASSIFIER_TENANT_ENABLED_CAMEL_NAME = "maas.classifier.tenantEnabled";
public static final String MAAS_CLASSIFIER_TENANT_ID_CAMEL_NAME = "maas.classifier.tenantId";

public static final String MCP_SERVICE_IDS = "mcpServiceIds";

private CamelNames() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class GeneralImportInstructionsConfig {
private ImportInstructionsConfig contextServices = new ImportInstructionsConfig();
@Valid
@Builder.Default
private ImportInstructionsConfig mcpServices = new ImportInstructionsConfig();
@Valid
@Builder.Default
@JsonIgnoreProperties(value = "ignore")
private ImportInstructionsConfig specificationGroups = new ImportInstructionsConfig();
@Valid
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.qubership.integration.platform.runtime.catalog.model.exportimport.system;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;
import org.qubership.integration.platform.runtime.catalog.persistence.configs.entity.User;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
@SuperBuilder
@Jacksonized
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MCPServiceContentDto {
private String description;
private String identifier;
private String instructions;
private Timestamp createdWhen;
private Timestamp modifiedWhen;
private User createdBy;
private User modifiedBy;
private String migrations;

@Builder.Default
private List<String> labels = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.qubership.integration.platform.runtime.catalog.model.exportimport.system;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;

import java.net.URI;

@Getter
@Setter
@SuperBuilder
@Jacksonized
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonPropertyOrder({ "id", "schema", "name", "content" })
public class MCPServiceDto {
@JsonProperty(value = "$schema", index = 0)
private URI schema;
private String id;
private String name;
MCPServiceContentDto content;
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,7 @@ public enum FilterFeature {
SESSION_DURATION,
EXCHANGE_DURATION,
MAIN_THREAD,
POD_IP
POD_IP,
IDENTIFIER,
INSTRUCTIONS,
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@
import java.util.zip.ZipOutputStream;

public interface ExportableObject {
String getId();

void accept(ExportableObjectWriterVisitor visitor, ZipOutputStream zipOut, String entryPath) throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.qubership.integration.platform.runtime.catalog.model.system.exportimport;

import com.fasterxml.jackson.databind.node.ObjectNode;
import org.qubership.integration.platform.runtime.catalog.service.exportimport.serializer.ExportableObjectWriterVisitor;

import java.io.IOException;
import java.util.zip.ZipOutputStream;

public class ExportedMCPSystemObject extends ExportedSystemObject {
public ExportedMCPSystemObject(String id, ObjectNode objectNode) {
super(id, objectNode);
}

@Override
public void accept(ExportableObjectWriterVisitor visitor, ZipOutputStream zipOut, String entryPath) throws IOException {
visitor.visit(this, zipOut, entryPath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public enum EntityType {
CHAIN_RUNTIME_PROPERTIES,
DATABASE_SYSTEM, //removed databases in 24.3
CONTEXT_SYSTEM,
MCP_SYSTEM,
DATABASE_SCRIPT, //This types remained to avoid error with old actions(in action log) with databases
SERVICE_DISCOVERY,
EXTERNAL_SERVICE,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.qubership.integration.platform.runtime.catalog.persistence.configs.entity.mcp;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Transient;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.FieldNameConstants;
import lombok.experimental.SuperBuilder;
import org.qubership.integration.platform.runtime.catalog.persistence.configs.entity.chain.Chain;
import org.qubership.integration.platform.runtime.catalog.persistence.configs.entity.system.AbstractSystemEntity;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;

import static jakarta.persistence.CascadeType.*;

@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@FieldNameConstants
@Entity(name = "mcp_systems")
public class MCPSystem extends AbstractSystemEntity {
@Column
private String identifier;

@Column
private String instructions;

@Builder.Default
@OneToMany(mappedBy = "system",
orphanRemoval = true,
cascade = {PERSIST, REMOVE, MERGE}
)
private Set<MCPSystemLabel> labels = new LinkedHashSet<>();

@Transient
private List<Chain> chains;

@Override
public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}
if (!(o instanceof MCPSystem mcpSystem)) {
return false;
}
return Objects.equals(identifier, mcpSystem.identifier) && Objects.equals(instructions, mcpSystem.instructions);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), getIdentifier(), getInstructions(), getChains());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.qubership.integration.platform.runtime.catalog.persistence.configs.entity.mcp;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;
import org.qubership.integration.platform.runtime.catalog.persistence.configs.entity.AbstractLabel;

import java.util.Objects;

@Getter
@Setter
@Slf4j
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Entity(name = "mcp_system_labels")
public class MCPSystemLabel extends AbstractLabel {
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "mcp_system_id")
private MCPSystem system;

public MCPSystemLabel(String name, MCPSystem system) {
super(name);
this.system = system;
}

public MCPSystemLabel(String name, boolean technical, MCPSystem system) {
super(name, technical);
this.system = system;
}

@Override
public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}
MCPSystemLabel that = (MCPSystemLabel) o;
return Objects.equals(getSystem(), that.getSystem());
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), getSystem());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,30 @@ WITH RECURSIVE parent_folders AS (
)
List<Chain> findAllChainsInFolders(List<String> folderIds);

@Query(
nativeQuery = true,
value = """
select distinct on (chain.id) chain.*
from catalog.chains chain
inner join catalog.elements element
on element.chain_id = chain.id
where jsonb_extract_path_text(element.properties, :property) = :value
"""
)
List<Chain> findChainsWithElementPropertyValue(String property, String value);

@Query(
nativeQuery = true,
value = """
select distinct on (chain.id) chain.*
from catalog.chains chain
inner join catalog.elements element
on element.chain_id = chain.id
where jsonb_exists(jsonb_extract_path(element.properties, :property), :value)
"""
)
List<Chain> findChainsWithElementPropertyContainsValue(String property, String value);

@Query(
nativeQuery = true,
value = """
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.qubership.integration.platform.runtime.catalog.persistence.configs.repository.mcp;

import org.qubership.integration.platform.runtime.catalog.persistence.configs.entity.mcp.MCPSystem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

public interface MCPSystemRepository extends JpaRepository<MCPSystem, String>, JpaSpecificationExecutor<MCPSystem> {

}
Loading
Loading