Skip to content

Commit

Permalink
refactor: rename StoreCriteria to ExporterCriteria
Browse files Browse the repository at this point in the history
  • Loading branch information
DropSnorz committed Aug 12, 2024
1 parent 05c45c0 commit bffb6d3
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import com.owlplug.explore.model.PackageBundle;
import com.owlplug.explore.model.RemotePackage;
import com.owlplug.explore.model.search.ExploreFilterCriteriaType;
import com.owlplug.explore.model.search.StoreFilterCriteria;
import com.owlplug.explore.model.search.ExploreFilterCriteria;
import com.owlplug.explore.services.ExploreService;
import com.owlplug.explore.ui.ExploreChipView;
import com.owlplug.explore.ui.PackageBlocViewBuilder;
Expand Down Expand Up @@ -204,7 +204,7 @@ public void initialize() {
HBox.setHgrow(exploreChipView, Priority.ALWAYS);
exploreChipViewContainer.getChildren().add(exploreChipView);

exploreChipView.getChips().addListener((ListChangeListener<StoreFilterCriteria>) change -> {
exploreChipView.getChips().addListener((ListChangeListener<ExploreFilterCriteria>) change -> {
performPackageSearch();
});

Expand Down Expand Up @@ -234,12 +234,12 @@ public void changed(ObservableValue<? extends Number> observable, Number oldValu
}

private void performPackageSearch() {
final List<StoreFilterCriteria> criteriaChipList = exploreChipView.getChips();
List<StoreFilterCriteria> criteriaList = new ArrayList<>(criteriaChipList);
final List<ExploreFilterCriteria> criteriaChipList = exploreChipView.getChips();
List<ExploreFilterCriteria> criteriaList = new ArrayList<>(criteriaChipList);

for (Entry<String, CheckBox> entry : targetFilterCheckBoxes.entrySet()) {
if (entry.getValue().isSelected()) {
criteriaList.add(new StoreFilterCriteria(entry.getKey(), ExploreFilterCriteriaType.PLATFORM));
criteriaList.add(new ExploreFilterCriteria(entry.getKey(), ExploreFilterCriteriaType.PLATFORM));
}
}

Expand All @@ -250,7 +250,7 @@ private void performPackageSearch() {
}
}
if (formats.size() > 0) {
criteriaList.add(new StoreFilterCriteria(formats, ExploreFilterCriteriaType.FORMAT_LIST));
criteriaList.add(new ExploreFilterCriteria(formats, ExploreFilterCriteriaType.FORMAT_LIST));
}

Task<Iterable<RemotePackage>> task = new Task<Iterable<RemotePackage>>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
import java.util.List;
import org.springframework.data.jpa.domain.Specification;

public class StoreCriteriaAdapter {
public class ExploreCriteriaAdapter {

public static Specification<RemotePackage> toSpecification(List<StoreFilterCriteria> criteriaList) {
public static Specification<RemotePackage> toSpecification(List<ExploreFilterCriteria> criteriaList) {

Specification<RemotePackage> spec = Specification.where(null);
for (StoreFilterCriteria criteria : criteriaList) {
for (ExploreFilterCriteria criteria : criteriaList) {
spec = spec.and(toSpecification(criteria));
}
return spec;

}

public static Specification<RemotePackage> toSpecification(StoreFilterCriteria criteria) {
public static Specification<RemotePackage> toSpecification(ExploreFilterCriteria criteria) {

if (criteria.getFilterType().equals(ExploreFilterCriteriaType.NAME)) {
return RemotePackageDAO.nameContains(String.valueOf(criteria.getValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.Objects;
import javafx.scene.image.Image;

public class StoreFilterCriteria {
public class ExploreFilterCriteria {

private Object value;
private String textValue;
Expand All @@ -34,7 +34,7 @@ public class StoreFilterCriteria {
* @param value - criteria value
* @param filterType - criteria type
*/
public StoreFilterCriteria(Object value, ExploreFilterCriteriaType filterType) {
public ExploreFilterCriteria(Object value, ExploreFilterCriteriaType filterType) {
super();
this.value = value;
this.filterType = filterType;
Expand All @@ -47,7 +47,7 @@ public StoreFilterCriteria(Object value, ExploreFilterCriteriaType filterType) {
* @param filterType - criteria type
* @param icon - criteria icon displayed
*/
public StoreFilterCriteria(Object value, ExploreFilterCriteriaType filterType, Image icon) {
public ExploreFilterCriteria(Object value, ExploreFilterCriteriaType filterType, Image icon) {
super();
this.value = value;
this.filterType = filterType;
Expand All @@ -63,7 +63,7 @@ public StoreFilterCriteria(Object value, ExploreFilterCriteriaType filterType, I
* @param textValue - custom text value overwriting original value toString()
* conversion.
*/
public StoreFilterCriteria(Object value, ExploreFilterCriteriaType filterType, Image icon, String textValue) {
public ExploreFilterCriteria(Object value, ExploreFilterCriteriaType filterType, Image icon, String textValue) {
super();
this.value = value;
this.icon = icon;
Expand Down Expand Up @@ -111,7 +111,7 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
StoreFilterCriteria criteria = (StoreFilterCriteria) o;
ExploreFilterCriteria criteria = (ExploreFilterCriteria) o;
return Objects.equals(value, criteria.getValue());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import com.owlplug.explore.model.json.RegistryModelAdapter;
import com.owlplug.explore.model.json.legacy.StoreJsonMapper;
import com.owlplug.explore.model.json.legacy.StoreModelAdapter;
import com.owlplug.explore.model.search.StoreCriteriaAdapter;
import com.owlplug.explore.model.search.StoreFilterCriteria;
import com.owlplug.explore.model.search.ExploreCriteriaAdapter;
import com.owlplug.explore.model.search.ExploreFilterCriteria;
import jakarta.annotation.PostConstruct;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -103,12 +103,12 @@ public RemoteSource getRemoteSourceByUrl(String url) {
* @param criteriaList criteria list
* @return list of store products
*/
public Iterable<RemotePackage> getRemotePackages(List<StoreFilterCriteria> criteriaList) {
public Iterable<RemotePackage> getRemotePackages(List<ExploreFilterCriteria> criteriaList) {
RuntimePlatform env = this.getApplicationDefaults().getRuntimePlatform();

Specification<RemotePackage> spec = RemotePackageDAO.sourceEnabled()
.and(RemotePackageDAO.hasPlatformTag(env.getCompatiblePlatformsTags()));
spec = spec.and(StoreCriteriaAdapter.toSpecification(criteriaList));
spec = spec.and(ExploreCriteriaAdapter.toSpecification(criteriaList));

return remotePackageDAO.findAll(spec);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.owlplug.core.components.ApplicationDefaults;
import com.owlplug.core.model.PluginType;
import com.owlplug.explore.model.search.ExploreFilterCriteriaType;
import com.owlplug.explore.model.search.StoreFilterCriteria;
import com.owlplug.explore.model.search.ExploreFilterCriteria;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
Expand All @@ -32,7 +32,7 @@
import javafx.scene.image.ImageView;
import javafx.util.StringConverter;

public class ExploreChipView extends ChipView<StoreFilterCriteria> {
public class ExploreChipView extends ChipView<ExploreFilterCriteria> {

private ApplicationDefaults applicationDefaults;
private List<String> pluginCreators;
Expand All @@ -54,81 +54,81 @@ public ExploreChipView(ApplicationDefaults applicationDefaults, List<String> plu

private void init() {

HashMap<String, StoreFilterCriteria> suggestions = new LinkedHashMap<>();
HashMap<String, ExploreFilterCriteria> suggestions = new LinkedHashMap<>();

suggestions.put("Effect", new StoreFilterCriteria(PluginType.EFFECT, ExploreFilterCriteriaType.TYPE,
suggestions.put("Effect", new ExploreFilterCriteria(PluginType.EFFECT, ExploreFilterCriteriaType.TYPE,
applicationDefaults.effectImage, "Effect"));
suggestions.put("Instrument", new StoreFilterCriteria(PluginType.INSTRUMENT, ExploreFilterCriteriaType.TYPE,
suggestions.put("Instrument", new ExploreFilterCriteria(PluginType.INSTRUMENT, ExploreFilterCriteriaType.TYPE,
applicationDefaults.instrumentImage, "Instrument"));

suggestions.put("Amp", new StoreFilterCriteria("Amp", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Amp", new ExploreFilterCriteria("Amp", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Analog",
new StoreFilterCriteria("Analog", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Analog", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Ambient",
new StoreFilterCriteria("Ambient", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Bass", new StoreFilterCriteria("Bass", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Ambient", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Bass", new ExploreFilterCriteria("Bass", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Brass",
new StoreFilterCriteria("Brass", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Brass", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Compressor",
new StoreFilterCriteria("Compressor", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Compressor", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Delay",
new StoreFilterCriteria("Delay", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Delay", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Distortion",
new StoreFilterCriteria("Distortion", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Drum", new StoreFilterCriteria("Drum", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Distortion", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Drum", new ExploreFilterCriteria("Drum", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Equalizer",
new StoreFilterCriteria("Equalizer", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Equalizer", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Filter",
new StoreFilterCriteria("Filter", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Filter", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Flanger",
new StoreFilterCriteria("Flanger", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Gate", new StoreFilterCriteria("Gate", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Flanger", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Gate", new ExploreFilterCriteria("Gate", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Guitar",
new StoreFilterCriteria("Guitar", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("LFO", new StoreFilterCriteria("LFO", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Guitar", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("LFO", new ExploreFilterCriteria("LFO", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Limiter",
new StoreFilterCriteria("Limiter", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Limiter", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Maximizer",
new StoreFilterCriteria("Maximizer", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Maximizer", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Monophonic",
new StoreFilterCriteria("Monophonic", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Monophonic", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Orchestral",
new StoreFilterCriteria("Orchestral", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Orchestral", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Organ",
new StoreFilterCriteria("Organ", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Organ", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Panner",
new StoreFilterCriteria("Panner", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Panner", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Phaser",
new StoreFilterCriteria("Phaser", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Phaser", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Piano",
new StoreFilterCriteria("Piano", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Piano", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Reverb",
new StoreFilterCriteria("Reverb", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Reverb", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Tremolo",
new StoreFilterCriteria("Tremolo", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Tube", new StoreFilterCriteria("Tube", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Tremolo", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Tube", new ExploreFilterCriteria("Tube", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Synth",
new StoreFilterCriteria("Synth", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Synth", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
suggestions.put("Vintage",
new StoreFilterCriteria("Vintage", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));
new ExploreFilterCriteria("Vintage", ExploreFilterCriteriaType.TAG, applicationDefaults.tagImage));

for (String creator : pluginCreators) {
suggestions.put(creator, new StoreFilterCriteria(creator, ExploreFilterCriteriaType.CREATOR,
suggestions.put(creator, new ExploreFilterCriteria(creator, ExploreFilterCriteriaType.CREATOR,
applicationDefaults.userImage));
}

this.getSuggestions().addAll(suggestions.values());
this.setConverter(new StringConverter<>() {
@Override
public String toString(StoreFilterCriteria object) {
public String toString(ExploreFilterCriteria object) {
return object.toString();
}

@Override
public StoreFilterCriteria fromString(String string) {
public ExploreFilterCriteria fromString(String string) {
String filter = string.trim();
StoreFilterCriteria found = suggestions.get(filter);
return found == null ? new StoreFilterCriteria(filter, ExploreFilterCriteriaType.NAME) : found;
ExploreFilterCriteria found = suggestions.get(filter);
return found == null ? new ExploreFilterCriteria(filter, ExploreFilterCriteriaType.NAME) : found;
}
});

Expand All @@ -146,7 +146,7 @@ public StoreFilterCriteria fromString(String string) {
}
});

this.getChips().addListener((ListChangeListener<StoreFilterCriteria>) change -> {
this.getChips().addListener((ListChangeListener<ExploreFilterCriteria>) change -> {
// Only display prompt text if any chips is selected
if (getChips().size() == 0) {
this.setPromptText(PROMPT_TEXT);
Expand All @@ -156,7 +156,7 @@ public StoreFilterCriteria fromString(String string) {
});

this.setSuggestionsCellFactory(param -> new ListCell<>() {
protected void updateItem(StoreFilterCriteria item, boolean empty) {
protected void updateItem(ExploreFilterCriteria item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
setText(item.toString());
Expand Down

0 comments on commit bffb6d3

Please sign in to comment.