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, "已经成功更新");
}
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);
}
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();
});
}
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));
}
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);
}
Aggregations