Search in sources :

Example 16 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class DataxAction method doUpdateDatax.

@Func(value = PermissionConstant.DATAX_MANAGE)
public void doUpdateDatax(Context context) throws Exception {
    String dataxName = this.getCollectionName();
    DataxProcessor old = IAppSource.load(null, dataxName);
    DataxProcessor editting = IAppSource.load(this, dataxName);
    File oldWorkDir = old.getDataXWorkDir((IPluginContext) null);
    File edittingDir = editting.getDataXWorkDir((IPluginContext) this);
    String edittingDirSuffix = StringUtils.substringAfter(edittingDir.getName(), oldWorkDir.getName());
    Matcher matcher = PatternEdittingDirSuffix.matcher(edittingDirSuffix);
    if (!matcher.matches()) {
        throw new IllegalStateException("dir name is illegal,oldDir:" + oldWorkDir.getAbsolutePath() + " editting dir:" + edittingDir.getAbsolutePath());
    }
    File backDir = new File(oldWorkDir.getParentFile(), oldWorkDir.getName() + ".bak");
    // 先备份
    try {
        FileUtils.moveDirectory(oldWorkDir, backDir);
        FileUtils.moveDirectory(edittingDir, oldWorkDir);
        FileUtils.forceDelete(backDir);
    } catch (Exception e) {
        try {
            FileUtils.moveDirectory(backDir, oldWorkDir);
        } catch (Throwable ex) {
        }
        throw new IllegalStateException("oldWorkDir update is illegal:" + oldWorkDir.getAbsolutePath(), e);
    }
    // 更新一下时间戳,workflow 会重新创建流程
    Application dataXApp = new Application();
    dataXApp.setUpdateTime(new Date());
    ApplicationCriteria appCriteria = new ApplicationCriteria();
    appCriteria.createCriteria().andProjectNameEqualTo(dataxName);
    this.getApplicationDAO().updateByExampleSelective(dataXApp, appCriteria);
    IAppSource.cleanAppSourcePluginStoreCache(null, dataxName);
    IAppSource.cleanAppSourcePluginStoreCache(this, dataxName);
    this.addActionMessage(context, "已经成功更新");
}
Also used : Matcher(java.util.regex.Matcher) ApplicationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria) File(java.io.File) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application) IOException(java.io.IOException) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 17 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class DataxAction method doSaveTableCreateDdl.

