#12 -- Fix code

This commit is contained in:
Anton Romanov 2021-04-10 12:19:44 +04:00
parent 03e2b7ac07
commit bf611faa38

View File

@ -13,6 +13,7 @@ import ru.ulstu.extractor.service.GitRepositoryService;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.function.Predicate;
@Service
public class StructuralUnitService {
@ -32,18 +33,24 @@ public class StructuralUnitService {
File rootPath = gitRepositoryService.getProjectDirectoryFile(repositoryUrl);
List<File> projectFiles = directoryService.getFilesRecursively(rootPath);
List<File> rootProjectFiles = directoryService.getDirectoryFiles(rootPath.toPath());
StructuralUnitIdentifier selectedIdentifier = structuralUnitIdentifiers.stream()
.filter(structuralUnitIdentifier -> structuralUnitIdentifier.canAppliedToProject(rootPath.getPath(), projectFiles, rootProjectFiles))
.findAny()
.orElseThrow(() -> new RuntimeException("Identifier not found"));
return selectedIdentifier.getEntityClasses(rootPath.getPath(), projectFiles, rootProjectFiles);
return getStructuralUnitIdentifier(
structuralUnitIdentifier -> structuralUnitIdentifier.canAppliedToProject(
rootPath.getPath(),
projectFiles,
rootProjectFiles)
).getEntityClasses(rootPath.getPath(), projectFiles, rootProjectFiles);
}
public boolean containsEntity(File projectFile) {
StructuralUnitIdentifier selectedIdentifier = structuralUnitIdentifiers.stream()
.filter(structuralUnitIdentifier -> structuralUnitIdentifier.canAppliedToFile(projectFile))
return getStructuralUnitIdentifier(
structuralUnitIdentifier -> structuralUnitIdentifier.canAppliedToFile(projectFile)
).isEntityClass(projectFile);
}
private StructuralUnitIdentifier getStructuralUnitIdentifier(Predicate<StructuralUnitIdentifier> predicate) {
return structuralUnitIdentifiers.stream()
.filter(predicate)
.findAny()
.orElseThrow(() -> new RuntimeException("Identifier not found"));
return selectedIdentifier.isEntityClass(projectFile);
}
}