Search in sources :

Example 6 with Option

use of com.qlangtech.tis.manage.common.Option in project plugins by qlangtech.

the class HudiTableMeta method getHistoryBatchs.

public static List<Option> getHistoryBatchs(ITISFileSystem fs, IHiveConnGetter hiveConn) {
    IPath path = fs.getPath(fs.getRootDir(), hiveConn.getDbName());
    List<IPathInfo> child = fs.listChildren(path);
    return child.stream().map((c) -> new Option(c.getName())).collect(Collectors.toList());
}
Also used : IPathInfo(com.qlangtech.tis.fs.IPathInfo) OutputStream(java.io.OutputStream) IPath(com.qlangtech.tis.fs.IPath) Schema(org.apache.avro.Schema) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) Option(com.qlangtech.tis.manage.common.Option) IPathInfo(com.qlangtech.tis.fs.IPathInfo) BasicHdfsWriterJob(com.qlangtech.tis.plugin.datax.BasicHdfsWriterJob) Collectors(java.util.stream.Collectors) Key(com.alibaba.datax.plugin.writer.hdfswriter.Key) Configuration(com.alibaba.datax.common.util.Configuration) HdfsWriterErrorCode(com.alibaba.datax.plugin.writer.hdfswriter.HdfsWriterErrorCode) SchemaBuilder(org.apache.avro.SchemaBuilder) HdfsColMeta(com.alibaba.datax.plugin.writer.hdfswriter.HdfsColMeta) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) LogicalTypes(org.apache.avro.LogicalTypes) CollectionUtils(org.apache.commons.collections.CollectionUtils) DataType(com.qlangtech.tis.plugin.ds.DataType) IHiveConnGetter(com.qlangtech.tis.config.hive.IHiveConnGetter) TisUTF8(com.qlangtech.tis.manage.common.TisUTF8) DataxUtils(com.qlangtech.tis.offline.DataxUtils) ITISFileSystem(com.qlangtech.tis.fs.ITISFileSystem) IPath(com.qlangtech.tis.fs.IPath) Option(com.qlangtech.tis.manage.common.Option)

Example 7 with Option

use of com.qlangtech.tis.manage.common.Option in project plugins by qlangtech.

the class PluginItems method getExistDbs.

