// Path: app/src/main/java/com/ofbizian/semat/app/services/homepage/HomePageService.java
// @DomainService(nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY)
// public class HomePageService {
// 
//     //region > homePage (action)
// 
//     @Action(semantics = SemanticsOf.SAFE)
//     @HomePage
//     public HomePageViewModel homePage() {
//         return serviceRegistry.injectServicesInto(new HomePageViewModel());
//     }
// 
//     //endregion
// 
//     //region > injected services
// 
//     @javax.inject.Inject
//     ServiceRegistry serviceRegistry;
// 
//     //endregion
// }
// 
// Path: app/src/main/java/com/ofbizian/semat/app/services/homepage/HomePageViewModel.java
// @ViewModel
// public class HomePageViewModel {
// 
//     public TranslatableString title() {
//         return TranslatableString.tr("Home Page");
//     }
// 
//     @org.apache.isis.applib.annotation.HomePage
//     public List<Project> getProjects() {
//         return wrapperFactory.wrap(repository).listAll();
//     }
// 
//     @javax.inject.Inject
//     ProjectRepository repository;
// 
//     @javax.inject.Inject
//     WrapperFactory wrapperFactory;
// }


import java.util.List;
import com.ofbizian.semat.app.services.homepage.HomePageService;
import com.ofbizian.semat.app.services.homepage.HomePageViewModel;
import org.apache.isis.applib.AbstractService;
import org.apache.isis.applib.annotation.Action;
import org.apache.isis.applib.annotation.ActionLayout;
import org.apache.isis.applib.annotation.DomainService;
import org.apache.isis.applib.annotation.DomainServiceLayout;
import org.apache.isis.applib.annotation.NatureOfService;
import org.apache.isis.applib.annotation.SemanticsOf;
import org.isisaddons.module.security.app.user.MeService;
import org.isisaddons.module.security.dom.tenancy.ApplicationTenancy;
import org.isisaddons.module.security.dom.tenancy.ApplicationTenancyRepository;
import org.isisaddons.module.security.dom.user.ApplicationUser;
    )
    public HomePageViewModel switchTenancy(final ApplicationTenancy applicationTenancy) {
        final ApplicationUser applicationUser = meService.me();
        applicationUser.updateAtPath(applicationTenancy.getPath());
        return homePageService.homePage();
    }

    public boolean hideSwitchTenancy() {
        final ApplicationUser applicationUser = meService.me();
        return !"admin".equals(applicationUser.getName());
    }

    public List<ApplicationTenancy> choices0SwitchTenancy() {
        return applicationTenancyRepository.allTenancies();
    }

    public ApplicationTenancy default0SwitchTenancy() {
        final ApplicationUser applicationUser = meService.me();
        return applicationTenancyRepository.findByPath(applicationUser.getAtPath());
    }
    //endregion

    //region > injected services
    @javax.inject.Inject
    private MeService meService;

    @javax.inject.Inject
    private ApplicationTenancyRepository applicationTenancyRepository;

    @javax.inject.Inject
// Path: app/src/main/java/com/ofbizian/semat/app/services/homepage/HomePageService.java
// @DomainService(nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY)
// public class HomePageService {
// 
//     //region > homePage (action)
// 
//     @Action(semantics = SemanticsOf.SAFE)
//     @HomePage
//     public HomePageViewModel homePage() {
//         return serviceRegistry.injectServicesInto(new HomePageViewModel());
//     }
// 
//     //endregion
// 
//     //region > injected services
// 
//     @javax.inject.Inject
//     ServiceRegistry serviceRegistry;
// 
//     //endregion
// }
// 
// Path: app/src/main/java/com/ofbizian/semat/app/services/homepage/HomePageViewModel.java
// @ViewModel
// public class HomePageViewModel {
// 
//     public TranslatableString title() {
//         return TranslatableString.tr("Home Page");
//     }
// 
//     @org.apache.isis.applib.annotation.HomePage
//     public List<Project> getProjects() {
//         return wrapperFactory.wrap(repository).listAll();
//     }
// 
//     @javax.inject.Inject
//     ProjectRepository repository;
// 
//     @javax.inject.Inject
//     WrapperFactory wrapperFactory;
// }


// Path: app/src/main/java/com/ofbizian/semat/app/services/tenancyevaluator/TenancySwitcher.java
import java.util.List;
import com.ofbizian.semat.app.services.homepage.HomePageService;
import com.ofbizian.semat.app.services.homepage.HomePageViewModel;
import org.apache.isis.applib.AbstractService;
import org.apache.isis.applib.annotation.Action;
import org.apache.isis.applib.annotation.ActionLayout;
import org.apache.isis.applib.annotation.DomainService;
import org.apache.isis.applib.annotation.DomainServiceLayout;
import org.apache.isis.applib.annotation.NatureOfService;
import org.apache.isis.applib.annotation.SemanticsOf;
import org.isisaddons.module.security.app.user.MeService;
import org.isisaddons.module.security.dom.tenancy.ApplicationTenancy;
import org.isisaddons.module.security.dom.tenancy.ApplicationTenancyRepository;
import org.isisaddons.module.security.dom.user.ApplicationUser;

    )
    public HomePageViewModel switchTenancy(final ApplicationTenancy applicationTenancy) {
        final ApplicationUser applicationUser = meService.me();
        applicationUser.updateAtPath(applicationTenancy.getPath());
        return homePageService.homePage();
    }

    public boolean hideSwitchTenancy() {
        final ApplicationUser applicationUser = meService.me();
        return !"admin".equals(applicationUser.getName());
    }

    public List<ApplicationTenancy> choices0SwitchTenancy() {
        return applicationTenancyRepository.allTenancies();
    }

    public ApplicationTenancy default0SwitchTenancy() {
        final ApplicationUser applicationUser = meService.me();
        return applicationTenancyRepository.findByPath(applicationUser.getAtPath());
    }
    //endregion

    //region > injected services
    @javax.inject.Inject
    private MeService meService;

    @javax.inject.Inject
    private ApplicationTenancyRepository applicationTenancyRepository;

    @javax.inject.Inject
    private HomePageService homePageService;