package core.process;

import core.operation.Operation;
import core.user.User;
import error.GExcptFactory;
import error.GExcptSQL;

public abstract class Process {

    private String permission;
    private Operation operation;
    private String buttonName;
    private String info;
    private String processOptions;

    public Process(String permission, String operationName, String processOptions, String info) throws Exception {
        super();
        this.setPermission(permission);
        this.setOperation(operationName);
        this.setInfo(info);
        this.setProcessOptions(processOptions);
        operation.setProcessOperations(processOptions);
    }

    public void setUserOperations(String key,Object value){
        this.operation.addUserOperations(key,value);
    }
    public void execute(User subject) throws GExcptSQL {
        this.operation.execute(subject);
    }
    private void setOperation(String operationName) throws GExcptFactory {
        try {
            this.operation = (Operation) core.utils.GetObjectByName.getOperationByName(operationName);
        } catch (Exception e) {
            throw new GExcptFactory("create"+operationName+"failure");
        }
    }

    public void setInfo(String info) {
        this.info = info;
    }
    public String getButtonName() {
        return buttonName;
    }
    public void setButtonName(String buttonName) {
        this.buttonName = buttonName;
    }
   public String getInfo() {
        return info;
    }
    public String getPermission() {
        return permission;
    }

    public void setPermission(String permission) {
        this.permission = permission;
    }

    public Operation getOperation() {
        return operation;
    }

    public void setOperation(Operation operation) {
        this.operation = operation;
    }

    public String getProcessOptions() {
        return processOptions;
    }

    public void setProcessOptions(String processOptions) {
        this.processOptions = processOptions;
    }

}
