Skip to content

Commit fce272f

Browse files
committed
add ontology for TIS
1 parent 6e5d5ca commit fce272f

163 files changed

Lines changed: 2204 additions & 6263 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tis-datax/tis-datax-local-akka-executor/src/main/java/com/qlangtech/tis/dag/BatchJobCrontab.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public JSONObject describePlugin() {
5050
return Descriptor.getManipulateMeta(false, this);
5151
}
5252

53+
54+
5355
/**
5456
* //@see DAGWorkflowServlet
5557
*
@@ -110,6 +112,7 @@ public boolean isManipulateStorable() {
110112
protected boolean verify(IControlMsgHandler msgHandler, Context context, PostFormVals postFormVals) {
111113
// return super.verify(msgHandler, context, postFormVals);
112114
// CrontabTriggerStrategy describable = postFormVals.newInstance();
115+
113116
Date nextFireTime = getNextFireTime(msgHandler, context, KEY_CRONTAB, postFormVals.getField(KEY_CRONTAB));
114117
if (nextFireTime != null) {
115118
msgHandler.addActionMessage(context, "最近触发时间为:" + TimeFormat.yyyyMMdd_HH_mm_ss.format(nextFireTime.getTime()));

tis-ontology-plugin/pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,22 @@
3535

3636
</properties>
3737

38+
<dependencies>
39+
<dependency>
40+
<groupId>com.qlangtech.tis</groupId>
41+
<artifactId>tis-plugin</artifactId>
42+
<version>${tis.version}</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.neo4j</groupId>
46+
<artifactId>neo4j</artifactId>
47+
<version>5.18.1</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>com.microsoft.onnxruntime</groupId>
51+
<artifactId>onnxruntime</artifactId>
52+
<version>1.17.3</version>
53+
</dependency>
54+
</dependencies>
55+
3856
</project>
Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,122 @@
1-
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * 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 com.qlangtech.tis.plugin.ontology;import com.alibaba.citrus.turbine.Context;import com.qlangtech.tis.aiagent.llm.LLMProvider;import com.qlangtech.tis.extension.DescriptorUseableShortComment;import com.qlangtech.tis.extension.TISExtension;import com.qlangtech.tis.plugin.annotation.FormField;import com.qlangtech.tis.plugin.annotation.FormFieldType;import com.qlangtech.tis.plugin.annotation.Validator;import com.qlangtech.tis.runtime.module.misc.IControlMsgHandler;import com.qlangtech.tis.util.IPluginContext;import com.qlangtech.tis.util.UploadPluginMeta;import java.util.Optional;import static com.qlangtech.tis.manage.common.UserProfile.KEY_FIELD_LLM_NAME;/** * 开启智能问数,design/chat-bi/06-neo4j-ontology-sync.md * * @author 百岁 (baisui@qlangtech.com) * @date 2026/5/28 */public class EnableChatBI extends OntologyDomainManipulate { /** * 大模型接口 */ @FormField(type = FormFieldType.SELECTABLE, ordinal = 1, validate = {Validator.identity}) public String llm; @Override public void manipuldateProcess(IPluginContext pluginContext, UploadPluginMeta pluginMeta, Optional<Context> context) { } @TISExtension public static final class DftDesc extends OntologyDomainManipulate.BasicDesc implements DescriptorUseableShortComment { public DftDesc() { super(); // List<Pair<OntologyDomain, IPluginStore<OntologyDomain>>> domainList = OntologyDomain // .getDoaminList(); // List<OntologyDomain> domains = domainList.stream().map(Pair::getKey).toList(); // this.registerSelectOptions("ontologyDomain", () -> domains); this.registerSelectOptions(KEY_FIELD_LLM_NAME, LLMProvider::getExistProviders); } @Override protected boolean validateAll(IControlMsgHandler msgHandler, Context context, PostFormVals postFormVals) { // // return super.validateAll(msgHandler, context, postFormVals); // OntologyPluginMeta ometa = getOntologyPluginMeta((IPluginContext) msgHandler, Optional.of // (context)); // // List<OntologyObjectType> objectTypes = OntologyObjectType.loadAll(ometa.getDomain()); // if (objectTypes.isEmpty()) { // throw new IllegalStateException("domain '" + ometa.getDomain() // + "' has no ObjectType, please export tables first"); // } // Optional<OntologyProperty> pk = null; // List<OntologyObjectType> lackPkObjTypes = Lists.newArrayList(); // for (OntologyObjectType objType : objectTypes) { // pk = objType.getPk(); // if (!pk.isPresent()) { // lackPkObjTypes.add(objType); // } // } // // if (CollectionUtils.isNotEmpty(lackPkObjTypes)) { // msgHandler.addErrorMessage(context, // "对象还未设置主键,完成后继续此操作:" // // + lackPkObjTypes.stream() // // .map((obj) -> "'" + obj.getName() + "'").collect(Collectors.joining(", // "))); // return false; // } return true; } @Override public String getDisplayName() { return "Enable ChatBI"; } @Override public String shortComment() { return "开启自然语言统计问数功能"; } }}
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package com.qlangtech.tis.plugin.ontology;
19+
20+
import com.alibaba.citrus.turbine.Context;
21+
import com.alibaba.fastjson.JSONObject;
22+
import com.qlangtech.tis.aiagent.llm.LLMProvider;
23+
import com.qlangtech.tis.datax.IManipulateStatus;
24+
import com.qlangtech.tis.extension.Descriptor;
25+
import com.qlangtech.tis.extension.DescriptorUseableShortComment;
26+
import com.qlangtech.tis.extension.TISExtension;
27+
import com.qlangtech.tis.plugin.IdentityDesc;
28+
import com.qlangtech.tis.plugin.annotation.FormField;
29+
import com.qlangtech.tis.plugin.annotation.FormFieldType;
30+
import com.qlangtech.tis.plugin.annotation.Validator;
31+
import com.qlangtech.tis.plugin.ds.manipulate.ManipulateItemsProcessor;
32+
import com.qlangtech.tis.plugin.ontology.impl.OntologyPluginMeta;
33+
import com.qlangtech.tis.plugin.ontology.sync.OntologyNeo4jSyncService;
34+
import com.qlangtech.tis.plugin.ontology.sync.OntologySyncQueue;
35+
import com.qlangtech.tis.runtime.module.misc.IControlMsgHandler;
36+
import com.qlangtech.tis.util.IPluginContext;
37+
38+
import java.util.Collections;
39+
import java.util.Optional;
40+
41+
import static com.qlangtech.tis.manage.common.UserProfile.KEY_FIELD_LLM_NAME;
42+
43+
/**
44+
* 开启智能问数,design/chat-bi/06-neo4j-ontology-sync.md
45+
*
46+
* @author 百岁 (baisui@qlangtech.com)
47+
* @date 2026/5/28
48+
*/
49+
public class EnableChatBI extends OntologyDomainManipulate implements IManipulateStatus, IdentityDesc<JSONObject> {
50+
51+
/**
52+
* 大模型接口
53+
*/
54+
@FormField(type = FormFieldType.SELECTABLE, ordinal = 1, validate = {Validator.identity, Validator.require})
55+
public String llm;
56+
57+
/**
58+
* chatBI 最大检索记录条数,放置获取记录数目太多导致信息过载
59+
*/
60+
@FormField(type = FormFieldType.INT_NUMBER, ordinal = 2, validate = {Validator.integer, Validator.require})
61+
public Integer maxRetrvalCount;
62+
63+
@Override
64+
protected void afterManipuldateProcess(IPluginContext pluginContext, Optional<Context> context,
65+
ManipulateItemsProcessor itemsProcessor) {
66+
super.afterManipuldateProcess(pluginContext, context, itemsProcessor);
67+
if (itemsProcessor.isDeleteProcess()) {
68+
return;
69+
}
70+
OntologyPluginMeta meta = OntologyPluginMeta.createPluginMeta(itemsProcessor.getPluginMeta());
71+
OntologySyncQueue.enqueue(() -> {
72+
IPluginContext.setPluginContext(pluginContext);
73+
OntologyNeo4jSyncService.getInstance().fullRebuild(meta.getDomain());
74+
});
75+
}
76+
77+
@Override
78+
public JSONObject describePlugin() {
79+
return Descriptor.getManipulateMeta(false, this);
80+
}
81+
82+
@Override
83+
public ManipulateStateSummary manipulateStatusSummary() {
84+
final StringBuilder summary = new StringBuilder("已经开启ChatBI功能");
85+
return new ManipulateStateSummary(
86+
Collections.singletonList(IManipulateStatus.create("正常"))
87+
, summary.toString(), true);
88+
}
89+
90+
@TISExtension
91+
public static final class DftDesc extends OntologyDomainManipulate.BasicDesc implements DescriptorUseableShortComment {
92+
public DftDesc() {
93+
super();
94+
this.registerSelectOptions(KEY_FIELD_LLM_NAME, LLMProvider::getExistProviders);
95+
}
96+
97+
@Override
98+
public boolean isManipulateStorable() {
99+
return true;
100+
}
101+
102+
@Override
103+
public EndType getEndType() {
104+
return EndType.ChatBI;
105+
}
106+
107+
@Override
108+
protected boolean validateAll(IControlMsgHandler msgHandler, Context context, PostFormVals postFormVals) {
109+
return true;
110+
}
111+
112+
@Override
113+
public String getDisplayName() {
114+
return "Enable ChatBI";
115+
}
116+
117+
@Override
118+
public String shortComment() {
119+
return "开启自然语言统计问数功能";
120+
}
121+
}
122+
}

tis-ontology-plugin/src/main/java/com/qlangtech/tis/plugin/ontology/ExportToOntologyInDataSource.java

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tis-ontology-plugin/src/main/java/com/qlangtech/tis/plugin/ontology/InferOntologyFromLLM.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public LLMProvider getLlmProvider() {
101101
return LLMProvider.load(Objects.requireNonNull(IPluginContext.getThreadLocalInstance()), llm);
102102
}
103103

104-
private static OntologyPluginMeta getOntologyPluginMeta(IPluginContext pluginContext, Optional<Context> context) {
104+
public static OntologyPluginMeta getOntologyPluginMeta(IPluginContext pluginContext, Optional<Context> context) {
105105
final Context ctx = context.orElseThrow();
106106
ManipulateItemsProcessor itemsProcessor = ManipuldateUtils.instance(pluginContext, ctx,
107107
null, (meta) -> {
@@ -117,13 +117,9 @@ private static OntologyPluginMeta getOntologyPluginMeta(IPluginContext pluginCon
117117
}
118118

119119
@Override
120-
public void manipuldateProcess(IPluginContext pluginContext, UploadPluginMeta pluginMeta,
121-
Optional<Context> context) {
120+
protected void afterManipuldateProcess(IPluginContext pluginContext, Optional<Context> context,
121+
ManipulateItemsProcessor itemsProcessor) {
122122
final Context ctx = context.orElseThrow();
123-
// ManipulateItemsProcessor itemsProcessor = ManipuldateUtils.instance(pluginContext, ctx,
124-
// null, (meta) -> {
125-
// UploadPluginMeta.putPluginMeta(ctx, meta);
126-
// });
127123

128124
OntologyPluginMeta ometa = getOntologyPluginMeta(pluginContext, context);
129125

@@ -698,6 +694,9 @@ protected boolean validateAll(IControlMsgHandler msgHandler, Context context, Po
698694
Optional<OntologyProperty> pk = null;
699695
List<OntologyObjectType> lackPkObjTypes = Lists.newArrayList();
700696
for (OntologyObjectType objType : objectTypes) {
697+
if (objType.hasDisablePK()) {
698+
continue;
699+
}
701700
pk = objType.getPk();
702701
if (!pk.isPresent()) {
703702
lackPkObjTypes.add(objType);

tis-ontology-plugin/src/main/java/com/qlangtech/tis/plugin/ontology/OntologyDomainManipulate.java

Lines changed: 0 additions & 1 deletion
This file was deleted.

tis-ontology-plugin/src/main/java/com/qlangtech/tis/plugin/ontology/impl/domain/DefaultOntologyDomain.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@
1818

1919
package com.qlangtech.tis.plugin.ontology.impl.domain;
2020

21+
import com.alibaba.citrus.turbine.Context;
22+
import com.qlangtech.tis.TIS;
23+
import com.qlangtech.tis.datax.StoreResourceType;
2124
import com.qlangtech.tis.extension.Descriptor;
2225
import com.qlangtech.tis.extension.DescriptorUseableShortComment;
2326
import com.qlangtech.tis.extension.IDescribableManipulate;
2427
import com.qlangtech.tis.extension.TISExtension;
2528
import com.qlangtech.tis.plugin.IPluginStore;
29+
import com.qlangtech.tis.plugin.KeyedPluginStore;
2630
import com.qlangtech.tis.plugin.ontology.OntologyDomain;
2731
import com.qlangtech.tis.plugin.ontology.OntologyDomainManipulate;
32+
import com.qlangtech.tis.plugin.ontology.impl.OntologyPluginMeta;
33+
import com.qlangtech.tis.util.IPluginContext;
2834

2935
import java.util.Optional;
3036

@@ -33,7 +39,12 @@
3339
* @author 百岁 (baisui@qlangtech.com)
3440
* @date 2026/5/28
3541
*/
36-
public class DefaultOntologyDomain extends OntologyDomain {
42+
public class DefaultOntologyDomain extends OntologyDomain implements IPluginStore.AfterPluginSaved {
43+
44+
@Override
45+
public void afterSaved(IPluginContext pluginContext, Optional<Context> context) {
46+
47+
}
3748

3849
@TISExtension
3950
public static class DefaultDesc extends Descriptor<OntologyDomain> implements DescriptorUseableShortComment, IDescribableManipulate<OntologyDomainManipulate> {
@@ -43,7 +54,7 @@ public DefaultDesc() {
4354

4455
@Override
4556
public String getDisplayName() {
46-
return "Ontology";
57+
return StoreResourceType.Ontology.pluginDescName;
4758
}
4859

4960
@Override
@@ -57,8 +68,13 @@ public Class<OntologyDomainManipulate> getManipulateExtendPoint() {
5768
}
5869

5970
@Override
60-
public Optional<IPluginStore<OntologyDomainManipulate>> getManipulateStore() {
61-
return Optional.empty();
71+
public final Optional<IPluginStore<OntologyDomainManipulate>> getManipulateStore() {
72+
OntologyPluginMeta pluginMeta = OntologyPluginMeta.createPluginMeta();
73+
KeyedPluginStore.Key<OntologyDomainManipulate> manipulateStoreKey
74+
= OntologyDomain.getStoreKey(pluginMeta.getDomain(), this.getManipulateExtendPoint());
75+
return Optional.of(TIS.getPluginStore(manipulateStoreKey));
6276
}
6377
}
6478
}
79+
80+

0 commit comments

Comments
 (0)