Files
VisualSapfor/src/Visual_DVM_2021/Passes/Server/CloneServerObject.java

35 lines
1.2 KiB
Java
Raw Normal View History

package Visual_DVM_2021.Passes.Server;
import Common_old.Current;
import Common.Database.Objects.riDBObject;
import 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 (!Current.Check(Log, currentName()))
return false;
//---------
pk = null;
if (Current.getAccount().CheckRegistered(Log)) {
target = d.newInstance();
target.SynchronizeFields(src=(D) Current.get(currentName()));
//единственное отличие клона - текущий автор
target.description+=" копия";
target.sender_name = Current.getAccount().name;
target.sender_address = Current.getAccount().email;
return true;
}
return false;
}
}