public static List<Option> getExistDbs(String... extendClass) {
    Set<String> extendClazzs = Sets.newHashSet("MySQL-V5", "MySQL-V8");
    for (String sourceType : extendClass) {
        if (extendClazzs.contains(sourceType)) {
            return Collections.singletonList(new Option(DB_NAME, DB_NAME));
        // Assert.fail("param:" + sourceType + " must contain in:" + extendClazzs.stream().collect(Collectors.joining(",")));
        }
    }
    Set<String> mongoDBextendClazzs = Sets.newHashSet("MongoDB");
    for (String sourceType : extendClass) {
        if (mongoDBextendClazzs.contains(sourceType)) {
            return Collections.singletonList(new Option(DB_MONGODB_NAME, DB_MONGODB_NAME));
        // Assert.fail("param:" + sourceType + " must contain in:" + extendClazzs.stream().collect(Collectors.joining(",")));
        }
    }
    for (String sourceType : extendClass) {
        if ("TiDB".equals(sourceType)) {
            return Collections.singletonList(new Option(DB_TIDB_NAME, DB_TIDB_NAME));
        // Assert.fail("param:" + sourceType + " must contain in:" + extendClazzs.stream().collect(Collectors.joining(",")));
        }
    }
    for (String sourceType : extendClass) {
        if ("ClickHouse".equals(sourceType)) {
            return Collections.singletonList(new Option(DB_CLICKHOUSE_NAME, DB_CLICKHOUSE_NAME));
        // Assert.fail("param:" + sourceType + " must contain in:" + extendClazzs.stream().collect(Collectors.joining(",")));
        }
    }
    for (String sourceType : extendClass) {
        if ("Cassandra".equals(sourceType)) {
            return Collections.singletonList(new Option(DB_CASSANDRA_NAME, DB_CASSANDRA_NAME));
        // Assert.fail("param:" + sourceType + " must contain in:" + extendClazzs.stream().collect(Collectors.joining(",")));
        }
    }
    for (String sourceType : extendClass) {
        if ("PostgreSQL".equals(sourceType)) {
            return Collections.singletonList(new Option(DB_POSTGRE_SQL, DB_POSTGRE_SQL));
        // Assert.fail("param:" + sourceType + " must contain in:" + extendClazzs.stream().collect(Collectors.joining(",")));
        }
    }
    for (String sourceType : extendClass) {
        if ("SqlServer".equals(sourceType)) {
            return Collections.singletonList(new Option(DB_SQL_Server, DB_SQL_Server));
        // Assert.fail("param:" + sourceType + " must contain in:" + extendClazzs.stream().collect(Collectors.joining(",")));
        }
    }
    for (String sourceType : extendClass) {
        if ("Oracle".equals(sourceType)) {
            return Collections.singletonList(new Option(DB_SQL_DORIS, DB_SQL_DORIS));
        // Assert.fail("param:" + sourceType + " must contain in:" + extendClazzs.stream().collect(Collectors.joining(",")));
        }
    }
    for (String sourceType : extendClass) {
        if ("Doris".equals(sourceType)) {
            return Collections.singletonList(new Option(DB_SQL_ORACLE, DB_SQL_ORACLE));
        // Assert.fail("param:" + sourceType + " must contain in:" + extendClazzs.stream().collect(Collectors.joining(",")));
        }
    }
    for (String sourceType : extendClass) {
        if ("StarRocks".equals(sourceType)) {
            return Collections.singletonList(new Option(DB_SQL_StarRocks, DB_SQL_StarRocks));
        // Assert.fail("param:" + sourceType + " must contain in:" + extendClazzs.stream().collect(Collectors.joining(",")));
        }
    }
    throw new IllegalStateException("param:" + Arrays.stream(extendClass).collect(Collectors.joining(",")) + " must contain is illegal");
}
Also used : Option(com.qlangtech.tis.manage.common.Option)

Example 8 with Option

use of com.qlangtech.tis.manage.common.Option in project tis by qlangtech.

the class Descriptor method resolveEnumProp.

// public static JSONArray resolveEnumProp(Descriptor descriptor, PropertyType propType) {
// return resolveEnumProp(descriptor, propType.extraProp);
// }
private static JSONArray resolveEnumProp(Descriptor descriptor, PluginExtraProps.Props fieldExtraProps) {
    Object anEnum = fieldExtraProps.getProps().get(KEY_ENUM_PROP);
    // if (anEnum == null) {
    // throw new IllegalStateException("fieldName:" + f.getName() + " relevant enum descriptor in json config can not be null");
    // }
    JSONArray enums = new JSONArray();
    if (anEnum != null && anEnum instanceof String) {
        // ]
        try {
            GroovyShellEvaluate.descriptorThreadLocal.set(descriptor);
            fieldExtraProps.getProps().put(KEY_ENUM_PROP, GroovyShellEvaluate.scriptEval((String) anEnum, (opts) -> {
                return Option.toJson((List<Option>) opts);
            }));
        } finally {
            GroovyShellEvaluate.descriptorThreadLocal.remove();
        }
    }
    return enums;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) XStream2(com.qlangtech.tis.util.XStream2) TIS(com.qlangtech.tis.TIS) ClassUtils(org.apache.commons.lang.ClassUtils) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) Option(com.qlangtech.tis.manage.common.Option) FormField(com.qlangtech.tis.plugin.annotation.FormField) SubForm(com.qlangtech.tis.plugin.annotation.SubForm) Callable(java.util.concurrent.Callable) Context(com.alibaba.citrus.turbine.Context) IFieldErrorHandler(com.qlangtech.tis.runtime.module.misc.IFieldErrorHandler) JSONArray(com.alibaba.fastjson.JSONArray) ValidatorCommons(com.qlangtech.tis.plugin.ValidatorCommons) Lists(com.google.common.collect.Lists) Matcher(java.util.regex.Matcher) com.qlangtech.tis.extension.impl(com.qlangtech.tis.extension.impl) IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) FormFieldType(com.qlangtech.tis.plugin.annotation.FormFieldType) DefaultFieldErrorHandler(com.qlangtech.tis.runtime.module.misc.impl.DefaultFieldErrorHandler) GroovyShellEvaluate(com.qlangtech.tis.extension.util.GroovyShellEvaluate) Validator(com.qlangtech.tis.plugin.annotation.Validator) java.lang.reflect(java.lang.reflect) PluginExtraProps(com.qlangtech.tis.extension.util.PluginExtraProps) ImmutableMap(com.google.common.collect.ImmutableMap) DataxWriter(com.qlangtech.tis.datax.impl.DataxWriter) IdentityName(com.qlangtech.tis.plugin.IdentityName) AttrValMap(com.qlangtech.tis.util.AttrValMap) IOException(java.io.IOException) Maps(com.google.common.collect.Maps) IPluginContext(com.qlangtech.tis.util.IPluginContext) Collectors(java.util.stream.Collectors) File(java.io.File) Types(org.jvnet.tiger_types.Types) JSON(com.alibaba.fastjson.JSON) IControlMsgHandler(com.qlangtech.tis.runtime.module.misc.IControlMsgHandler) ISelectOptionsGetter(com.qlangtech.tis.util.ISelectOptionsGetter) JSONObject(com.alibaba.fastjson.JSONObject) Pattern(java.util.regex.Pattern) IMessageHandler(com.qlangtech.tis.runtime.module.misc.IMessageHandler) JSONArray(com.alibaba.fastjson.JSONArray) JSONObject(com.alibaba.fastjson.JSONObject)