@Func(value = PermissionConstant.DATAX_MANAGE)
public void doSaveTableCreateDdl(Context context) throws Exception {
    JSONObject post = this.parseJsonPost();
    String dataXName = post.getString(DataxUtils.DATAX_NAME);
    String createTableDDL = post.getString("content");
    if (StringUtils.isEmpty(createTableDDL)) {
        throw new IllegalArgumentException("create table ddl can not be null");
    }
    if (StringUtils.isEmpty(dataXName)) {
        throw new IllegalArgumentException("param dataXName can not be null");
    }
    DataxProcessor dataxProcessor = IAppSource.load(this, dataXName);
    String createFileName = post.getString("fileName");
    dataxProcessor.saveCreateTableDDL(this, new StringBuffer(createTableDDL), createFileName, true);
    this.addActionMessage(context, "已经成功更新建表DDL脚本 " + createFileName);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 18 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class DataxAction method doValidateDataxProfile.

/**
 * @param context
 * @throws Exception
 */
@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doValidateDataxProfile(Context context) throws Exception {
    Application app = this.parseJsonPost(Application.class);
    SchemaAction.CreateAppResult validateResult = this.createNewApp(context, app, true, (newAppId) -> {
        throw new UnsupportedOperationException();
    });
}
Also used : SchemaAction(com.qlangtech.tis.runtime.module.action.SchemaAction) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 19 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class DataxAction method doGotoEsAppCreateConfirm.

@Func(value = PermissionConstant.APP_ADD)
public void doGotoEsAppCreateConfirm(Context context) throws Exception {
    this.errorsPageShow(context);
    // 这里只做schema的校验
    CreateIndexConfirmModel confiemModel = parseJsonPost(CreateIndexConfirmModel.class);
    String schemaContent = null;
    if (confiemModel.isExpertModel()) {
        schemaContent = confiemModel.getExpert().getXml();
    } else {
        ISearchEngineTypeTransfer typeTransfer = ISearchEngineTypeTransfer.load(this, confiemModel.getDataxName());
        schemaContent = typeTransfer.mergeFromStupidModel(confiemModel.getStupid().getModel(), ISearchEngineTypeTransfer.getOriginExpertSchema(null)).toJSONString();
    }
    ESTableAlias esTableAlias = new ESTableAlias();
    esTableAlias.setSchemaContent(schemaContent);
    this.saveTableMapper(this, confiemModel.getDataxName(), Collections.singletonList(esTableAlias));
}
Also used : CreateIndexConfirmModel(com.qlangtech.tis.runtime.module.action.CreateIndexConfirmModel) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 20 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class DataxAction method doValidateReaderWriter.

/**
 * submit reader type and writer type form for validate
 *
 * @param context
 */
@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doValidateReaderWriter(Context context) throws Exception {
    this.errorsPageShow(context);
    JSONObject post = this.parseJsonPost();
    String dataxPipeName = post.getString("dataxPipeName");
    JSONObject reader = post.getJSONObject("readerDescriptor");
    JSONObject writer = post.getJSONObject("writerDescriptor");
    // Objects.requireNonNull(writer, "writer can not be null");
    if (reader == null || writer == null) {
        this.addErrorMessage(context, "请选择'Reader类型'和'Writer类型'");
        return;
    }
    DataxReader.BaseDataxReaderDescriptor readerDesc = (DataxReader.BaseDataxReaderDescriptor) TIS.get().getDescriptor(reader.getString("impl"));
    DataxWriter.BaseDataxWriterDescriptor writerDesc = (DataxWriter.BaseDataxWriterDescriptor) TIS.get().getDescriptor(writer.getString("impl"));
    DataXBasicProcessMeta processMeta = getDataXBasicProcessMeta(readerDesc, writerDesc);
    // DataxProcessor processor = DataxProcessor.load(this, dataxPipeName);
    // File workDir = processor.getDataXWorkDir(this);
    FileUtils.write(IDataxProcessor.getWriterDescFile(this, dataxPipeName), writerDesc.getId(), TisUTF8.get(), false);
    this.setBizResult(context, processMeta);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Func(com.qlangtech.tis.manage.spring.aop.Func)

Aggregations

Func (com.qlangtech.tis.manage.spring.aop.Func)64 JSONObject (com.alibaba.fastjson.JSONObject)12 DataXJobWorker (com.qlangtech.tis.datax.job.DataXJobWorker)6 File (java.io.File)6 Date (java.util.Date)6 Context (com.alibaba.citrus.turbine.Context)5 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)5 JSONObject (org.json.JSONObject)5 Validator (com.qlangtech.tis.plugin.annotation.Validator)4 IControlMsgHandler (com.qlangtech.tis.runtime.module.misc.IControlMsgHandler)4 IFieldErrorHandler (com.qlangtech.tis.runtime.module.misc.IFieldErrorHandler)4 DelegateControl4JsonPostMsgHandler (com.qlangtech.tis.runtime.module.misc.impl.DelegateControl4JsonPostMsgHandler)4 WorkFlow (com.qlangtech.tis.workflow.pojo.WorkFlow)4 JSONArray (org.json.JSONArray)4 ExecResult (com.qlangtech.tis.assemble.ExecResult)3 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)3 IndexStreamCodeGenerator (com.qlangtech.tis.compiler.streamcode.IndexStreamCodeGenerator)3 DescriptorExtensionList (com.qlangtech.tis.extension.DescriptorExtensionList)3 IOException (java.io.IOException)3 Matcher (java.util.regex.Matcher)3