Search in sources :

Example 16 with ColumnMetaData

use of com.qlangtech.tis.plugin.ds.ColumnMetaData in project tis by qlangtech.

the class SchemaAction method mergeWfColsWithTplCollection.

/**
 * 通过解析workflow的最终导出的字段,来生成Schema配置
 *
 * @param module
 * @param context
 * @param appSource
 * @return
 * @throws Exception
 */
public static SchemaResult mergeWfColsWithTplCollection(BasicModule module, Context context, ISolrAppSource appSource, final ISchemaPluginContext schemaPlugin, SolrFieldsParser.ParseResultCallback... parseResultCallback) throws Exception {
    // 通过version取默认模板
    Application tplApp = getTemplateApp(module);
    SchemaResult tplSchema = getTemplateSchema(module, context, tplApp);
    if (!tplSchema.isSuccess()) {
        return null;
    }
    ParseResult parseResult = (ParseResult) tplSchema.getParseResult();
    SolrType strType = parseResult.getTisType(ReflectSchemaFieldType.STRING.literia);
    List<ColumnMetaData> cols = appSource.reflectCols();
    for (ColumnMetaData colName : cols) {
        PSchemaField f = new PSchemaField();
        f.setName(colName.getKey());
        f.setType(strType);
        f.setStored(true);
        f.setIndexed(false);
        f.setMltiValued(false);
        f.setDocValue(false);
        parseResult.dFields.add(f);
    }
    parseResult.setUniqueKey(null);
    for (SolrFieldsParser.ParseResultCallback c : parseResultCallback) {
        c.process(cols, parseResult);
    }
    parseResult.addReservedFields();
    tplSchema.content = XModifier.modifySchemaContent(tplSchema.content, (document2, modifier) -> {
        modifier.addModify("/fields/field(:delete)");
        modifier.addModify("/sharedKey(:delete)");
        modifier.deleteUniqueKey();
        updateSchemaXML(parseResult.types, schemaPlugin, parseResult, document2, modifier);
    });
    parseResultCallback4test.process(cols, parseResult);
    return tplSchema;
}
Also used : WorkFlow(com.qlangtech.tis.workflow.pojo.WorkFlow) StringUtils(org.apache.commons.lang.StringUtils) PluginStore(com.qlangtech.tis.plugin.PluginStore) PSchemaField(com.qlangtech.tis.solrdao.pojo.PSchemaField) TIS(com.qlangtech.tis.TIS) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) WorkFlowCriteria(com.qlangtech.tis.workflow.pojo.WorkFlowCriteria) IServerGroupDAO(com.qlangtech.tis.manage.biz.dal.dao.IServerGroupDAO) SaveFileContentAction(com.qlangtech.tis.runtime.module.action.jarcontent.SaveFileContentAction) Document(org.jdom2.Document) com.qlangtech.tis.solrdao(com.qlangtech.tis.solrdao) ByteArrayInputStream(java.io.ByteArrayInputStream) PermissionConstant(com.qlangtech.tis.manage.PermissionConstant) IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) IPluginStore(com.qlangtech.tis.plugin.IPluginStore) EntityResolver(org.xml.sax.EntityResolver) Savefilecontent(com.qlangtech.tis.manage.Savefilecontent) com.qlangtech.tis.manage.biz.dal.pojo(com.qlangtech.tis.manage.biz.dal.pojo) Validator(com.qlangtech.tis.plugin.annotation.Validator) ISolrAppSource(com.qlangtech.tis.manage.ISolrAppSource) JSONException(com.alibaba.fastjson.JSONException) com.qlangtech.tis.manage.common(com.qlangtech.tis.manage.common) Collectors(java.util.stream.Collectors) IOUtils(org.apache.commons.io.IOUtils) ISearchEngineTypeTransfer(com.qlangtech.tis.datax.ISearchEngineTypeTransfer) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) SAXException(org.xml.sax.SAXException) RunEnvironment(com.qlangtech.tis.pubhook.common.RunEnvironment) JSONObject(com.alibaba.fastjson.JSONObject) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Pattern(java.util.regex.Pattern) UnsupportedEncodingException(java.io.UnsupportedEncodingException) LuceneVersion(com.qlangtech.tis.fullbuild.indexbuild.LuceneVersion) ParseResult(com.qlangtech.tis.solrdao.impl.ParseResult) java.util(java.util) BeanUtils(org.apache.commons.beanutils.BeanUtils) DocType(org.jdom2.DocType) Func(com.qlangtech.tis.manage.spring.aop.Func) ColumnMetaData(com.qlangtech.tis.plugin.ds.ColumnMetaData) SolrType(com.qlangtech.tis.solrdao.SolrFieldsParser.SolrType) Context(com.alibaba.citrus.turbine.Context) JsonUtil(com.qlangtech.tis.trigger.util.JsonUtil) JSONArray(com.alibaba.fastjson.JSONArray) com.qlangtech.tis.runtime.module.misc(com.qlangtech.tis.runtime.module.misc) DataxProcessor(com.qlangtech.tis.datax.impl.DataxProcessor) Charset(java.nio.charset.Charset) XModifier(com.yushu.tis.xmodifier.XModifier) DataxUtils(com.qlangtech.tis.offline.DataxUtils) InputSource(org.xml.sax.InputSource) ReflectSchemaFieldType(com.qlangtech.tis.plugin.ds.ReflectSchemaFieldType) FieldTypeFactory(com.qlangtech.tis.plugin.solr.schema.FieldTypeFactory) IOException(java.io.IOException) Maps(com.google.common.collect.Maps) JSON(com.alibaba.fastjson.JSON) StringReader(java.io.StringReader) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Assert(com.qlangtech.tis.common.utils.Assert) SolrType(com.qlangtech.tis.solrdao.SolrFieldsParser.SolrType) ParseResult(com.qlangtech.tis.solrdao.impl.ParseResult) PSchemaField(com.qlangtech.tis.solrdao.pojo.PSchemaField) ColumnMetaData(com.qlangtech.tis.plugin.ds.ColumnMetaData)

Aggregations

ColumnMetaData (com.qlangtech.tis.plugin.ds.ColumnMetaData)16 Collectors (java.util.stream.Collectors)5 StringUtils (org.apache.commons.lang.StringUtils)4 List (java.util.List)3 Map (java.util.Map)3 Context (com.alibaba.citrus.turbine.Context)2 Lists (com.google.common.collect.Lists)2 TIS (com.qlangtech.tis.TIS)2 IDataxProcessor (com.qlangtech.tis.datax.IDataxProcessor)2 DataxReader (com.qlangtech.tis.datax.impl.DataxReader)2 TISExtension (com.qlangtech.tis.extension.TISExtension)2 Validator (com.qlangtech.tis.plugin.annotation.Validator)2 DataType (com.qlangtech.tis.plugin.ds.DataType)2 ISelectedTab (com.qlangtech.tis.plugin.ds.ISelectedTab)2 TISTable (com.qlangtech.tis.plugin.ds.TISTable)2 File (java.io.File)2 Optional (java.util.Optional)2 FileUtils (org.apache.commons.io.FileUtils)2 Configuration (com.alibaba.datax.common.util.Configuration)1 JSON (com.alibaba.fastjson.JSON)1