Class DetectionService

java.lang.Object
edu.university.ecs.lab.detection.DetectionService

public class DetectionService extends Object
Service class for detection of antipatterns, architectural rule violations, and metrics
  • Field Details

    • columnLabels

      private static final String[] columnLabels
      Column labels for violation counts and metrics
    • ANTIPATTERNS

      private static final int ANTIPATTERNS
      Count of antipatterns, metrics, and architectural rules
      See Also:
    • METRICS

      private static final int METRICS
      See Also:
    • ARCHRULES

      private static final int ARCHRULES
      See Also:
    • BASE_DELTA_PATH

      private static String BASE_DELTA_PATH
    • BASE_IR_PATH

      private static String BASE_IR_PATH
    • configPath

      private final String configPath
      Detection services and parameters
    • config

      private final Config config
    • gitService

      private final GitService gitService
    • irExtractionService

      private IRExtractionService irExtractionService
    • arDetectionService

      private ARDetectionService arDetectionService
    • deltaExtractionService

      private DeltaExtractionService deltaExtractionService
    • mergeService

      private MergeService mergeService
    • workbook

      private final org.apache.poi.xssf.usermodel.XSSFWorkbook workbook
    • sheet

      private org.apache.poi.xssf.usermodel.XSSFSheet sheet
  • Constructor Details

    • DetectionService

      public DetectionService(String configPath)
      Construct with given configuration file path
      Parameters:
      configPath - YAML file to extract microservice details from
  • Method Details

    • runDetection

      public void runDetection()
      Method to detect antipatterns, architectural rule violations, and metrics
    • writeHeaders

      private void writeHeaders()
      Write headers to XSSFSheet
    • writeEmptyRow

      private void writeEmptyRow(int rowIndex)
      Write empty row to XSSFSheet
      Parameters:
      rowIndex - index to write row to
    • iterableToList

      private List<org.eclipse.jgit.revwalk.RevCommit> iterableToList(Iterable<org.eclipse.jgit.revwalk.RevCommit> iterable)
      Convert iterable to a list
      Parameters:
      iterable - iterable object to convert
      Returns:
      iterable object converted to a list
    • detectAntipatterns

      private void detectAntipatterns(MicroserviceSystem microserviceSystem, Map<String,Integer> allAntiPatterns)
      Detect antipatterns in the given microservice
      Parameters:
      microserviceSystem - microservice to scan for antipatterns
      allAntiPatterns - map of antipattern names and integers to store antipattern counts
    • detectMetrics

      private void detectMetrics(MicroserviceSystem microserviceSystem, Map<String,Double> metrics, String oldIRPath)
    • updateRules

      private void updateRules(int rowIndex, List<AbstractAR> currARs)
      Update counts of architectural rule violations in excel
      Parameters:
      rowIndex - XSSFSheet row index
      currARs - list of architectural rule violations
    • updateAntiPatterns

      private void updateAntiPatterns(int rowIndex, Map<String,Integer> allAntiPatterns)
      Update antipattern counts in excel
      Parameters:
      rowIndex - XSSFSheet row index
      allAntiPatterns - map of antipatterns to integer count
    • updateMetrics

      private void updateMetrics(int rowIndex, Map<String,Double> metrics)
      Update metric counts in excel
      Parameters:
      rowIndex - XSSFSheet row index
      metrics - map of metrics to double value
    • toJsonArray

      public static com.google.gson.JsonArray toJsonArray(List<List<AbstractAR>> archRulesList)
      Create JSON array from list of architectural rule objects
      Parameters:
      archRulesList - list of AR objects
      Returns:
      JSON array with list entities