Search in sources :

Example 1 with ApplicationDTO

use of org.phoenicis.repository.dto.ApplicationDTO in project POL-POM-5 by PlayOnLinux.

the class MergeableRepository method mergeCategories.

protected CategoryDTO mergeCategories(CategoryDTO leftCategory, CategoryDTO rightCategory) {
    final Map<String, ApplicationDTO> leftApplications = createSortedMap(leftCategory.getApplications(), ApplicationDTO::getName);
    final Map<String, ApplicationDTO> rightApplications = createSortedMap(rightCategory.getApplications(), ApplicationDTO::getName);
    final SortedMap<String, ApplicationDTO> mergedApps = new TreeMap<>(rightApplications);
    for (String applicationName : leftApplications.keySet()) {
        final ApplicationDTO application = leftApplications.get(applicationName);
        if (mergedApps.containsKey(applicationName)) {
            mergedApps.put(applicationName, mergeApplications(mergedApps.get(applicationName), application));
        } else {
            mergedApps.put(applicationName, application);
        }
    }
    final List<ApplicationDTO> applications = new ArrayList<>(mergedApps.values());
    applications.sort(ApplicationDTO.nameComparator());
    return new CategoryDTO.Builder().withApplications(applications).withType(leftCategory.getType()).withIcon(leftCategory.getIcon()).withName(leftCategory.getName()).build();
}
Also used : CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO)

Example 2 with ApplicationDTO

use of org.phoenicis.repository.dto.ApplicationDTO in project POL-POM-5 by PlayOnLinux.

the class FilterRepository method fetchInstallableApplications.

@Override
public List<CategoryDTO> fetchInstallableApplications() {
    final OperatingSystem currentOperatingSystem = operatingSystemFetcher.fetchCurrentOperationSystem();
    final List<CategoryDTO> categories = repository.fetchInstallableApplications();
    return categories.stream().map(category -> {
        final List<ApplicationDTO> applications = new ArrayList<>();
        for (ApplicationDTO application : category.getApplications()) {
            List<ScriptDTO> scripts = application.getScripts();
            if (!enforceIncompatibleOperatingSystems) {
                scripts = application.getScripts().stream().filter(script -> script.getCompatibleOperatingSystems() == null || script.getCompatibleOperatingSystems().contains(currentOperatingSystem)).collect(Collectors.toList());
            }
            if (!scripts.isEmpty()) {
                applications.add(new ApplicationDTO.Builder(application).withScripts(scripts).build());
            }
        }
        return new CategoryDTO.Builder(category).withApplications(applications).build();
    }).filter(category -> !category.getApplications().isEmpty()).collect(Collectors.toList());
}
Also used : OperatingSystem(org.phoenicis.entities.OperatingSystem) CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) List(java.util.List) OperatingSystem(org.phoenicis.entities.OperatingSystem) EqualsBuilder(org.apache.commons.lang.builder.EqualsBuilder) HashCodeBuilder(org.apache.commons.lang.builder.HashCodeBuilder) OperatingSystemFetcher(org.phoenicis.tools.system.OperatingSystemFetcher) Collectors(java.util.stream.Collectors) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) ArrayList(java.util.ArrayList) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) EqualsBuilder(org.apache.commons.lang.builder.EqualsBuilder) HashCodeBuilder(org.apache.commons.lang.builder.HashCodeBuilder) ArrayList(java.util.ArrayList)

Example 3 with ApplicationDTO

use of org.phoenicis.repository.dto.ApplicationDTO in project POL-POM-5 by PlayOnLinux.

the class ClasspathRepository method buildApplications.

private List<ApplicationDTO> buildApplications(String categoryFileName) throws IOException {
    final String categoryScanClassPath = packagePath + "/" + categoryFileName;
    Resource[] resources = resourceResolver.getResources(categoryScanClassPath + "/*");
    final List<ApplicationDTO> applicationDTOS = new ArrayList<>();
    for (Resource resource : resources) {
        final String fileName = resource.getFilename();
        if (!"icon.png".equals(fileName) && !"category.json".equals(fileName)) {
            final ApplicationDTO application = buildApplication(categoryFileName, fileName);
            if (!application.getScripts().isEmpty()) {
                applicationDTOS.add(application);
            }
        }
    }
    Collections.sort(applicationDTOS, Comparator.comparing(ApplicationDTO::getName));
    return applicationDTOS;
}
Also used : ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) Resource(org.springframework.core.io.Resource)

