package core.operation;


import core.user.User;
import error.GExcptSQL;
import gdms.Mode;

import java.util.Map;

public abstract class Operation {

    private Map<String, Object> options;
    private User subject;
    Operation(){
        super();
    }
    public User getSubject() {
        return subject;
    }
    public void setSubject(User subject) {
        this.subject = subject;
    }
    public void setOptions(String options) {
        this.options = core.operation.utils.util.string2MapOptions(options);
    }
    public void setProcessOperations(String processOptions){
        setOptions(processOptions);
    }
    public void addUserOperations(String key, Object value){
        if ( Mode.strict == 1){
            if(!this.options.containsKey(key)) {
                try {
                    throw new Exception("options repeat");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        this.options.put(key,value);
    }
    public abstract void execute(User subject) throws GExcptSQL;

}
