Search in sources :

Example 1 with DescriptorExtensionList

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);
}
Also used : WorkFlow(com.qlangtech.tis.workflow.pojo.WorkFlow) StringUtils(org.apache.commons.lang.StringUtils) ERRules.$(com.qlangtech.tis.sql.parser.er.ERRules.$) SqlTaskNode(com.qlangtech.tis.sql.parser.SqlTaskNode) JoinRule(com.qlangtech.tis.git.GitUtils.JoinRule) TIS(com.qlangtech.tis.TIS) WorkFlowCriteria(com.qlangtech.tis.workflow.pojo.WorkFlowCriteria) Autowired(org.springframework.beans.factory.annotation.Autowired) Option(com.qlangtech.tis.manage.common.Option) DbScope(com.qlangtech.tis.offline.DbScope) DescriptorsJSON(com.qlangtech.tis.util.DescriptorsJSON) IFieldErrorHandler(com.qlangtech.tis.runtime.module.misc.IFieldErrorHandler) JSONObject(org.json.JSONObject) Matcher(java.util.regex.Matcher) DescriptorExtensionList(com.qlangtech.tis.extension.DescriptorExtensionList) PermissionConstant(com.qlangtech.tis.manage.PermissionConstant) FullbuildPhase(com.qlangtech.tis.assemble.FullbuildPhase) IPluginStore(com.qlangtech.tis.plugin.IPluginStore) PluginFormProperties(com.qlangtech.tis.extension.PluginFormProperties) PostParam(com.qlangtech.tis.manage.common.HttpUtils.PostParam) Validator(com.qlangtech.tis.plugin.annotation.Validator) GitRepositoryCommitPojo(com.qlangtech.tis.offline.pojo.GitRepositoryCommitPojo) DelegateControl4JsonPostMsgHandler(com.qlangtech.tis.runtime.module.misc.impl.DelegateControl4JsonPostMsgHandler) HeteroList(com.qlangtech.tis.util.HeteroList) Descriptor(com.qlangtech.tis.extension.Descriptor) TabCardinality(com.qlangtech.tis.sql.parser.er.TabCardinality) Collectors(java.util.stream.Collectors) name.fraser.neil.plaintext.diff_match_patch(name.fraser.neil.plaintext.diff_match_patch) IFullBuildContext(com.qlangtech.tis.fullbuild.IFullBuildContext) IOUtils(org.apache.commons.io.IOUtils) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) IWorkFlowDAO(com.qlangtech.tis.workflow.dao.IWorkFlowDAO) IControlMsgHandler(com.qlangtech.tis.runtime.module.misc.IControlMsgHandler) TableRelation(com.qlangtech.tis.sql.parser.er.TableRelation) DataxAction(com.qlangtech.tis.coredefine.module.action.DataxAction) SqlDataFlowTopology(com.qlangtech.tis.sql.parser.SqlTaskNodeMeta.SqlDataFlowTopology) DBConfigSuit(com.qlangtech.tis.db.parser.DBConfigSuit) Pattern(java.util.regex.Pattern) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties) Types(java.sql.Types) Pager(com.koubei.web.tag.pager.Pager) java.util(java.util) Func(com.qlangtech.tis.manage.spring.aop.Func) UploadPluginMeta(com.qlangtech.tis.util.UploadPluginMeta) Context(com.alibaba.citrus.turbine.Context) TISDb(com.qlangtech.tis.offline.pojo.TISDb) JsonUtil(com.qlangtech.tis.trigger.util.JsonUtil) Lists(com.google.common.collect.Lists) PropertyType(com.qlangtech.tis.extension.impl.PropertyType) DatasourceTable(com.qlangtech.tis.workflow.pojo.DatasourceTable) CollectionUtils(org.apache.commons.collections.CollectionUtils) GitUtils(com.qlangtech.tis.git.GitUtils) OfflineManager(com.qlangtech.tis.offline.module.manager.impl.OfflineManager) FormFieldType(com.qlangtech.tis.plugin.annotation.FormFieldType) com.qlangtech.tis.sql.parser.meta(com.qlangtech.tis.sql.parser.meta) WorkflowPojo(com.qlangtech.tis.offline.pojo.WorkflowPojo) IWorkflowDAOFacade(com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade) MapUtils(org.apache.commons.collections.MapUtils) IdentityName(com.qlangtech.tis.plugin.IdentityName) JSONTokener(org.json.JSONTokener) com.qlangtech.tis.plugin.ds(com.qlangtech.tis.plugin.ds) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) Maps(com.google.common.collect.Maps) File(java.io.File) TisSqlFormatException(com.qlangtech.tis.sql.parser.exception.TisSqlFormatException) JSON(com.alibaba.fastjson.JSON) ERRules(com.qlangtech.tis.sql.parser.er.ERRules) BasicModule(com.qlangtech.tis.runtime.module.action.BasicModule) AppDomainInfo(com.qlangtech.tis.manage.common.AppDomainInfo) CoreAction(com.qlangtech.tis.coredefine.module.action.CoreAction) Assert(com.qlangtech.tis.common.utils.Assert) SqlTaskNodeMeta(com.qlangtech.tis.sql.parser.SqlTaskNodeMeta) IUser(com.qlangtech.tis.manage.common.IUser) PrimaryTableMeta(com.qlangtech.tis.sql.parser.er.PrimaryTableMeta) JSONArray(org.json.JSONArray) PluginDescMeta(com.qlangtech.tis.coredefine.module.action.PluginDescMeta) OfflineManager(com.qlangtech.tis.offline.module.manager.impl.OfflineManager) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) DescriptorsJSON(com.qlangtech.tis.util.DescriptorsJSON) Descriptor(com.qlangtech.tis.extension.Descriptor) JSONObject(org.json.JSONObject) Func(com.qlangtech.tis.manage.spring.aop.Func)

Aggregations

Context (com.alibaba.citrus.turbine.Context)1 JSON (com.alibaba.fastjson.JSON)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Pager (com.koubei.web.tag.pager.Pager)1 TIS (com.qlangtech.tis.TIS)1 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)1 Assert (com.qlangtech.tis.common.utils.Assert)1 CoreAction (com.qlangtech.tis.coredefine.module.action.CoreAction)1 DataxAction (com.qlangtech.tis.coredefine.module.action.DataxAction)1 PluginDescMeta (com.qlangtech.tis.coredefine.module.action.PluginDescMeta)1 DataxReader (com.qlangtech.tis.datax.impl.DataxReader)1 DBConfigSuit (com.qlangtech.tis.db.parser.DBConfigSuit)1 Descriptor (com.qlangtech.tis.extension.Descriptor)1 DescriptorExtensionList (com.qlangtech.tis.extension.DescriptorExtensionList)1 PluginFormProperties (com.qlangtech.tis.extension.PluginFormProperties)1 PropertyType (com.qlangtech.tis.extension.impl.PropertyType)1 SuFormProperties (com.qlangtech.tis.extension.impl.SuFormProperties)1 IFullBuildContext (com.qlangtech.tis.fullbuild.IFullBuildContext)1 GitUtils (com.qlangtech.tis.git.GitUtils)1