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

75 lines
3.0 KiB
Java
Raw Normal View History

package Visual_DVM_2021.Passes.All;
2024-10-07 14:22:52 +03:00
import Common.Utils.CommonUtils;
import _VisualDVM.Global;
2024-10-09 22:21:57 +03:00
import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.Files.FileType;
import _VisualDVM.Repository.Component.Sapfor.TransformationPermission;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Transformation;
2023-09-17 22:13:42 +03:00
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Vector;
public class PrepareForModulesAssembly extends Transformation {
@Override
protected PassCode_2021 necessary() {
return PassCode_2021.SPF_GetIncludeDependencies;
}
@Override
protected boolean canStart(Object... args) throws Exception {
switch (Global.transformationPermission) {
case All:
return super.canStart(args) && target.CheckSameStyle(Log);
case VariantsOnly:
if (getPermission().equals(TransformationPermission.VariantsOnly)) {
return super.canStart(args) && target.CheckSameStyle(Log);
} else {
Log.Writeln_("Разрешено только построение параллельных вариантов!");
return false;
}
case None:
Log.Writeln_("Нет разрешения на выполнение преобразований");
return false;
}
return false;
}
@Override
protected void body() throws Exception {
File total = Paths.get(target.last_version.Home.getAbsolutePath(), "total.for").toFile();
while (total.exists()) {
2024-10-07 22:22:51 +03:00
total = Paths.get(target.last_version.Home.getAbsolutePath(), CommonUtils.getDateName("total") + ".for").toFile();
2023-09-17 22:13:42 +03:00
Thread.sleep(1000);
}
//--создать
Vector<String> total_lines = new Vector<>();
for (String name : target.files_order) {
2024-10-07 14:22:52 +03:00
total_lines.add(" include " + CommonUtils.Quotes(CommonUtils.toU(name)));
2023-09-17 22:13:42 +03:00
}
FileUtils.writeLines(total, total_lines, false);
//-------------------------------
//скопировать все файлы
for (String name : target.db.files.Data.keySet()) {
Files.copy(
target.db.files.Data.get(name).file.toPath(),
Paths.get(target.last_version.Home.getAbsolutePath(), name)
);
}
}
@Override
protected void performDone() throws Exception {
super.performDone();
//--->>>
target.last_version.Open();
target.last_version.db.BeginTransaction();
for (String name : target.files_order){
DBProjectFile file = target.last_version.db.files.get(name);
file.fileType= FileType.header;
target.last_version.db.Update(file);
}
target.last_version.db.Commit();
target.last_version.Close();
}
}