Search in sources :

Example 1 with IWorkflowDAOFacade

use of com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade in project tis by qlangtech.

the class TestCollectionAction method clearUpDB.

private void clearUpDB() {
    IWorkflowDAOFacade wfDaoFacade = applicationContext.getBean("wfDaoFacade", IWorkflowDAOFacade.class);
    DatasourceTableCriteria tabCriteria = new DatasourceTableCriteria();
    tabCriteria.createCriteria().andNameEqualTo(TEST_TABLE_EMPLOYEES_NAME);
    wfDaoFacade.getDatasourceTableDAO().deleteByExample(tabCriteria);
    DatasourceDbCriteria dbCriteria = new DatasourceDbCriteria();
    dbCriteria.createCriteria().andNameEqualTo(TEST_DS_NAME);
    wfDaoFacade.getDatasourceDbDAO().deleteByExample(dbCriteria);
    WorkFlowCriteria wfCriteria = new WorkFlowCriteria();
    wfCriteria.createCriteria().andNameEqualTo(TEST_TABLE_EMPLOYEES_NAME);
    wfDaoFacade.getWorkFlowDAO().deleteByExample(wfCriteria);
    // daoContext" class="com.qlangtech.tis.manage.common.RunContextImpl
    RunContext daoContext = applicationContext.getBean("daoContext", RunContext.class);
    ApplicationCriteria appCriteria = new ApplicationCriteria();
    appCriteria.createCriteria().andProjectNameEqualTo(TISCollectionUtils.NAME_PREFIX + TEST_TABLE_EMPLOYEES_NAME);
    for (Application app : daoContext.getApplicationDAO().selectByExample(appCriteria)) {
        ServerGroupCriteria sgCriteria = new ServerGroupCriteria();
        sgCriteria.createCriteria().andAppIdEqualTo(app.getAppId());
        daoContext.getServerGroupDAO().deleteByExample(sgCriteria);
    }
    daoContext.getApplicationDAO().deleteByExample(appCriteria);
    for (Long gid : daoContext.getServerGroupDAO().getServergroupWithoutAppReference()) {
        // assertNotNull(g.getGid());
        daoContext.getServerGroupDAO().deleteByPrimaryKey(gid.intValue());
    }
// select g.gid
// from server_group g left join application a on g.app_id = a.app_id
// where a.app_id is null
}
Also used : ApplicationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria) DatasourceTableCriteria(com.qlangtech.tis.workflow.pojo.DatasourceTableCriteria) ServerGroupCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria) IWorkflowDAOFacade(com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade) WorkFlowCriteria(com.qlangtech.tis.workflow.pojo.WorkFlowCriteria) DatasourceDbCriteria(com.qlangtech.tis.workflow.pojo.DatasourceDbCriteria) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application)

Example 2 with IWorkflowDAOFacade

use of com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade in project tis by qlangtech.

the class PluginItems method getExistDbs.

/**
 * datax中显示已由数据源使用 <br>
 * must call form Descriptor
 *
 * @param extendClass
 * @return
 */
