use of com.qlangtech.tis.extension.DescriptorExtensionList in project tis by qlangtech.
the class OfflineDatasourceAction method doGetDsRelevantReaderDesc.
@Func(value = PermissionConstant.PERMISSION_DATASOURCE_EDIT, sideEffect = false)
public void doGetDsRelevantReaderDesc(Context context) {
com.alibaba.fastjson.JSONObject form = this.parseJsonPost();
Integer dbId = form.getInteger("dbId");
if (dbId == null) {
throw new IllegalStateException("dbId can not be null");
}
com.qlangtech.tis.workflow.pojo.DatasourceDb db = this.offlineDAOFacade.getDatasourceDbDAO().selectByPrimaryKey(dbId);
// IPluginStore<DataSourceFactory> dbPlugin = TIS.getDataBasePluginStore(new PostedDSProp(db.getName(), DbScope.DETAILED));
// DataSourceFactory.BaseDataSourceFactoryDescriptor descriptor = (DataSourceFactory.BaseDataSourceFactoryDescriptor) dbPlugin.getPlugin().getDescriptor();
OfflineManager.DBDataXReaderDescName defaultDataXReaderDescName = offlineManager.getDBDataXReaderDescName(db.getName());
Map<String, Object> result = Maps.newHashMap();
if (!defaultDataXReaderDescName.readerDescName.isPresent()) {
// throw new IllegalStateException("datasource:" + db.getName() + " desc:" + descriptor.getDisplayName() + " has not relevant DataXReader defined");
// result.put(KEY_DATA_READER_SETTED + "NotSupport", descriptor.getId());
this.addErrorMessage(context, "插件:" + defaultDataXReaderDescName.dsDescriptor.getId() + " 不支持表导入");
return;
}
DataxReader dataxReader = OfflineManager.getDBDataxReader(this, db.getName());
if (dataxReader != null) {
result.put(KEY_DATA_READER_SETTED, true);
// this.setBizResult(context, result);
// return;
}
DescriptorExtensionList<DataxReader, Descriptor<DataxReader>> descriptorList = TIS.get().getDescriptorList(DataxReader.class);
Optional<DataxReader.BaseDataxReaderDescriptor> dataXReaderDesc = descriptorList.stream().filter((de) -> {
return defaultDataXReaderDescName.getReaderDescName().equals(de.getDisplayName());
}).map((d) -> (DataxReader.BaseDataxReaderDescriptor) d).findFirst();
if (!dataXReaderDesc.isPresent()) {
throw new IllegalStateException("DataXReaderDescName:" + defaultDataXReaderDescName.getReaderDescName() + " can not find relevant DataXReader Descriptor");
}
result.put("readerDesc", new DescriptorsJSON(dataXReaderDesc.get()).getDescriptorsJSON());
result.put("processMeta", DataxAction.getDataXBasicProcessMetaByReader(dataXReaderDesc.get()));
this.setBizResult(context, result);
}
Aggregations