All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.schoolwow.quickdao.module.database.dcl.kit.DatabaseControlImpl Maven / Gradle / Ivy

There is a newer version: 5.3.1
Show newest version
package cn.schoolwow.quickdao.module.database.dcl.kit;

import cn.schoolwow.quickdao.domain.database.dcl.DataBaseUser;
import cn.schoolwow.quickdao.domain.database.dcl.GrantOption;
import cn.schoolwow.quickdao.module.database.dcl.service.*;
import cn.schoolwow.quickdao.module.database.parent.kit.DatabaseDAOImpl;
import cn.schoolwow.quickflow.QuickFlow;
import cn.schoolwow.quickflow.domain.FlowContext;

import java.util.List;

public class DatabaseControlImpl extends DatabaseDAOImpl implements DatabaseControl {

    public DatabaseControlImpl(QuickFlow quickFlow) {
        super(quickFlow);
    }

    @Override
    public List getUserNameList() {
        FlowContext flowContext = quickFlow.executeFlow(new GetUserNameListFlow());
        List userNameList = (List) flowContext.getData("userNameList");
        return userNameList;
    }

    @Override
    public boolean hasUserName(String username) {
        List userNameList = getUserNameList();
        for(String username1:userNameList){
            if(username1.equalsIgnoreCase(username)){
                return true;
            }
        }
        return false;
    }

    @Override
    public void createUser(DataBaseUser dataBaseUser) {
        quickFlow.startFlow(new CreateDatabaseUserFlow())
                .putReturnData("dataBaseUser", dataBaseUser)
                .execute();
    }

    @Override
    public void modifyPassword(String username, String newPassword) {
        quickFlow.startFlow(new ModifyPasswordFlow())
                .putReturnData("username", username)
                .putReturnData("newPassword", newPassword)
                .execute();
    }

    @Override
    public void deleteUser(DataBaseUser dataBaseUser) {
        quickFlow.startFlow(new DeleteDatabaseUserFlow())
                .putReturnData("dataBaseUser", dataBaseUser)
                .execute();
    }

    @Override
    public void grant(GrantOption grantOption) {
        quickFlow.startFlow(new GrantFlow())
                .putReturnData("grantOption", grantOption)
                .execute();
    }

    @Override
    public void createUserAndGrant(GrantOption grantOption) {
        quickFlow.startFlow(new CreateDatabaseUserAndGrantFlow())
                .putReturnData("grantOption", grantOption)
                .execute();
    }

    @Override
    public void revoke(GrantOption grantOption) {
        quickFlow.startFlow(new RevokeFlow())
                .putReturnData("grantOption", grantOption)
                .execute();
    }

    @Override
    public void flushPrivileges() {
        quickFlow.executeFlow(new FlushPrivilegesFlow());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy