use of com.qlangtech.tis.extension.Describable in project plugins by qlangtech.
the class TestPlugin method testReceiceRequestFromClient.
public void testReceiceRequestFromClient() throws Exception {
com.alibaba.fastjson.JSONArray jsonArray = null;
com.alibaba.fastjson.JSONObject jsonObject = null;
com.alibaba.fastjson.JSONObject valJ = null;
String impl = null;
PropertyType attrDesc = null;
Descriptor descriptor = null;
JSONArray vals = null;
String attr = null;
String attrVal = null;
TIS tis = TIS.get();
// IncrComponent incrComponent = tis.loadIncrComponent(collection);
// incrComponent.setMqListenerFactory();
Describable describable = null;
try (InputStream input = TestPlugin.class.getResourceAsStream("RocketMQListenerFactory.json")) {
assertNotNull(input);
jsonArray = JSONArray.parseArray(IOUtils.toString(input, TisUTF8.getName()));
for (int i = 0; i < jsonArray.size(); i++) {
// 创建一个item
jsonObject = jsonArray.getJSONObject(i);
describable = (Describable) parseDescribable(jsonObject).instance;
}
}
assertNotNull(describable);
RocketMQListenerFactory mqListenerFactory = (RocketMQListenerFactory) describable;
assertEquals(MQ_TOPIC, mqListenerFactory.getMqTopic());
assertEquals(NamesrvAddr, mqListenerFactory.getNamesrvAddr());
assertEquals(consumeId, mqListenerFactory.consumeName);
assertNotNull(mqListenerFactory.getDeserialize());
}
use of com.qlangtech.tis.extension.Describable in project plugins by qlangtech.
the class SelectedTab method getContextTableCols.
public static List<Option> getContextTableCols(Function<List<ColumnMetaData>, Stream<ColumnMetaData>> func) {
SuFormProperties.SuFormGetterContext context = SuFormProperties.subFormGetterProcessThreadLocal.get();
if (context == null || context.plugin == null) {
return Collections.emptyList();
}
Describable plugin = Objects.requireNonNull(context.plugin, "context.plugin can not be null");
if (!(plugin instanceof DataSourceMeta)) {
throw new IllegalStateException("plugin must be type of " + DataSourceMeta.class.getName() + ", now type of " + plugin.getClass().getName());
}
DataSourceMeta dsMeta = (DataSourceMeta) plugin;
List<ColumnMetaData> cols = context.getContextAttr(KEY_TABLE_COLS, (key) -> dsMeta.getTableMetadata(context.getSubFormIdentityField()));
return func.apply(cols).map((c) -> c).collect(Collectors.toList());
}
use of com.qlangtech.tis.extension.Describable in project tis by qlangtech.
the class TaskStatusServlet method service.
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
String extendPoint = null;
try {
if (StringUtils.isNotEmpty(extendPoint = req.getParameter(DescriptorsJSON.KEY_EXTEND_POINT))) {
IPluginStore<Describable> pluginStore = TIS.getPluginStore((Class<Describable>) Class.forName(extendPoint));
pluginStore.cleanPlugins();
logger.info("key of '{}' pluginStore has been clean", extendPoint);
return;
}
} catch (ClassNotFoundException e) {
throw new ServletException("clean plugin store cache faild ", e);
}
if (Boolean.parseBoolean(req.getParameter(TIS.KEY_ACTION_CLEAN_TIS))) {
TIS.clean();
logger.info(" clean TIS cache", extendPoint);
return;
}
int taskid = Integer.parseInt(req.getParameter(IParamContext.KEY_TASK_ID));
// 是否要获取全部的日志信息,比如dump已經完成了,那麼只需要獲取dump之後的日志信息
// boolean all = Boolean.parseBoolean(req.getParameter("all"));
PhaseStatusCollection statusSet = TrackableExecuteInterceptor.getTaskPhaseReference(taskid);
JSONObject result = new JSONObject();
boolean success = false;
if (statusSet != null) {
result.put("status", statusSet);
success = true;
}
result.put("success", success);
IOUtils.write(JSON.toJSONString(result, true), res.getWriter());
}
use of com.qlangtech.tis.extension.Describable in project tis by qlangtech.
the class DescriptorsJSON method getDescriptorsJSON.
public JSONObject getDescriptorsJSON(Optional<IPropertyType.SubFormFilter> subFormFilter) {
JSONArray attrs;
String key;
PropertyType val;
JSONObject extraProps = null;
// FormField fieldAnnot;
JSONObject attrVal;
JSONObject descriptors = new JSONObject();
Map<String, Object> extractProps;
// IPropertyType.SubFormFilter subFilter = null;
PluginFormProperties pluginFormPropertyTypes;
for (Descriptor<T> d : this.descriptors) {
pluginFormPropertyTypes = d.getPluginFormPropertyTypes(subFormFilter);
JSONObject des = new JSONObject();
pluginFormPropertyTypes.accept(new SubFormFieldVisitor(subFormFilter) {
@Override
public Void visit(SuFormProperties props) {
JSONObject subForm = new JSONObject();
subForm.put("fieldName", props.getSubFormFieldName());
if (subFormFilter.isPresent()) {
IPropertyType.SubFormFilter filter = subFormFilter.get();
if (!filter.subformDetailView) {
des.put("subForm", true);
subForm.put("idList", props.getSubFormIdListGetter().build(filter));
}
}
des.put("subFormMeta", subForm);
return null;
}
});
des.put(KEY_EXTEND_POINT, d.getT().getName());
this.setDescInfo(d, des);
des.put("veriflable", d.overWriteValidateMethod);
if (IdentityName.class.isAssignableFrom(d.clazz)) {
des.put("pkField", d.getIdentityField().displayName);
}
extractProps = d.getExtractProps();
if (!extractProps.isEmpty()) {
des.put("extractProps", extractProps);
}
attrs = new JSONArray();
ArrayList<Map.Entry<String, PropertyType>> entries = Lists.newArrayList(pluginFormPropertyTypes.getKVTuples());
entries.sort(((o1, o2) -> o1.getValue().ordinal() - o2.getValue().ordinal()));
for (Map.Entry<String, PropertyType> pp : entries) {
key = pp.getKey();
val = pp.getValue();
// fieldAnnot = val.getFormField();
attrVal = new JSONObject();
attrVal.put("key", key);
// 是否是主键
attrVal.put("pk", val.isIdentity());
attrVal.put("describable", val.isDescribable());
attrVal.put("type", val.typeIdentity());
attrVal.put("required", val.isInputRequired());
attrVal.put("ord", val.ordinal());
extraProps = val.getExtraProps();
if (extraProps != null) {
// 额外属性
attrVal.put("eprops", extraProps);
}
if (val.typeIdentity() == FormFieldType.SELECTABLE.getIdentity()) {
attrVal.put("options", getSelectOptions(d, val, key));
}
if (val.isDescribable()) {
DescriptorsJSON des2Json = new DescriptorsJSON(val.getApplicableDescriptors());
attrVal.put("descriptors", des2Json.getDescriptorsJSON());
}
// attrs.put(attrVal);
attrs.add(attrVal);
}
// 对象拥有的属性
des.put("attrs", attrs);
// processor.process(attrs.keySet(), d);
descriptors.put(d.getId(), des);
}
return descriptors;
}
use of com.qlangtech.tis.extension.Describable in project tis by qlangtech.
the class IdentityName method identityValue.
// /**
// * 相同类型的插件不能重名
// *
// * @return
// */
// String getName();
/**
* 取得唯一ID
*
* @return
*/
default String identityValue() {
Describable plugin = (Describable) this;
Descriptor des = plugin.getDescriptor();
Objects.requireNonNull(des, " Descriptor of Describable instance of " + plugin.getClass().getName());
return des.getIdentityValue(plugin);
}
Aggregations