Resolve "Определять классы, содержащие бизнес-логику" #46
@ -45,6 +45,8 @@ public abstract class StructuralUnitIdentifier {
|
|||||||
|
|
||||||
public abstract boolean isEntityClass(String sourceCode);
|
public abstract boolean isEntityClass(String sourceCode);
|
||||||
|
|
||||||
|
public abstract boolean isBusinessLogicClass(String sourceCode);
|
||||||
|
|
||||||
protected abstract boolean isBusinessLogicClass(File file);
|
protected abstract boolean isBusinessLogicClass(File file);
|
||||||
|
|
||||||
public abstract List<BusinessLogicUnit> getBusinessLogicClasses(String projectPath, String subDirectory, List<File> projectFiles);
|
public abstract List<BusinessLogicUnit> getBusinessLogicClasses(String projectPath, String subDirectory, List<File> projectFiles);
|
||||||
|
@ -126,6 +126,16 @@ public class JavaIdentifier extends StructuralUnitIdentifier {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBusinessLogicClass(String sourceCode) {
|
||||||
|
try {
|
||||||
|
return classContainsAnnotation(sourceCode, SERVICE_ANNOTATION);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean classContainsAnnotation(File file, String annotationDeclaration) throws IOException {
|
private boolean classContainsAnnotation(File file, String annotationDeclaration) throws IOException {
|
||||||
return classContainsAnnotation(new String(Files.readAllBytes(file.toPath())), annotationDeclaration);
|
return classContainsAnnotation(new String(Files.readAllBytes(file.toPath())), annotationDeclaration);
|
||||||
}
|
}
|
||||||
|
@ -70,4 +70,11 @@ public class StructuralUnitService {
|
|||||||
.filter(predicate)
|
.filter(predicate)
|
||||||
.findAny();
|
.findAny();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean containsBusinessLogic(String sourceCode) {
|
||||||
|
return getStructuralUnitIdentifier(
|
||||||
|
structuralUnitIdentifier -> structuralUnitIdentifier.canAppliedToCode(sourceCode))
|
||||||
|
.map(identifier -> identifier.isBusinessLogicClass(sourceCode))
|
||||||
|
.orElse(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ public class FileChange extends BaseEntity {
|
|||||||
|
|
||||||
private Boolean containsEntity;
|
private Boolean containsEntity;
|
||||||
|
|
||||||
|
private Boolean containsBusinessLogic;
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "file_change_id", unique = true)
|
@JoinColumn(name = "file_change_id", unique = true)
|
||||||
@Fetch(FetchMode.SUBSELECT)
|
@Fetch(FetchMode.SUBSELECT)
|
||||||
@ -86,4 +88,20 @@ public class FileChange extends BaseEntity {
|
|||||||
public void setContainsEntity(boolean containsEntity) {
|
public void setContainsEntity(boolean containsEntity) {
|
||||||
this.containsEntity = containsEntity;
|
this.containsEntity = containsEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getContainsEntity() {
|
||||||
|
return containsEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContainsEntity(Boolean containsEntity) {
|
||||||
|
this.containsEntity = containsEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getContainsBusinessLogic() {
|
||||||
|
return containsBusinessLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContainsBusinessLogic(Boolean containsBusinessLogic) {
|
||||||
|
this.containsBusinessLogic = containsBusinessLogic;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,6 +206,9 @@ public class GitRepositoryService {
|
|||||||
fileChange.setContainsEntity(
|
fileChange.setContainsEntity(
|
||||||
structuralUnitService.containsEntity(getContent(repository, commit, maybeFileName.get()))
|
structuralUnitService.containsEntity(getContent(repository, commit, maybeFileName.get()))
|
||||||
);
|
);
|
||||||
|
fileChange.setContainsBusinessLogic(
|
||||||
|
structuralUnitService.containsBusinessLogic(getContent(repository, commit, maybeFileName.get()))
|
||||||
|
);
|
||||||
/// вытащить другие изменения из коммита
|
/// вытащить другие изменения из коммита
|
||||||
changes.add(fileChange);
|
changes.add(fileChange);
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,9 @@
|
|||||||
<column name="contains_entity" type="boolean"/>
|
<column name="contains_entity" type="boolean"/>
|
||||||
</addColumn>
|
</addColumn>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
<changeSet author="orion" id="20210419-100000-1">
|
||||||
|
<addColumn tableName="file_change">
|
||||||
|
<column name="contains_business_logic" type="boolean"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
Loading…
Reference in New Issue
Block a user