Example 9 with Option

use of com.qlangtech.tis.manage.common.Option in project tis by qlangtech.

the class PluginItems method getExistDbs.

/**
 * datax中显示已由数据源使用 <br>
 * must call form Descriptor
 *
 * @param extendClass
 * @return
 */
public static List<Option> getExistDbs(String... extendClass) {
    if (OfflineDatasourceAction.existDbs != null) {
        return OfflineDatasourceAction.existDbs;
    }
    if (extendClass == null || extendClass.length < 1) {
        throw new IllegalArgumentException("param extendClass can not be null");
    }
    Descriptor descriptor = GroovyShellEvaluate.descriptorThreadLocal.get();
    Objects.requireNonNull(descriptor, "descriptor can not be null");
    if (dbUpdateEventObservers.add(descriptor)) {
        // 当有数据源更新时需要将descriptor的属性重新更新一下
        addPluginItemsSaveObserver(new PluginItemsSaveObserver() {

            @Override
            public void afterSaved(PluginItemsSaveEvent event) {
                if (event.heteroEnum == HeteroEnum.DATASOURCE) {
                    descriptor.cleanPropertyTypes();
                }
            }
        });
    }
    IWorkflowDAOFacade wfFacade = BasicServlet.getBeanByType(ServletActionContext.getServletContext(), IWorkflowDAOFacade.class);
    Objects.requireNonNull(wfFacade, "wfFacade can not be null");
    DatasourceDbCriteria dbCriteria = new DatasourceDbCriteria();
    // Lists.newArrayList(extendClass).stre;
    List<String> extendClazzs = Lists.newArrayList();
    for (String type : extendClass) {
        extendClazzs.add(StringUtils.lowerCase(type));
    }
    dbCriteria.createCriteria().andExtendClassIn(extendClazzs);
    List<com.qlangtech.tis.workflow.pojo.DatasourceDb> dbs = wfFacade.getDatasourceDbDAO().selectByExample(dbCriteria);
    return dbs.stream().map((db) -> new Option(db.getName(), db.getName())).collect(Collectors.toList());
}
Also used : OfflineDatasourceAction(com.qlangtech.tis.offline.module.action.OfflineDatasourceAction) java.util(java.util) TargetResName(com.qlangtech.tis.coredefine.module.action.TargetResName) IAppSource(com.qlangtech.tis.manage.IAppSource) TIS(com.qlangtech.tis.TIS) DatasourceDbCriteria(com.qlangtech.tis.workflow.pojo.DatasourceDbCriteria) Option(com.qlangtech.tis.manage.common.Option) PostedDSProp(com.qlangtech.tis.plugin.ds.PostedDSProp) DbScope(com.qlangtech.tis.offline.DbScope) StringUtils(org.apache.commons.lang3.StringUtils) Context(com.alibaba.citrus.turbine.Context) ParamsConfigPluginStore(com.qlangtech.tis.plugin.credentials.ParamsConfigPluginStore) DataXJobWorker(com.qlangtech.tis.datax.job.DataXJobWorker) BasicServlet(com.qlangtech.tis.manage.servlet.BasicServlet) Lists(com.google.common.collect.Lists) IPropertyType(com.qlangtech.tis.extension.IPropertyType) PluginFormProperties(com.qlangtech.tis.extension.PluginFormProperties) DataSourceFactory(com.qlangtech.tis.plugin.ds.DataSourceFactory) GroovyShellEvaluate(com.qlangtech.tis.extension.util.GroovyShellEvaluate) IWorkflowDAOFacade(com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade) com.qlangtech.tis.plugin(com.qlangtech.tis.plugin) Descriptor(com.qlangtech.tis.extension.Descriptor) IPluginEnum(com.qlangtech.tis.IPluginEnum) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ServletActionContext(org.apache.struts2.ServletActionContext) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties) Describable(com.qlangtech.tis.extension.Describable) IWorkflowDAOFacade(com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade) Descriptor(com.qlangtech.tis.extension.Descriptor) Option(com.qlangtech.tis.manage.common.Option) DatasourceDbCriteria(com.qlangtech.tis.workflow.pojo.DatasourceDbCriteria)

