Files
VisualSapfor/src/Visual_DVM_2021/Passes/All/SynchronizeTests.java

74 lines
2.4 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package Visual_DVM_2021.Passes.All;
import Common.Current;
import Common.UI.Menus_2023.PassButton;
import Common.UI.UI;
import Common.Utils.Utils;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
import org.apache.commons.io.FileUtils;
import javax.swing.*;
import java.io.File;
public class SynchronizeTests extends TestingSystemPass<Object> {
File new_db_file;
@Override
protected boolean canStart(Object... args) throws Exception {
return Current.getAccount().CheckRegistered(Log);
}
@Override
public String getIconPath() {
return "/icons/ComponentsActual.png";
}
@Override
public String getButtonText() {
return "";
}
@Override
public JButton createButton() {
return new PassButton(this);
}
@Override
protected void showPreparation() throws Exception {
server.db.SaveLastSelections();
//--
// server.db.machines _testing_system
//--
server.db.configurations.ClearUI();
server.db.groups.ClearUI();
server.db.sapforConfigurations.ClearUI();
server.db.serverSapfors.ClearUI();
server.db.dvmPackages.ClearUI();
server.db.sapforPackages.ClearUI();
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(ServerCode.ReceiveTestsDatabase));
response.Unpack(new_db_file = Utils.getTempFileName("tdb"));
}
@Override
protected void performDone() throws Exception {
super.performDone();
server.db.Disconnect();
Utils.forceDeleteWithCheck(server.db.getFile());
FileUtils.moveFile(new_db_file, server.db.getFile());
server.db.Connect();
server.db.prepareTablesStatements();
server.db.Synchronize();
}
@Override
protected void showDone() throws Exception {
if (UI.HasMainWindow()) {
//server.db.machines
server.db.configurations.ShowUI();
server.db.groups.ShowUI();
server.db.sapforConfigurations.ShowUI();
server.db.serverSapfors.ShowUI();
server.db.dvmPackages.ShowUI();
server.db.sapforPackages.ShowUI();
server.db.RestoreLastSelections(); //---- ? объединить с RestoreCredentials
UI.getMainWindow().ShowCheckedTestsCount();
}
}
}