Search in sources :

Example 1 with DataSourceMeta

use of com.qlangtech.tis.plugin.ds.DataSourceMeta 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());
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) DataSourceMeta(com.qlangtech.tis.plugin.ds.DataSourceMeta) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) LoggerFactory(org.slf4j.LoggerFactory) Option(com.qlangtech.tis.manage.common.Option) FormField(com.qlangtech.tis.plugin.annotation.FormField) ColumnMetaData(com.qlangtech.tis.plugin.ds.ColumnMetaData) Function(java.util.function.Function) Context(com.alibaba.citrus.turbine.Context) Lists(com.google.common.collect.Lists) CollectionUtils(org.apache.commons.collections.CollectionUtils) FormFieldType(com.qlangtech.tis.plugin.annotation.FormFieldType) Validator(com.qlangtech.tis.plugin.annotation.Validator) TISExtension(com.qlangtech.tis.extension.TISExtension) Logger(org.slf4j.Logger) Descriptor(com.qlangtech.tis.extension.Descriptor) IdentityName(com.qlangtech.tis.plugin.IdentityName) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) Stream(java.util.stream.Stream) IControlMsgHandler(com.qlangtech.tis.runtime.module.misc.IControlMsgHandler) Optional(java.util.Optional) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties) Collections(java.util.Collections) Describable(com.qlangtech.tis.extension.Describable) Describable(com.qlangtech.tis.extension.Describable) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties) ColumnMetaData(com.qlangtech.tis.plugin.ds.ColumnMetaData) DataSourceMeta(com.qlangtech.tis.plugin.ds.DataSourceMeta)

Aggregations

Context (com.alibaba.citrus.turbine.Context)1 Lists (com.google.common.collect.Lists)1 DataxReader (com.qlangtech.tis.datax.impl.DataxReader)1 Describable (com.qlangtech.tis.extension.Describable)1 Descriptor (com.qlangtech.tis.extension.Descriptor)1 TISExtension (com.qlangtech.tis.extension.TISExtension)1 SuFormProperties (com.qlangtech.tis.extension.impl.SuFormProperties)1 Option (com.qlangtech.tis.manage.common.Option)1 IdentityName (com.qlangtech.tis.plugin.IdentityName)1 FormField (com.qlangtech.tis.plugin.annotation.FormField)1 FormFieldType (com.qlangtech.tis.plugin.annotation.FormFieldType)1 Validator (com.qlangtech.tis.plugin.annotation.Validator)1 ColumnMetaData (com.qlangtech.tis.plugin.ds.ColumnMetaData)1 DataSourceMeta (com.qlangtech.tis.plugin.ds.DataSourceMeta)1 ISelectedTab (com.qlangtech.tis.plugin.ds.ISelectedTab)1 IControlMsgHandler (com.qlangtech.tis.runtime.module.misc.IControlMsgHandler)1 Collections (java.util.Collections)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1