Skip to content

Commit

Permalink
Users can create and analyze datasets. (#12)
Browse files Browse the repository at this point in the history
* Add dropdown component

* adding ui components

* adding datasetName to API

* adding datasetName to API

* adding datasetName to API

* adding datasetName to API

* adding datasets to UI

* Add dropdown component

* Add dropdown component

* Improve Dataset selection

---------

Co-authored-by: artur <[email protected]>
Co-authored-by: artur <[email protected]>
  • Loading branch information
3 people authored Jul 15, 2024
1 parent ff72ed3 commit e196165
Show file tree
Hide file tree
Showing 38 changed files with 550 additions and 291 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/rocks/artur/api/AnalyzePersistFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
*/
public interface AnalyzePersistFile {

Long uploadCharacterisationResults(ByteFile file);
Long uploadCharacterisationResults(ByteFile file, String datasetName);

Long uploadCharacterisationResults(List<ByteFile> files);
Long uploadCharacterisationResults(List<ByteFile> files, String datasetName);

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
import java.util.Map;

public interface GetCollectionStatistics {
Map<String, Double> getStatistics(FilterCriteria filterCriteria);
Map<String, Double> getStatistics(FilterCriteria filterCriteria, String datasetName);

}
7 changes: 7 additions & 0 deletions core/src/main/java/rocks/artur/api/GetDatasetInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package rocks.artur.api;

import java.util.List;

public interface GetDatasetInfo {
List<String> listDatasets();
}
6 changes: 3 additions & 3 deletions core/src/main/java/rocks/artur/api/GetObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* This interface enables getting characterisation results.
*/
public interface GetObjects {
List<PropertiesPerObjectStatistic> getObjects(FilterCriteria filterCriteria);
Iterable<CharacterisationResult> getObject(String filePath);
List<PropertiesPerObjectStatistic> getObjects(FilterCriteria filterCriteria, String datasetName);
Iterable<CharacterisationResult> getObject(String filePath, String datasetName);

List<CharacterisationResult> getConflictsFromObject(String filePath);
List<CharacterisationResult> getConflictsFromObject(String filePath, String datasetName);
}
4 changes: 2 additions & 2 deletions core/src/main/java/rocks/artur/api/GetProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
* This interface enables getting a property distribution.
*/
public interface GetProperties {
List<PropertyStatistic> getProperties();
List<PropertyStatistic> getProperties(FilterCriteria filter);
List<PropertyStatistic> getProperties(String datasetName);
List<PropertyStatistic> getProperties(FilterCriteria filter, String datasetName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
* This interface enables getting a property value distribution given a property name.
*/
public interface GetPropertyValueDistribution {
List<PropertyValueStatistic> getPropertyValueDistribution(Property propertyName, FilterCriteria<CharacterisationResult> filterCriteria);
List<PropertyValueStatistic> getPropertyValueDistribution(Property propertyName, FilterCriteria<CharacterisationResult> filterCriteria, String datasetName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
* This interface enables getting a property value distribution given a filter.
*/
public interface GetPropertyValueDistributionWithFilter {
List<PropertyValueStatistic> getPropertyValueDistributionWithFilter(String propertyName, String filter);
List<PropertyValueStatistic> getPropertyValueDistributionWithFilter(String propertyName, String filter, String datasetName);
}
4 changes: 2 additions & 2 deletions core/src/main/java/rocks/artur/api/GetSamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface GetSamples {

void setProperties(List<Property> properties);

Iterable<String> getObjects(FilterCriteria filterCriteria);
Iterable<String> getObjects(FilterCriteria filterCriteria, String datasetName);

List<String[]> getSamplingInfo(FilterCriteria filterCriteria);
List<String[]> getSamplingInfo(FilterCriteria filterCriteria, String datasetName);
}
2 changes: 1 addition & 1 deletion core/src/main/java/rocks/artur/api/GetSources.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
* This interface enables getting a property distribution.
*/
public interface GetSources {
List<String> getSources();
List<String> getSources(String datasetName);
}
2 changes: 1 addition & 1 deletion core/src/main/java/rocks/artur/api/ResolveConflicts.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package rocks.artur.api;

public interface ResolveConflicts {
void run();
void run(String datasetName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ public AnalyzePersistFileImpl(CharacterisationResultProducer characterisationRes
}

@Override
public Long uploadCharacterisationResults(ByteFile file) {
public Long uploadCharacterisationResults(ByteFile file, String datasetName) {
List<CharacterisationResult> characterisationResults = characterisationResultProducer.processFile(file);
characterisationResultGateway.addCharacterisationResults(characterisationResults);
characterisationResultGateway.addCharacterisationResults(characterisationResults, datasetName);
return Long.valueOf(characterisationResults.size());
}

@Override
public Long uploadCharacterisationResults(List<ByteFile> files) {
public Long uploadCharacterisationResults(List<ByteFile> files, String datasetName) {
List<CharacterisationResult> characterisationResults = new ArrayList<>();
files.stream().forEach(file -> {
List<CharacterisationResult> tmp = characterisationResultProducer.processFile(file);
characterisationResults.addAll(tmp);
});
characterisationResultGateway.addCharacterisationResults(characterisationResults);
characterisationResultGateway.addCharacterisationResults(characterisationResults, datasetName);
return Long.valueOf(characterisationResults.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,41 @@ public CRH_ResolveConflictsImpl(CharacterisationResultGateway characterisationRe
}


public void run() {
init();
public void run(String datasetName) {
init(datasetName);
System.out.println(sourceWeights);
//System.out.println("sum of weights: " + sourceWeights.values().stream().reduce(0d, Double::sum));
updateTruth();
updateTruth(datasetName);
System.out.println("sum of weights: " + sourceWeights.values().stream().reduce(0d, Double::sum));
//System.out.println(truth);
for (int i = 0; i < 3; i++) {
updateWeights();
updateWeights(datasetName);
System.out.println(sourceWeights);
System.out.println("sum of weights: " + sourceWeights.values().stream().reduce(0d, Double::sum));
updateTruth();
updateTruth(datasetName);
//System.out.println(truth);
}

resolveConflicts();
resolveConflicts(datasetName);
}

private void resolveConflicts() {
private void resolveConflicts(String datasetName) {
truth.entrySet().stream().forEach( entry -> {
Entry key = entry.getKey();
String value = entry.getValue();

List<CharacterisationResult> characterisationResultsByEntry = characterisationResultGateway.getCharacterisationResultsByEntry(key);
List<CharacterisationResult> characterisationResultsByEntry = characterisationResultGateway.getCharacterisationResultsByEntry(key, datasetName);
for (CharacterisationResult characterisationResult : characterisationResultsByEntry) {
if (!characterisationResult.getValue().equals(value)) {
characterisationResultGateway.delete(characterisationResult);
characterisationResultGateway.delete(characterisationResult, datasetName);
}
}


});
}

private void updateWeights() {
private void updateWeights(String datasetName) {
Map<String, Double> score = sources.stream().collect(Collectors.toMap(
Function.identity(),
s -> 0.0));
Expand All @@ -66,10 +66,10 @@ private void updateWeights() {
s -> 0.0));


List<Entry> entries = characterisationResultGateway.getEntries();
List<Entry> entries = characterisationResultGateway.getEntries(datasetName);

for (Entry entry : entries) {
List<CharacterisationResult> characterisationResults = characterisationResultGateway.getCharacterisationResultsByEntry(entry);
List<CharacterisationResult> characterisationResults = characterisationResultGateway.getCharacterisationResultsByEntry(entry, datasetName);

for (CharacterisationResult characterisationResult : characterisationResults) {

Expand Down Expand Up @@ -112,10 +112,10 @@ private void updateWeights() {
}
}

private void updateTruth() {
List<Entry> entries = characterisationResultGateway.getEntries();
private void updateTruth(String datasetName) {
List<Entry> entries = characterisationResultGateway.getEntries(datasetName);
for (Entry entry : entries) {
List<CharacterisationResult> characterisationResults = characterisationResultGateway.getCharacterisationResultsByEntry(entry);
List<CharacterisationResult> characterisationResults = characterisationResultGateway.getCharacterisationResultsByEntry(entry, datasetName);

if (characterisationResults.size() > 0) {
CharacterisationResult firstResult = characterisationResults.get(0);
Expand All @@ -140,9 +140,9 @@ private void updateTruth() {
Map<String, Double> sourceWeights;
Map<Entry, String> truth;

void init() {
void init(String datasetName) {

sources = characterisationResultGateway.getSources();
sources = characterisationResultGateway.getSources(datasetName);
sourceWeights = sources.stream().collect(Collectors.toMap(
Function.identity(),
s -> 1.0 / sources.size()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public GetCollectionStatisticsImpl(CharacterisationResultGateway characterisatio
}

@Override
public Map<String, Double> getStatistics(FilterCriteria filterCriteria) {
Map<String, Double> sizeStatistics = characterisationResultGateway.getCollectionStatistics(filterCriteria);
public Map<String, Double> getStatistics(FilterCriteria filterCriteria, String datasetName) {
Map<String, Double> sizeStatistics = characterisationResultGateway.getCollectionStatistics(filterCriteria, datasetName);
return sizeStatistics;
}

Expand Down
19 changes: 19 additions & 0 deletions core/src/main/java/rocks/artur/api_impl/GetDatasetInfoImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package rocks.artur.api_impl;

import rocks.artur.api.GetDatasetInfo;
import rocks.artur.domain.CharacterisationResultGateway;

import java.util.List;

public class GetDatasetInfoImpl implements GetDatasetInfo {
private CharacterisationResultGateway characterisationResultGateway;

public GetDatasetInfoImpl(CharacterisationResultGateway characterisationResultGateway) {
this.characterisationResultGateway = characterisationResultGateway;
}

@Override
public List<String> listDatasets() {
return this.characterisationResultGateway.listDatasets();
}
}
12 changes: 6 additions & 6 deletions core/src/main/java/rocks/artur/api_impl/GetObjectsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ public GetObjectsImpl(CharacterisationResultGateway characterisationResultGatewa
}

@Override
public List<PropertiesPerObjectStatistic> getObjects(FilterCriteria filterCriteria) {
List<PropertiesPerObjectStatistic> objects = characterisationResultGateway.getObjects(filterCriteria);
public List<PropertiesPerObjectStatistic> getObjects(FilterCriteria filterCriteria, String datasetName) {
List<PropertiesPerObjectStatistic> objects = characterisationResultGateway.getObjects(filterCriteria, datasetName);
return objects;
}

@Override
public Iterable<CharacterisationResult> getObject(String filePath) {
Iterable<CharacterisationResult> characterisationResultsByFilepath = characterisationResultGateway.getCharacterisationResultsByFilepath(filePath);
public Iterable<CharacterisationResult> getObject(String filePath, String datasetName) {
Iterable<CharacterisationResult> characterisationResultsByFilepath = characterisationResultGateway.getCharacterisationResultsByFilepath(filePath, datasetName);
return characterisationResultsByFilepath;
}

@Override
public List<CharacterisationResult> getConflictsFromObject(String filePath) {
List<CharacterisationResult> characterisationResultsByFilepath = characterisationResultGateway.getConflictsByFilepath(filePath);
public List<CharacterisationResult> getConflictsFromObject(String filePath, String datasetName) {
List<CharacterisationResult> characterisationResultsByFilepath = characterisationResultGateway.getConflictsByFilepath(filePath, datasetName);
return characterisationResultsByFilepath;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public GetPropertiesImpl(CharacterisationResultGateway characterisationResultGat
}

@Override
public List<PropertyStatistic> getProperties() {
List<PropertyStatistic> propertyDistribution = characterisationResultGateway.getPropertyDistribution(null);
public List<PropertyStatistic> getProperties(String datasetName) {
List<PropertyStatistic> propertyDistribution = characterisationResultGateway.getPropertyDistribution(null, datasetName);
return propertyDistribution;
}

@Override
public List<PropertyStatistic> getProperties(FilterCriteria filter) {
List<PropertyStatistic> propertyDistribution = characterisationResultGateway.getPropertyDistribution(filter);
public List<PropertyStatistic> getProperties(FilterCriteria filter, String datasetName) {
List<PropertyStatistic> propertyDistribution = characterisationResultGateway.getPropertyDistribution(filter, datasetName);
return propertyDistribution;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public GetPropertyValueDistributionImpl(CharacterisationResultGateway characteri


@Override
public List<PropertyValueStatistic> getPropertyValueDistribution(Property property, FilterCriteria<CharacterisationResult> filterCriteria) {
List<PropertyValueStatistic> valueDistributionByProperty = characterisationResultGateway.getPropertyValueDistribution(property, filterCriteria);
public List<PropertyValueStatistic> getPropertyValueDistribution(Property property, FilterCriteria<CharacterisationResult> filterCriteria, String datasetName) {
List<PropertyValueStatistic> valueDistributionByProperty = characterisationResultGateway.getPropertyValueDistribution(property, filterCriteria, datasetName);
return valueDistributionByProperty;
}
}
8 changes: 4 additions & 4 deletions core/src/main/java/rocks/artur/api_impl/GetSamplesImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public void setProperties(List<Property> properties) {
}

@Override
public List<String> getObjects(FilterCriteria filterCriteria) {
List<String[]> samplingResults = characterisationResultGateway.getSamples(filterCriteria, algorithm, properties);
public List<String> getObjects(FilterCriteria filterCriteria, String datasetName) {
List<String[]> samplingResults = characterisationResultGateway.getSamples(filterCriteria, algorithm, properties, datasetName);
List<String> results = new ArrayList<>();
switch (algorithm) {

Expand All @@ -50,8 +50,8 @@ public List<String> getObjects(FilterCriteria filterCriteria) {
}

@Override
public List<String[]> getSamplingInfo(FilterCriteria filterCriteria) {
List<String[]> samplingResults = characterisationResultGateway.getSamples(filterCriteria, algorithm, properties);
public List<String[]> getSamplingInfo(FilterCriteria filterCriteria, String datasetName) {
List<String[]> samplingResults = characterisationResultGateway.getSamples(filterCriteria, algorithm, properties, datasetName);

return samplingResults;
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/rocks/artur/api_impl/GetSourcesImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public GetSourcesImpl(CharacterisationResultGateway characterisationResultGatewa
}

@Override
public List<String> getSources() {
List<String> sources = characterisationResultGateway.getSources();
public List<String> getSources(String datasetName) {
List<String> sources = characterisationResultGateway.getSources(datasetName);
return sources;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public Native_ResolveConflictsImpl(CharacterisationResultGateway characterisatio
this.characterisationResultGateway = characterisationResultGateway;
}
@Override
public void run() {
characterisationResultGateway.resolveConflictsNative();
public void run(String datasetName) {
characterisationResultGateway.resolveConflictsNative(datasetName);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package rocks.artur.api_impl.filter;

import rocks.artur.domain.ValueType;

public enum FilterOperation {
LESS("<"), LESS_OR_EQUAL ("<="),
Expand Down
Loading

0 comments on commit e196165

Please sign in to comment.