Example 4 with ApplicationDTO

use of org.phoenicis.repository.dto.ApplicationDTO in project POL-POM-5 by PlayOnLinux.

the class ApplicationsFeaturePanelSkin method createContent.

/**
 * {@inheritDoc}
 */
@Override
public ObjectExpression<Node> createContent() {
    /*
         * initialising the application lists by:
         * 1. sorting the applications by their name
         * 2. filtering them
         */
    final FilteredList<ApplicationDTO> filteredApplications = ConcatenatedList.create(new MappedList<>(getControl().getCategories().filtered(category -> category.getType() == CategoryDTO.CategoryType.INSTALLERS), CategoryDTO::getApplications)).sorted(Comparator.comparing(ApplicationDTO::getName)).filtered(getControl()::filterApplication);
    filteredApplications.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl()::filterApplication, getControl().searchTermProperty(), getControl().fuzzySearchRatioProperty(), getControl().operatingSystemProperty(), getControl().filterCategoryProperty(), getControl().containAllOSCompatibleApplicationsProperty(), getControl().containCommercialApplicationsProperty(), getControl().containRequiresPatchApplicationsProperty(), getControl().containTestingApplicationsProperty()));
    final ObservableList<ListWidgetElement<ApplicationDTO>> listWidgetEntries = new MappedList<>(filteredApplications, ListWidgetElement::create);
    final CombinedListWidget<ApplicationDTO> combinedListWidget = new CombinedListWidget<>(listWidgetEntries, this.selectedListWidget);
    // bind direction: controller property -> skin property
    getControl().selectedApplicationProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            combinedListWidget.select(newValue);
        } else {
            combinedListWidget.deselect();
        }
    });
    // bind direction: skin property -> controller properties
    combinedListWidget.selectedElementProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            final ApplicationDTO selectedItem = newValue.getItem();
            getControl().setSelectedApplication(selectedItem);
            getControl().setOpenedDetailsPanel(new ApplicationInformation(selectedItem));
        } else {
            getControl().setSelectedApplication(null);
            getControl().setOpenedDetailsPanel(new None());
        }
    });
    return new SimpleObjectProperty<>(combinedListWidget);
}
Also used : MappedList(org.phoenicis.javafx.collections.MappedList) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) CombinedListWidget(org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement) None(org.phoenicis.javafx.components.common.panelstates.None) ApplicationInformation(org.phoenicis.javafx.components.application.panelstates.ApplicationInformation)

Example 5 with ApplicationDTO

use of org.phoenicis.repository.dto.ApplicationDTO in project POL-POM-5 by PlayOnLinux.

the class ApplicationInformationPanelSkin method updateApplication.

/**
 * Update the content of the details panel when the to be shown application changes
 */
private void updateApplication() {
    final ApplicationDTO application = getControl().getApplication();
    if (application != null) {
        scripts.setAll(application.getScripts());
        miniatureUris.setAll(application.getMiniatures());
    }
}
Also used : ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO)

Aggregations

ApplicationDTO (org.phoenicis.repository.dto.ApplicationDTO)14 CategoryDTO (org.phoenicis.repository.dto.CategoryDTO)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 TypeDTO (org.phoenicis.repository.dto.TypeDTO)4 List (java.util.List)2 EqualsBuilder (org.apache.commons.lang.builder.EqualsBuilder)2 HashCodeBuilder (org.apache.commons.lang.builder.HashCodeBuilder)2 ContainerDTO (org.phoenicis.containers.dto.ContainerDTO)2 ScriptDTO (org.phoenicis.repository.dto.ScriptDTO)2 File (java.io.File)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1 Optional (java.util.Optional)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 ToStringBuilder (org.apache.commons.lang.builder.ToStringBuilder)1 OperatingSystem (org.phoenicis.entities.OperatingSystem)1 MappedList (org.phoenicis.javafx.collections.MappedList)1