use of com.qlangtech.tis.extension.PluginFormProperties in project plugins by qlangtech.
the class TestDataxMySQLReader method testGetPluginFormPropertyTypes.
public void testGetPluginFormPropertyTypes() {
DataxMySQLReader mySQLReader = new DataxMySQLReader();
Descriptor<DataxReader> descriptor = mySQLReader.getDescriptor();
assertNotNull(descriptor);
PluginFormProperties propertyTypes = descriptor.getPluginFormPropertyTypes();
assertEquals(4, propertyTypes.getKVTuples().size());
}
use of com.qlangtech.tis.extension.PluginFormProperties in project plugins by qlangtech.
the class TestDataxMySQLWriter method testFieldCount.
public void testFieldCount() throws Exception {
DataxMySQLWriter mySQLWriter = new DataxMySQLWriter();
Descriptor<DataxWriter> descriptor = mySQLWriter.getDescriptor();
PluginFormProperties pluginFormPropertyTypes = descriptor.getPluginFormPropertyTypes();
assertTrue(pluginFormPropertyTypes instanceof RootFormProperties);
assertEquals(8, pluginFormPropertyTypes.getKVTuples().size());
}
use of com.qlangtech.tis.extension.PluginFormProperties in project plugins by qlangtech.
the class TestPlugin method testSerialize.
public void testSerialize() throws Exception {
IPluginStore<MQListenerFactory> pluginStore = TIS.getPluginStore(collection, MQListenerFactory.class);
// IncrComponent incrComponent = createIncrComponent();
List<MQListenerFactory> mqListenerFactory = pluginStore.getPlugins();
UploadPluginMeta meta = UploadPluginMeta.parse("mq");
HeteroList<MQListenerFactory> hList = new HeteroList<>(meta);
hList.setCaption("MQ消息监听");
hList.setItems(mqListenerFactory);
hList.setDescriptors(TIS.getPluginStore(MQListenerFactory.class).allDescriptor());
assertEquals(1, hList.getDescriptors().size());
PluginFormProperties propertyTypes;
for (Descriptor<MQListenerFactory> f : hList.getDescriptors()) {
System.out.println(f.getId());
// getPropertyTypes();
propertyTypes = f.getPluginFormPropertyTypes();
for (Map.Entry<String, PropertyType> entry : propertyTypes.getKVTuples()) {
System.out.println(entry.getKey() + ":" + entry.getValue());
}
}
JSONObject j = hList.toJSON();
System.out.println("==============================");
System.out.println(j.toJSONString());
System.out.println("==============================");
}
use of com.qlangtech.tis.extension.PluginFormProperties in project tis by qlangtech.
the class DataxReader method createDataXReaderKey.
private static TIS.DataXReaderAppKey createDataXReaderKey(IPluginContext pluginContext, boolean db, String appname) {
return new TIS.DataXReaderAppKey(pluginContext, db, appname, new PluginStore.IPluginProcessCallback<DataxReader>() {
@Override
public void afterDeserialize(final DataxReader reader) {
List<PluginFormProperties> subFieldFormPropertyTypes = reader.getDescriptor().getSubPluginFormPropertyTypes();
if (subFieldFormPropertyTypes.size() > 0) {
// 加载子字段
subFieldFormPropertyTypes.forEach((pt) -> {
pt.accept(new PluginFormProperties.IVisitor() {
@Override
public Void visit(final SuFormProperties props) {
SubFieldFormAppKey<DataxReader> subFieldKey = new SubFieldFormAppKey<>(pluginContext, db, appname, props, DataxReader.class);
KeyedPluginStore<DataxReader> subFieldStore = KeyedPluginStore.getPluginStore(subFieldKey);
// 子表单中的内容更新了之后,要同步父表单中的状态
subFieldStore.addPluginsUpdateListener(new PluginStore.PluginsUpdateListener<DataxReader>(subFieldKey.getSerializeFileName(), reader) {
@Override
public void accept(PluginStore<DataxReader> pluginStore) {
setReaderSubFormProp(props, pluginStore.getPlugin());
}
});
DataxReader subFieldReader = subFieldStore.getPlugin();
if (subFieldReader == null) {
return null;
}
setReaderSubFormProp(props, subFieldReader);
return null;
}
private void setReaderSubFormProp(SuFormProperties props, DataxReader subFieldReader) {
setReaderSubFormProp(props, reader, subFieldReader);
}
private void setReaderSubFormProp(SuFormProperties props, DataxReader reader, DataxReader subFieldReader) {
if (reader == null) {
return;
}
try {
props.subFormField.set(reader, props.subFormField.get(subFieldReader));
} catch (IllegalAccessException e) {
throw new RuntimeException("get subField:" + props.getSubFormFieldName(), e);
}
}
});
});
}
}
});
}
use of com.qlangtech.tis.extension.PluginFormProperties in project tis by qlangtech.
the class OfflineDatasourceAction method doGetDsTabsVals.
/**
* 批量设置用,初始化数据库表
*
* @param context
* @throws IOException
*/
public void doGetDsTabsVals(Context context) throws IOException {
com.alibaba.fastjson.JSONObject body = this.parseJsonPost();
com.alibaba.fastjson.JSONArray tabs = body.getJSONArray("tabs");
if (tabs == null) {
throw new IllegalArgumentException("initialize Tabs can not be null");
}
List<String> selectedTabs = tabs.stream().map((tab) -> (String) tab).collect(Collectors.toList());
String pluginName = body.getString("name");
boolean require = body.getBooleanValue("require");
String extraParam = body.getString("extraParam");
UploadPluginMeta pluginMeta = null;
List<UploadPluginMeta> pluginMetas = UploadPluginMeta.parse(new String[] { pluginName + ":" + (require ? "require" : StringUtils.EMPTY) + "," + extraParam });
for (UploadPluginMeta m : pluginMetas) {
pluginMeta = m;
}
Objects.requireNonNull(pluginMeta, "pluginMeta can not be null");
HeteroList<DataxReader> heteroList = pluginMeta.getHeteroList(this);
List<DataxReader> readers = heteroList.getItems();
Map<String, List<ColumnMetaData>> mapCols = null;
List<ISelectedTab> allNewTabs = Lists.newArrayList();
PluginFormProperties pluginFormPropertyTypes = null;
Map<String, Object> bizResult = Maps.newHashMap();
for (DataxReader reader : readers) {
mapCols = selectedTabs.stream().collect(Collectors.toMap((tab) -> tab, (tab) -> {
return reader.getTableMetadata(tab);
}));
if (MapUtils.isEmpty(mapCols)) {
throw new IllegalStateException("mapCols can not be empty");
}
pluginFormPropertyTypes = reader.getDescriptor().getPluginFormPropertyTypes(pluginMeta.getSubFormFilter());
for (Map.Entry<String, List<ColumnMetaData>> tab2cols : mapCols.entrySet()) {
SuFormProperties.setSuFormGetterContext(reader, pluginMeta, tab2cols.getKey());
allNewTabs.add(createNewSelectedTab(pluginFormPropertyTypes, tab2cols));
}
DescriptorsJSON desc2Json = new DescriptorsJSON(reader.getDescriptor());
bizResult.put("subformDescriptor", desc2Json.getDescriptorsJSON(pluginMeta.getSubFormFilter()));
break;
}
Objects.requireNonNull(pluginFormPropertyTypes, "pluginFormPropertyTypes can not be null");
if (allNewTabs.size() < 1) {
throw new IllegalStateException("allNewTabs size can not small than 1");
}
bizResult.put("tabVals", pluginFormPropertyTypes.accept(new PluginFormProperties.IVisitor() {
@Override
public com.alibaba.fastjson.JSONObject visit(SuFormProperties props) {
return props.createSubFormVals(allNewTabs.stream().map((t) -> (IdentityName) t).collect(Collectors.toList()));
}
}));
this.setBizResult(context, bizResult);
}
Aggregations