Search in sources :

Example 1 with ISolrAppSource

use of com.qlangtech.tis.manage.ISolrAppSource in project tis by qlangtech.

the class SchemaAction method doGetTplFields.

/**
 * 创建新索引流程取得通过workflow反射Schema 生成索引
 *
 * @param context
 * @throws Exception
 */
public void doGetTplFields(Context context) throws Exception {
    AddAppAction.ExtendApp app = this.parseJsonPost(AddAppAction.ExtendApp.class);
    CreateAppResult validateResult = this.createNewApp(context, app, -1, /* publishSnapshotId */
    null, /* schemaContent */
    true);
    if (!validateResult.isSuccess()) {
        return;
    }
    ISolrAppSource appSource = app.createAppSource(this);
    SchemaResult tplSchema = mergeWfColsWithTplCollection(this, context, appSource, ISchemaPluginContext.NULL);
    Objects.requireNonNull(tplSchema, "tplSchema can not be null");
    // 序列化结果
    this.setBizResult(context, tplSchema.toJSON());
}
Also used : ISolrAppSource(com.qlangtech.tis.manage.ISolrAppSource)

Example 2 with ISolrAppSource

use of com.qlangtech.tis.manage.ISolrAppSource 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

ISolrAppSource (com.qlangtech.tis.manage.ISolrAppSource)2 Context (com.alibaba.citrus.turbine.Context)1 JSON (com.alibaba.fastjson.JSON)1 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONException (com.alibaba.fastjson.JSONException)1 JSONObject (com.alibaba.fastjson.JSONObject)1 Maps (com.google.common.collect.Maps)1 TIS (com.qlangtech.tis.TIS)1 Assert (com.qlangtech.tis.common.utils.Assert)1 IDataxProcessor (com.qlangtech.tis.datax.IDataxProcessor)1 ISearchEngineTypeTransfer (com.qlangtech.tis.datax.ISearchEngineTypeTransfer)1 DataxProcessor (com.qlangtech.tis.datax.impl.DataxProcessor)1 DataxReader (com.qlangtech.tis.datax.impl.DataxReader)1 LuceneVersion (com.qlangtech.tis.fullbuild.indexbuild.LuceneVersion)1 PermissionConstant (com.qlangtech.tis.manage.PermissionConstant)1 Savefilecontent (com.qlangtech.tis.manage.Savefilecontent)1 IServerGroupDAO (com.qlangtech.tis.manage.biz.dal.dao.IServerGroupDAO)1 com.qlangtech.tis.manage.biz.dal.pojo (com.qlangtech.tis.manage.biz.dal.pojo)1 com.qlangtech.tis.manage.common (com.qlangtech.tis.manage.common)1 Func (com.qlangtech.tis.manage.spring.aop.Func)1