Skip to content
Open
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 @@ -23,6 +23,7 @@
import modelengine.fit.jober.aipp.util.JsonUtils;

import modelengine.fitframework.annotation.Component;
import modelengine.fitframework.annotation.Value;
import modelengine.fitframework.inspection.Validation;
import modelengine.fitframework.util.ObjectUtils;

Expand All @@ -47,6 +48,9 @@ public class AppVersionToAppDtoConverter implements EntityConverter {
private static final String FORM_PROPERTY_GROUP_NULL = "null";
private final IconConverter iconConverter;

@Value("${app-engine.chat-path.format}")
private String chatPathFormat;

@Override
public Class<AppVersion> source() {
return AppVersion.class;
Expand Down Expand Up @@ -83,7 +87,7 @@ public AppBuilderAppDto convert(Object appVersion) {
.configFormProperties(this.buildConfigFormProperties(s.getFormProperties()));
Optional.ofNullable(s.getData().getPath())
.filter(path -> !path.isEmpty())
.ifPresent(path -> appDtoBuilder.chatUrl(String.format("/chat/%s", path)));
.ifPresent(path -> appDtoBuilder.chatUrl(String.format(this.chatPathFormat, path)));
return appDtoBuilder.build();
}).orElse(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public class AppVersion {
private final FlowDefinitionService flowDefinitionService;
private final KnowledgeCenterService knowledgeCenterService;
private final String resourcePath;
private final String chatPathFormat;

AppVersion(AppBuilderAppPo data, Dependencies dependencies) {
this.data = data;
Expand Down Expand Up @@ -233,6 +234,7 @@ public class AppVersion {
this.maxUserContextLen = dependencies.getMaxUserContextLen();
this.knowledgeCenterService = dependencies.getKnowledgeCenterService();
this.resourcePath = dependencies.getResourcePath();
this.chatPathFormat = dependencies.getChatPathFormat();
}

/**
Expand Down Expand Up @@ -344,12 +346,17 @@ public void publish(PublishContext context) {
// 判断版本是否已存在.
this.validateVersion(context);

// 发布时候需要用到 path 字段,所以需要提前生成一个唯一的 path
if (StringUtils.isBlank(this.data.getPath())) {
this.data.setPath(this.generateUniquePath());
}

// 发布.
List<Publisher> publishers = new ArrayList<>();
publishers.add(new GraphPublisher(this.flowGraphRepository));
publishers.add(new FormProperyPublisher(this.formPropertyRepository));
publishers.add(new FlowPublisher(this.flowsService));
publishers.add(new StorePublisher(this.appService, this.pluginService, this.toolService));
publishers.add(new StorePublisher(this.appService, this.pluginService, this.toolService, this.chatPathFormat));
publishers.add(new TaskPublisher(this.appTaskService));
publishers.forEach(p -> p.publish(context, this));

Expand All @@ -364,9 +371,6 @@ public void publish(PublishContext context) {
this.attributes.put(PUBLISH_UPDATE_DESCRIPTION_KEY, context.getPublishData().getPublishedDescription());
this.attributes.put(PUBLISH_UPDATE_LOG_KEY, context.getPublishData().getPublishedUpdateLog());
this.attributes.put(ATTR_APP_IS_UPDATE, true);
if (StringUtils.isBlank(this.data.getPath())) {
this.data.setPath(this.generateUniquePath());
}
this.appVersionRepository.update(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class AppVersionFactory {
private final KnowledgeCenterService knowledgeCenterService;
private final String resourcePath;
private final IconConverter iconConverter;
private final String chatPathFormat;

public AppVersionFactory(AppBuilderFormPropertyRepository formPropertyRepository, AppTaskService appTaskService,
AppBuilderConfigRepository configRepository, AppBuilderFormRepository formRepository,
Expand All @@ -85,7 +86,7 @@ public AppVersionFactory(AppBuilderFormPropertyRepository formPropertyRepository
@Value("${app-engine.question.max-length}") Integer maxQuestionLen,
@Value("${app-engine.user-context.max-length}") Integer maxUserContextLen,
KnowledgeCenterService knowledgeCenterService, @Value("${app-engine.resource.path}") String resourcePath,
IconConverter iconConverter) {
IconConverter iconConverter, @Value("${app-engine.chat-path.format}") String chatPathFormat) {
this.formPropertyRepository = formPropertyRepository;
this.appTaskService = appTaskService;
this.configRepository = configRepository;
Expand All @@ -112,6 +113,7 @@ public AppVersionFactory(AppBuilderFormPropertyRepository formPropertyRepository
this.knowledgeCenterService = knowledgeCenterService;
this.resourcePath = resourcePath;
this.iconConverter = iconConverter;
this.chatPathFormat = chatPathFormat;
}

/**
Expand Down Expand Up @@ -150,6 +152,7 @@ public AppVersion create(AppBuilderAppPo data, AppVersionRepository appVersionRe
.knowledgeCenterService(this.knowledgeCenterService)
.resourcePath(this.resourcePath)
.iconConverter(this.iconConverter)
.chatPathFormat(this.chatPathFormat)
.build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ public class Dependencies {
private KnowledgeCenterService knowledgeCenterService;
private String resourcePath;
private IconConverter iconConverter;
private String chatPathFormat;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package modelengine.fit.jober.aipp.domains.appversion.publish;

import modelengine.fitframework.util.StringUtils;
import modelengine.jade.store.service.ToolService;
import modelengine.fit.jane.task.util.Entities;
import modelengine.fit.jober.WaterFlowService;
Expand All @@ -29,6 +30,7 @@

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand All @@ -44,6 +46,7 @@ public class StorePublisher implements Publisher {
private final AppService appService;
private final PluginService pluginService;
private final ToolService toolService;
private final String chatPathFormat;

@Override
public void publish(PublishContext context, AppVersion appVersion) {
Expand Down Expand Up @@ -84,7 +87,12 @@ private AppPublishData buildItemData(PublishContext context, AppVersion appVersi
itemData.setUniqueName(appVersion.getData().getUniqueName());
itemData.setSchema(ToolSchemaBuilder.create(context).build());
itemData.setSource(appCategory.getSource());
itemData.setTags(Set.of(appCategory.getTag()));
Set<String> tag = new HashSet<>();
tag.add(appCategory.getTag());
if (StringUtils.isNotBlank(appVersion.getClassification())) {
tag.add(appVersion.getClassification());
}
itemData.setTags(tag);
itemData.setRunnables(this.buildRunnables(context, appVersion));
itemData.setUserGroupId(context.getPublishData().getUserGroupId());
return itemData;
Expand All @@ -101,6 +109,7 @@ private Map<String, Object> buildRunnables(PublishContext context, AppVersion ap
.put("aippId", appVersion.getData().getAppSuiteId())
.put("version", context.getPublishData().getVersion())
.put("appCategory", context.getPublishData().getAppCategory())
.put("chatPath", String.format(this.chatPathFormat, appVersion.getData().getPath()))
.build();
runnablesMap.put("APP", app);
return runnablesMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ app-engine:
max-length: 500
plugin:
system-creator: 'system'
chat-path:
format: '/chat/%s'
elsa:
endpoint:
elsaKey:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void setUp() {
300,
this.knowledgeCenterService,
"/var/share",
this.iconConverter);
this.iconConverter, "/chat/%s");
when(this.iconConverter.toFrontend(anyString())).thenReturn("/v1/api");
when(this.iconConverter.toStorage(anyString())).thenReturn("/v1/api");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ public static AppVersion mockAppVersion(AppBuilderAppPo appPo) {
300,
null,
"/var/share",
null);
null, "/chat/%s");
if (StringUtils.isBlank(appPo.getConfigId())) {
appPo.setConfigId("defaultConfigId");
}
Expand Down