Search in sources :

Example 1 with OperatingSystem

use of org.phoenicis.entities.OperatingSystem 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)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 EqualsBuilder (org.apache.commons.lang.builder.EqualsBuilder)1 HashCodeBuilder (org.apache.commons.lang.builder.HashCodeBuilder)1 OperatingSystem (org.phoenicis.entities.OperatingSystem)1 ApplicationDTO (org.phoenicis.repository.dto.ApplicationDTO)1 CategoryDTO (org.phoenicis.repository.dto.CategoryDTO)1 ScriptDTO (org.phoenicis.repository.dto.ScriptDTO)1 OperatingSystemFetcher (org.phoenicis.tools.system.OperatingSystemFetcher)1