#12 -- Fix code
This commit is contained in:
parent
03e2b7ac07
commit
bf611faa38
@ -13,6 +13,7 @@ import ru.ulstu.extractor.service.GitRepositoryService;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class StructuralUnitService {
|
public class StructuralUnitService {
|
||||||
@ -32,18 +33,24 @@ public class StructuralUnitService {
|
|||||||
File rootPath = gitRepositoryService.getProjectDirectoryFile(repositoryUrl);
|
File rootPath = gitRepositoryService.getProjectDirectoryFile(repositoryUrl);
|
||||||
List<File> projectFiles = directoryService.getFilesRecursively(rootPath);
|
List<File> projectFiles = directoryService.getFilesRecursively(rootPath);
|
||||||
List<File> rootProjectFiles = directoryService.getDirectoryFiles(rootPath.toPath());
|
List<File> rootProjectFiles = directoryService.getDirectoryFiles(rootPath.toPath());
|
||||||
StructuralUnitIdentifier selectedIdentifier = structuralUnitIdentifiers.stream()
|
return getStructuralUnitIdentifier(
|
||||||
.filter(structuralUnitIdentifier -> structuralUnitIdentifier.canAppliedToProject(rootPath.getPath(), projectFiles, rootProjectFiles))
|
structuralUnitIdentifier -> structuralUnitIdentifier.canAppliedToProject(
|
||||||
.findAny()
|
rootPath.getPath(),
|
||||||
.orElseThrow(() -> new RuntimeException("Identifier not found"));
|
projectFiles,
|
||||||
return selectedIdentifier.getEntityClasses(rootPath.getPath(), projectFiles, rootProjectFiles);
|
rootProjectFiles)
|
||||||
|
).getEntityClasses(rootPath.getPath(), projectFiles, rootProjectFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsEntity(File projectFile) {
|
public boolean containsEntity(File projectFile) {
|
||||||
StructuralUnitIdentifier selectedIdentifier = structuralUnitIdentifiers.stream()
|
return getStructuralUnitIdentifier(
|
||||||
.filter(structuralUnitIdentifier -> structuralUnitIdentifier.canAppliedToFile(projectFile))
|
structuralUnitIdentifier -> structuralUnitIdentifier.canAppliedToFile(projectFile)
|
||||||
|
).isEntityClass(projectFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private StructuralUnitIdentifier getStructuralUnitIdentifier(Predicate<StructuralUnitIdentifier> predicate) {
|
||||||
|
return structuralUnitIdentifiers.stream()
|
||||||
|
.filter(predicate)
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElseThrow(() -> new RuntimeException("Identifier not found"));
|
.orElseThrow(() -> new RuntimeException("Identifier not found"));
|
||||||
return selectedIdentifier.isEntityClass(projectFile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user