package Visual_DVM_2021.Passes.Server;
import Common.Current_;
import _VisualDVM.Current;
import Common.Database.Objects.riDBObject;
import _VisualDVM.Global;
import _VisualDVM.Repository.RepositoryServer;
public abstract class CloneServerObject<S extends RepositoryServer, D extends riDBObject> extends PublishServerObject<S, D> {
    public D src;
    @Override
    public String getIconPath() {
        return "/icons/MultiFiles.png";
    }
    public CloneServerObject(S server_in, Class<D> d_in) {
        super(server_in, d_in);
    }
    protected abstract Current currentName();
    @Override
    protected boolean canStart(Object... args) throws Exception {
        src=null;
        if (!Global.mainModule.Check(Log, currentName()))
            return false;

        //---------
        pk = null;
        if (Global.mainModule.getAccount().CheckRegistered(Log)) {
            target = d.newInstance();
            target.SynchronizeFields(src=(D) Global.mainModule.get(currentName()));
            //единственное отличие клона - текущий автор
            target.description+=" копия";
            target.sender_name = Global.mainModule.getAccount().name;
            target.sender_address = Global.mainModule.getAccount().email;
            return true;
        }
        return false;
    }
}
