Search in sources :

Example 1 with GenerateDAOAndIncrScript

use of com.qlangtech.tis.compiler.streamcode.GenerateDAOAndIncrScript in project tis by qlangtech.

the class CoreAction method doCompileAndPackage.

/**
 * 编译打包
 *
 * @param context
 * @throws Exception
 */
@Func(value = PermissionConstant.PERMISSION_INCR_PROCESS_CONFIG_EDIT)
public void doCompileAndPackage(Context context) throws Exception {
    IBasicAppSource appSource = IAppSource.load(null, this.getCollectionName());
    IndexStreamCodeGenerator indexStreamCodeGenerator = getIndexStreamCodeGenerator(this);
    IndexIncrStatus incrStatus = new IndexIncrStatus();
    GenerateDAOAndIncrScript daoAndIncrScript = new GenerateDAOAndIncrScript(this, indexStreamCodeGenerator);
    // if (appSource.isExcludeFacadeDAOSupport()) {
    if (true) {
        daoAndIncrScript.generateIncrScript(context, incrStatus, true, Collections.emptyMap());
    } else {
        Map<Integer, Long> dependencyDbs = getDependencyDbsMap(this, indexStreamCodeGenerator);
        // 需要facadeDAO支持
        daoAndIncrScript.generate(context, incrStatus, true, dependencyDbs);
    }
}
Also used : IndexStreamCodeGenerator(com.qlangtech.tis.compiler.streamcode.IndexStreamCodeGenerator) GenerateDAOAndIncrScript(com.qlangtech.tis.compiler.streamcode.GenerateDAOAndIncrScript) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 2 with GenerateDAOAndIncrScript

use of com.qlangtech.tis.compiler.streamcode.GenerateDAOAndIncrScript in project tis by qlangtech.

the class CoreAction method generateDAOAndIncrScript.

/**
 * @param module
 * @param context
 * @param
 * @param validateGlobalIncrStreamFactory
 * @param compilerAndPackage
 * @param excludeFacadeDAOSupport         由于单表同步不需要dao支持,可以选择false即可
 * @return
 * @throws Exception
 */
public static IndexIncrStatus generateDAOAndIncrScript(BasicModule module, Context context, boolean validateGlobalIncrStreamFactory, boolean compilerAndPackage, boolean excludeFacadeDAOSupport) throws Exception {
    IndexStreamCodeGenerator indexStreamCodeGenerator = getIndexStreamCodeGenerator(module);
    // List<FacadeContext> facadeList = indexStreamCodeGenerator.getFacadeList();
    // PluginStore<IncrStreamFactory> store = TIS.getPluginStore(IncrStreamFactory.class);
    IndexIncrStatus incrStatus = doGetDataXReaderWriterDesc(module.getCollectionName());
    // if (validateGlobalIncrStreamFactory && store.getPlugin() == null) {
    // throw new IllegalStateException("global IncrStreamFactory config can not be null");
    // }
    // if (store.getPlugin() != null) {
    // 已经定义了全局插件
    IPluginStore<IncrStreamFactory> collectionBindIncrStreamFactoryStore = getIncrStreamFactoryStore(module);
    if (collectionBindIncrStreamFactoryStore.getPlugin() == null) {
    // 需要将全局插件属性拷贝到collection绑定的插件属性上来
    // Descriptor flinkStreamDesc = TIS.get().getDescriptor(IncrStreamFactory.FLINK_STREM);
    // if (flinkStreamDesc == null) {
    // throw new IllegalStateException(
    // "can not find findStream Factory in plugin repository, Descriptor ID:" + IncrStreamFactory.FLINK_STREM);
    // }
    // 
    // collectionBindIncrStreamFactoryStore.setPlugins(module, Optional.of(context)
    // , Collections.singletonList(flinkStreamDesc.newInstance(module, Collections.emptyMap(), Optional.empty())));
    // throw new IllegalStateException("collectionName:" + module.getCollectionName() + " relevant plugin can not be null " + IncrStreamFactory.class.getName());
    }
    // }
    // 这里永远是false应该
    incrStatus.setK8sPluginInitialized(false);
    // 判断是否已经成功创建,如果已经创建了,就退出
    if (indexStreamCodeGenerator.isIncrScriptDirCreated()) {
        incrStatus.setIncrScriptCreated(true);
        incrStatus.setIncrScriptMainFileContent(indexStreamCodeGenerator.readIncrScriptMainFileContent());
        log.info("incr script has create ignore it file path:{}", indexStreamCodeGenerator.getIncrScriptDirPath());
    // this.setBizResult(context, incrStatus);
    }
    GenerateDAOAndIncrScript generateDAOAndIncrScript = new GenerateDAOAndIncrScript(module, indexStreamCodeGenerator);
    if (excludeFacadeDAOSupport) {
        generateDAOAndIncrScript.generateIncrScript(context, incrStatus, compilerAndPackage, Collections.emptyMap());
    } else {
        // 需要facadeDAO支持
        generateDAOAndIncrScript.generate(context, incrStatus, compilerAndPackage, getDependencyDbsMap(module, indexStreamCodeGenerator));
    }
    incrStatus.setIncrScriptTimestamp(indexStreamCodeGenerator.getIncrScriptTimestamp());
    return incrStatus;
}
Also used : IndexStreamCodeGenerator(com.qlangtech.tis.compiler.streamcode.IndexStreamCodeGenerator) GenerateDAOAndIncrScript(com.qlangtech.tis.compiler.streamcode.GenerateDAOAndIncrScript) IncrStreamFactory(com.qlangtech.tis.plugin.incr.IncrStreamFactory)

Aggregations

GenerateDAOAndIncrScript (com.qlangtech.tis.compiler.streamcode.GenerateDAOAndIncrScript)2 IndexStreamCodeGenerator (com.qlangtech.tis.compiler.streamcode.IndexStreamCodeGenerator)2 Func (com.qlangtech.tis.manage.spring.aop.Func)1 IncrStreamFactory (com.qlangtech.tis.plugin.incr.IncrStreamFactory)1