diff --git a/core/src/main/java/rocks/artur/api/GetCollectionStatistics.java b/core/src/main/java/rocks/artur/api/GetCollectionStatistics.java index d6c97e6..4ee5ae3 100644 --- a/core/src/main/java/rocks/artur/api/GetCollectionStatistics.java +++ b/core/src/main/java/rocks/artur/api/GetCollectionStatistics.java @@ -5,7 +5,6 @@ import java.util.Map; public interface GetCollectionStatistics { - Map getSizeStatistics(FilterCriteria filterCriteria); + Map getStatistics(FilterCriteria filterCriteria); - double getConflictRate(); } diff --git a/core/src/main/java/rocks/artur/api_impl/GetCollectionStatisticsImpl.java b/core/src/main/java/rocks/artur/api_impl/GetCollectionStatisticsImpl.java index 0021701..ea97869 100644 --- a/core/src/main/java/rocks/artur/api_impl/GetCollectionStatisticsImpl.java +++ b/core/src/main/java/rocks/artur/api_impl/GetCollectionStatisticsImpl.java @@ -15,13 +15,9 @@ public GetCollectionStatisticsImpl(CharacterisationResultGateway characterisatio } @Override - public Map getSizeStatistics(FilterCriteria filterCriteria) { - Map sizeStatistics = characterisationResultGateway.getSizeStatistics(filterCriteria); + public Map getStatistics(FilterCriteria filterCriteria) { + Map sizeStatistics = characterisationResultGateway.getCollectionStatistics(filterCriteria); return sizeStatistics; } - @Override - public double getConflictRate() { - return characterisationResultGateway.getConflictRate(); - } } diff --git a/core/src/main/java/rocks/artur/domain/CharacterisationResultGateway.java b/core/src/main/java/rocks/artur/domain/CharacterisationResultGateway.java index ce0a750..f9a86bc 100644 --- a/core/src/main/java/rocks/artur/domain/CharacterisationResultGateway.java +++ b/core/src/main/java/rocks/artur/domain/CharacterisationResultGateway.java @@ -55,7 +55,7 @@ public interface CharacterisationResultGateway { */ List getConflictsByFilepath(String filepath); - Map getSizeStatistics(FilterCriteria filterCriteria); + Map getCollectionStatistics(FilterCriteria filterCriteria); List getPropertyValueDistribution(Property property, FilterCriteria filter); diff --git a/infra-persistence/src/main/java/rocks/artur/jpa/CharacterisationResultGatewayJpaImpl.java b/infra-persistence/src/main/java/rocks/artur/jpa/CharacterisationResultGatewayJpaImpl.java index 64fdcc8..e53ee2e 100644 --- a/infra-persistence/src/main/java/rocks/artur/jpa/CharacterisationResultGatewayJpaImpl.java +++ b/infra-persistence/src/main/java/rocks/artur/jpa/CharacterisationResultGatewayJpaImpl.java @@ -158,25 +158,19 @@ public List getConflictsByFilepath(String filepath) { } @Override - public Map getSizeStatistics(FilterCriteria filterCriteria) { + public Map getCollectionStatistics(FilterCriteria filterCriteria) { Map result = new HashMap<>(); double[] sizeStatistics = characterisationResultViewRepository.getSizeStatistics(filterCriteria); result.put("totalSize", sizeStatistics[0]); - Long minSize = characterisationResultViewRepository.getMinSize(); result.put("minSize", sizeStatistics[1]); - Long maxSize = characterisationResultViewRepository.getMaxSize(); result.put("maxSize", sizeStatistics[2]); - - Long avgSize = characterisationResultViewRepository.getAvgSize(); result.put("avgSize", sizeStatistics[3]); - - Long totalCount = characterisationResultViewRepository.getTotalCount(); result.put("totalCount", sizeStatistics[4]); - double conflictRate = this.getConflictRate(); - result.put("conflictRate", conflictRate); - + double[] conflictStatistics = characterisationResultViewRepository.getConflictStatistics(filterCriteria); + result.put("conflictRate", conflictStatistics[1]); + result.put("conflictCount", conflictStatistics[0]); return result; } diff --git a/infra-persistence/src/main/java/rocks/artur/jpa/view/CustomCharacterisationResultViewRepository.java b/infra-persistence/src/main/java/rocks/artur/jpa/view/CustomCharacterisationResultViewRepository.java index 00a0058..fa4bd35 100644 --- a/infra-persistence/src/main/java/rocks/artur/jpa/view/CustomCharacterisationResultViewRepository.java +++ b/infra-persistence/src/main/java/rocks/artur/jpa/view/CustomCharacterisationResultViewRepository.java @@ -12,6 +12,8 @@ public interface CustomCharacterisationResultViewRepository { List getObjects(FilterCriteria filterCriteria); + double[] getConflictStatistics(FilterCriteria filterCriteria); + List getRandomSamples(FilterCriteria filterCriteria, int sampleSize); List getSelectiveFeatureDistributionSamples(FilterCriteria filterCriteria, List properties); diff --git a/infra-persistence/src/main/java/rocks/artur/jpa/view/CustomCharacterisationResultViewRepositoryImpl.java b/infra-persistence/src/main/java/rocks/artur/jpa/view/CustomCharacterisationResultViewRepositoryImpl.java index c8916e5..fda89e7 100644 --- a/infra-persistence/src/main/java/rocks/artur/jpa/view/CustomCharacterisationResultViewRepositoryImpl.java +++ b/infra-persistence/src/main/java/rocks/artur/jpa/view/CustomCharacterisationResultViewRepositoryImpl.java @@ -8,7 +8,6 @@ import rocks.artur.domain.FilterCriteria; import rocks.artur.domain.Property; -import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -82,7 +81,7 @@ public List getObjects(FilterCriteria filterCriteria) { } @Override - public double[] getSizeStatistics(FilterCriteria filterCriteria){ + public double[] getSizeStatistics(FilterCriteria filterCriteria) { String subquery = "select distinct FILEPATH from CHARACTERISATIONRESULTVIEW "; if (filterCriteria != null) { subquery = filterJPA.convert(filterCriteria); @@ -108,6 +107,38 @@ public double[] getSizeStatistics(FilterCriteria filterCriteria){ return result; } + + @Override + public double[] getConflictStatistics(FilterCriteria filterCriteria) { + String subquery = "select distinct FILEPATH from CHARACTERISATIONRESULTVIEW "; + if (filterCriteria != null) { + subquery = filterJPA.convert(filterCriteria); + } + + String query = String.format( + "select count(distinct t.FILEPATH) as count " + + "from CHARACTERISATIONRESULTVIEW t " + + "join (%s) c on t.FILEPATH=c.FILEPATH " + + "where t.PROPERTY_VALUE='CONFLICT'", subquery); + + Long conflictsCount = (Long) entityManager.createNativeQuery(query).getSingleResult(); + + + String query2 = String.format( + "select count(distinct t.FILEPATH) as count " + + "from CHARACTERISATIONRESULTVIEW t " + + "join (%s) c on t.FILEPATH=c.FILEPATH ", subquery); + + Long totalCount = (Long) entityManager.createNativeQuery(query2).getSingleResult(); + + double rate = 0d; + if (totalCount != 0) { + rate = (double) conflictsCount / totalCount; + } + double[] result = new double[]{conflictsCount, rate}; + return result; + } + @Override public List getRandomSamples(FilterCriteria filterCriteria, int sampleSize) { String subquery = "select distinct FILEPATH from CHARACTERISATIONRESULTVIEW "; @@ -181,5 +212,4 @@ public List getSelectiveFeatureDistributionSamples(FilterCriteria filt } - } diff --git a/infra-rest/src/main/java/rocks/artur/endpoints/RestService.java b/infra-rest/src/main/java/rocks/artur/endpoints/RestService.java index f0ae430..268af6c 100644 --- a/infra-rest/src/main/java/rocks/artur/endpoints/RestService.java +++ b/infra-rest/src/main/java/rocks/artur/endpoints/RestService.java @@ -104,7 +104,7 @@ public List getConflictsPerObject( public Map getCollectionStatistics(@RequestParam(name = "filter", required = false) @Parameter(name = "filter", description = "Filter", example = "FORMAT=\"Portable Document Format\"") String filter) throws ParseException { CriteriaParser parser = new CriteriaParser(); FilterCriteria filterCriteria = parser.parse(filter); - Map sizeStatistics = getCollectionStatistics.getSizeStatistics(filterCriteria); + Map sizeStatistics = getCollectionStatistics.getStatistics(filterCriteria); return sizeStatistics; } diff --git a/main/src/test/java/rocks/artur/CharacterisationResultGatewayImplTest.java b/main/src/test/java/rocks/artur/CharacterisationResultGatewayImplTest.java index 9eefd1d..9cd38da 100644 --- a/main/src/test/java/rocks/artur/CharacterisationResultGatewayImplTest.java +++ b/main/src/test/java/rocks/artur/CharacterisationResultGatewayImplTest.java @@ -102,7 +102,7 @@ void getCollectionStatisticsWithoutFilterTest() throws ParseException { String typeFilter = "FORMAT=\"Portable Document Format\""; CriteriaParser parser = new CriteriaParser(); FilterCriteria parse = parser.parse(typeFilter); - Map sizeStatistics = characterisationResultGatewaySqlImpl.getSizeStatistics(null); + Map sizeStatistics = characterisationResultGatewaySqlImpl.getCollectionStatistics(null); Assert.assertEquals(10047.0, sizeStatistics.get("totalSize"), 0.1); System.out.println(sizeStatistics); } @@ -112,7 +112,7 @@ void getCollectionStatisticsWithFilterTest() throws ParseException { String typeFilter = "FORMAT=\"Portable Document Format\""; CriteriaParser parser = new CriteriaParser(); FilterCriteria parse = parser.parse(typeFilter); - Map sizeStatistics = characterisationResultGatewaySqlImpl.getSizeStatistics(parse); + Map sizeStatistics = characterisationResultGatewaySqlImpl.getCollectionStatistics(parse); Assert.assertEquals(4.0, sizeStatistics.get("totalSize"), 0.1); System.out.println(sizeStatistics); } diff --git a/web/frontend/src/scenes/PropertyValueDistribution/index.jsx b/web/frontend/src/scenes/PropertyValueDistribution/index.jsx index e3cb1ec..7bc65b2 100644 --- a/web/frontend/src/scenes/PropertyValueDistribution/index.jsx +++ b/web/frontend/src/scenes/PropertyValueDistribution/index.jsx @@ -63,7 +63,7 @@ const PropertyValueDistribution = (payload) => { }, [filter]); let filterClick = (property, event) => { - if (event.indexValue == "...others") { + if (event.indexValue == ".etc") { return; } let newCondition = null;