use of com.qlangtech.tis.util.HeteroList 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.util.HeteroList 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