Example 10 with Option

use of com.qlangtech.tis.manage.common.Option in project tis by qlangtech.

the class UserAction method doGetChildDpt.

/**
 * get child department
 *
 * @param context
 */
public void doGetChildDpt(Context context) {
    Integer dptid = this.getInt("pid");
    DepartmentCriteria query = new DepartmentCriteria();
    query.createCriteria().andParentIdEqualTo(dptid);
    List<Option> result = new ArrayList<Option>();
    for (Department dpt : this.getDepartmentDAO().selectByExample(query)) {
        result.add(new Option(dpt.getName(), String.valueOf(dpt.getDptId())));
    }
    context.put(AjaxValve.BIZ_RESULT, result);
}
Also used : Department(com.qlangtech.tis.manage.biz.dal.pojo.Department) Option(com.qlangtech.tis.manage.common.Option) DepartmentCriteria(com.qlangtech.tis.manage.biz.dal.pojo.DepartmentCriteria)

Aggregations

Option (com.qlangtech.tis.manage.common.Option)11 Collectors (java.util.stream.Collectors)5 Lists (com.google.common.collect.Lists)4 Context (com.alibaba.citrus.turbine.Context)3 Describable (com.qlangtech.tis.extension.Describable)3 Descriptor (com.qlangtech.tis.extension.Descriptor)3 ISelectedTab (com.qlangtech.tis.plugin.ds.ISelectedTab)3 List (java.util.List)3 JSONArray (com.alibaba.fastjson.JSONArray)2 JSONObject (com.alibaba.fastjson.JSONObject)2 TIS (com.qlangtech.tis.TIS)2 DataxReader (com.qlangtech.tis.datax.impl.DataxReader)2 SuFormProperties (com.qlangtech.tis.extension.impl.SuFormProperties)2 GroovyShellEvaluate (com.qlangtech.tis.extension.util.GroovyShellEvaluate)2 IdentityName (com.qlangtech.tis.plugin.IdentityName)2 FormField (com.qlangtech.tis.plugin.annotation.FormField)2 FormFieldType (com.qlangtech.tis.plugin.annotation.FormFieldType)2 Validator (com.qlangtech.tis.plugin.annotation.Validator)2 IControlMsgHandler (com.qlangtech.tis.runtime.module.misc.IControlMsgHandler)2 java.util (java.util)2