Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkeil committed Sep 25, 2024
1 parent 74376b6 commit 159f6e3
Showing 1 changed file with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,11 @@ protected void setAspectDatasets() {
datasetPairs = ResourcePair.getPairsOf(datasets);
datasetTupels = ResourceTupel.getTupelsOf(datasets);
outputMetaModelByDataset = getOutputMetaModels(datasets);
correspondingResourcesByDataset = new HashMap<>();
resourcesByNonDistinctValueByDatasetByVariable = getMapOfResourcesByValueByDatasetByVariable();
resourcesByDistinctValueByDatasetByVariable = getMapOfResourcesByValueByDatasetByVariable();
resourcesByNonDistinctValueByDatasetByVariable = createMapOfResourcesByValueByDatasetByVariable();
resourcesByDistinctValueByDatasetByVariable = createMapOfResourcesByValueByDatasetByVariable();
}

protected Map<String, Map<Resource, Map<RDFNode, Set<Resource>>>> getMapOfResourcesByValueByDatasetByVariable() {
protected Map<String, Map<Resource, Map<RDFNode, Set<Resource>>>> createMapOfResourcesByValueByDatasetByVariable() {
Map<String, Map<Resource, Map<RDFNode, Set<Resource>>>> map = new HashMap<>();
for (String variable : variables) {
Map<Resource, Map<RDFNode, Set<Resource>>> resourcesByValueByDataset = new HashMap<>();
Expand Down Expand Up @@ -168,7 +167,6 @@ protected <M extends Count<ResourcePair>> void setZeroForVariablesCoveredByDatas
}

protected void loadResourcesOfAspect() {
unprocessedResourcesByDataset.clear();
for (Resource dataset : datasets) {
loadResourcesOfAspectAndDataset(dataset);
}
Expand All @@ -185,7 +183,7 @@ protected void compareValuesOfCorrespondingResources() {

protected void compareValuesOfCorrespondingResources(List<Resource> correspondingResources) {
setCorrespondingResourcesByDataset(correspondingResources);
removeCorrespondingResourcesFromUncoveredResources();
removeFromUnprocessedResources(correspondingResources);

loadNonDistinctValues();
calculateDistinctValues();
Expand All @@ -196,24 +194,22 @@ protected void compareValuesOfCorrespondingResources(List<Resource> correspondin
reportDeviationsAndOmissions();
}

protected void setCorrespondingResourcesByDataset(List<Resource> correspondingResources) {
protected void setCorrespondingResourcesByDataset(Collection<Resource> correspondingResources) {
for (Resource dataset : datasets) {
Set<Resource> correspondingResourcesOfDataset = new HashSet<>(correspondingResources);
correspondingResourcesOfDataset.retainAll(unprocessedResourcesByDataset.get(dataset));
correspondingResourcesByDataset.put(dataset,correspondingResourcesOfDataset);
}
}

protected void removeCorrespondingResourcesFromUncoveredResources() {
for (Resource dataset : correspondingResourcesByDataset.keySet()) {
Set<Resource> uncoveredResourcesOfDataset = unprocessedResourcesByDataset.get(dataset);
Set<Resource> coveredResourcesOfDataset = correspondingResourcesByDataset.get(dataset);
uncoveredResourcesOfDataset.removeAll(coveredResourcesOfDataset);
protected void removeFromUnprocessedResources(Collection<Resource> correspondingResources) {
for (Set<Resource> unprocessedResourcesOfDataset : unprocessedResourcesByDataset.values()) {
unprocessedResourcesOfDataset.removeAll(correspondingResources);
}
}

protected void loadNonDistinctValues() {
resetResourcesByNonDistinctValueByDatasetByVariable();
clearValues(resourcesByNonDistinctValueByDatasetByVariable);

Set<Resource> datasetsOfCorrespondingResources = correspondingResourcesByDataset.keySet();

Expand All @@ -223,7 +219,7 @@ protected void loadNonDistinctValues() {
}
}

protected void resetResourcesByNonDistinctValueByDatasetByVariable() {
protected void clearValues(Map<String, Map<Resource, Map<RDFNode, Set<Resource>>>> resourcesByNonDistinctValueByDatasetByVariable) {
for (Map<Resource, Map<RDFNode, Set<Resource>>> resourcesByNonDistinctValueByDataset : resourcesByNonDistinctValueByDatasetByVariable.values()) {
for (Map<RDFNode, Set<Resource>> resourcesByNonDistinctValue : resourcesByNonDistinctValueByDataset.values()) {
resourcesByNonDistinctValue.clear();
Expand Down

0 comments on commit 159f6e3

Please sign in to comment.