public static List<Option> getExistDbs(String... extendClass) {
    if (OfflineDatasourceAction.existDbs != null) {
        return OfflineDatasourceAction.existDbs;
    }
    if (extendClass == null || extendClass.length < 1) {
        throw new IllegalArgumentException("param extendClass can not be null");
    }
    Descriptor descriptor = GroovyShellEvaluate.descriptorThreadLocal.get();
    Objects.requireNonNull(descriptor, "descriptor can not be null");
    if (dbUpdateEventObservers.add(descriptor)) {
        // 当有数据源更新时需要将descriptor的属性重新更新一下
        addPluginItemsSaveObserver(new PluginItemsSaveObserver() {

            @Override
            public void afterSaved(PluginItemsSaveEvent event) {
                if (event.heteroEnum == HeteroEnum.DATASOURCE) {
                    descriptor.cleanPropertyTypes();
                }
            }
        });
    }
    IWorkflowDAOFacade wfFacade = BasicServlet.getBeanByType(ServletActionContext.getServletContext(), IWorkflowDAOFacade.class);
    Objects.requireNonNull(wfFacade, "wfFacade can not be null");
    DatasourceDbCriteria dbCriteria = new DatasourceDbCriteria();
    // Lists.newArrayList(extendClass).stre;
    List<String> extendClazzs = Lists.newArrayList();
    for (String type : extendClass) {
        extendClazzs.add(StringUtils.lowerCase(type));
    }
    dbCriteria.createCriteria().andExtendClassIn(extendClazzs);
    List<com.qlangtech.tis.workflow.pojo.DatasourceDb> dbs = wfFacade.getDatasourceDbDAO().selectByExample(dbCriteria);
    return dbs.stream().map((db) -> new Option(db.getName(), db.getName())).collect(Collectors.toList());
}
Also used : OfflineDatasourceAction(com.qlangtech.tis.offline.module.action.OfflineDatasourceAction) java.util(java.util) TargetResName(com.qlangtech.tis.coredefine.module.action.TargetResName) IAppSource(com.qlangtech.tis.manage.IAppSource) TIS(com.qlangtech.tis.TIS) DatasourceDbCriteria(com.qlangtech.tis.workflow.pojo.DatasourceDbCriteria) Option(com.qlangtech.tis.manage.common.Option) PostedDSProp(com.qlangtech.tis.plugin.ds.PostedDSProp) DbScope(com.qlangtech.tis.offline.DbScope) StringUtils(org.apache.commons.lang3.StringUtils) Context(com.alibaba.citrus.turbine.Context) ParamsConfigPluginStore(com.qlangtech.tis.plugin.credentials.ParamsConfigPluginStore) DataXJobWorker(com.qlangtech.tis.datax.job.DataXJobWorker) BasicServlet(com.qlangtech.tis.manage.servlet.BasicServlet) Lists(com.google.common.collect.Lists) IPropertyType(com.qlangtech.tis.extension.IPropertyType) PluginFormProperties(com.qlangtech.tis.extension.PluginFormProperties) DataSourceFactory(com.qlangtech.tis.plugin.ds.DataSourceFactory) GroovyShellEvaluate(com.qlangtech.tis.extension.util.GroovyShellEvaluate) IWorkflowDAOFacade(com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade) com.qlangtech.tis.plugin(com.qlangtech.tis.plugin) Descriptor(com.qlangtech.tis.extension.Descriptor) IPluginEnum(com.qlangtech.tis.IPluginEnum) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ServletActionContext(org.apache.struts2.ServletActionContext) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) SuFormProperties(com.qlangtech.tis.extension.impl.SuFormProperties) Describable(com.qlangtech.tis.extension.Describable) IWorkflowDAOFacade(com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade) Descriptor(com.qlangtech.tis.extension.Descriptor) Option(com.qlangtech.tis.manage.common.Option) DatasourceDbCriteria(com.qlangtech.tis.workflow.pojo.DatasourceDbCriteria)

Aggregations

IWorkflowDAOFacade (com.qlangtech.tis.workflow.dao.IWorkflowDAOFacade)2 DatasourceDbCriteria (com.qlangtech.tis.workflow.pojo.DatasourceDbCriteria)2 Context (com.alibaba.citrus.turbine.Context)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 IPluginEnum (com.qlangtech.tis.IPluginEnum)1 TIS (com.qlangtech.tis.TIS)1 TargetResName (com.qlangtech.tis.coredefine.module.action.TargetResName)1 DataxReader (com.qlangtech.tis.datax.impl.DataxReader)1 DataXJobWorker (com.qlangtech.tis.datax.job.DataXJobWorker)1 Describable (com.qlangtech.tis.extension.Describable)1 Descriptor (com.qlangtech.tis.extension.Descriptor)1 IPropertyType (com.qlangtech.tis.extension.IPropertyType)1 PluginFormProperties (com.qlangtech.tis.extension.PluginFormProperties)1 SuFormProperties (com.qlangtech.tis.extension.impl.SuFormProperties)1 GroovyShellEvaluate (com.qlangtech.tis.extension.util.GroovyShellEvaluate)1 IAppSource (com.qlangtech.tis.manage.IAppSource)1 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)1 ApplicationCriteria (com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria)1 ServerGroupCriteria (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria)1