Search in sources :

Example 1 with ApplicationTenancyLevel

use of org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel in project estatio by estatio.

the class ChargeRepository method chargesForCountry.

@Programmatic
public List<Charge> chargesForCountry(final ApplicationTenancy countryOrLowerLevel) {
    final ApplicationTenancyLevel level = ApplicationTenancyLevel.of(countryOrLowerLevel);
    final String countryPath = level.getCountryPath();
    return chargesForCountry(countryPath);
}
Also used : ApplicationTenancyLevel(org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 2 with ApplicationTenancyLevel

use of org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel in project estatio by estatio.

the class EstatioApplicationTenancyRepositoryForProperty method findOrCreateLocalNamedTenancy.

public ApplicationTenancy findOrCreateLocalNamedTenancy(final ApplicationTenancy propertyTenancy, final String child, final String suffix) {
    ApplicationTenancyLevel propertyLevel = ApplicationTenancyLevel.of(propertyTenancy);
    ApplicationTenancyLevel localDefaultLevel = propertyLevel.child(child);
    ApplicationTenancy childTenancy = applicationTenancies.findByPath(localDefaultLevel.getPath());
    if (childTenancy == null) {
        childTenancy = applicationTenancies.newTenancy(propertyTenancy.getName() + " " + suffix, localDefaultLevel.getPath(), propertyTenancy);
    }
    return childTenancy;
}
Also used : ApplicationTenancyLevel(org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 3 with ApplicationTenancyLevel

use of org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel in project estatio by estatio.

the class ChargeRepository method chargesForCountry.

@Programmatic
public List<Charge> chargesForCountry(final String applicationTenancyPath) {
    // assert the path (must not be root)
    final String countryPath = ApplicationTenancyLevel.of(applicationTenancyPath).getCountryPath();
    final List<Charge> charges = allInstances();
    return Lists.newArrayList(Iterables.filter(charges, new Predicate<Charge>() {

        @Override
        public boolean apply(final Charge charge) {
            final ApplicationTenancyLevel chargeLevel = ApplicationTenancyLevel.of(charge);
            return chargeLevel.isRoot() || chargeLevel.isCountry() && chargeLevel.getPath().equalsIgnoreCase(countryPath);
        }
    }));
}
Also used : ApplicationTenancyLevel(org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel) Predicate(com.google.common.base.Predicate) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with ApplicationTenancyLevel

use of org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel in project estatio by estatio.

the class LeaseMenu method choices3NewLease.

public List<LeaseType> choices3NewLease(final Property property) {
    if (property == null) {
        return null;
    }
    final ApplicationTenancy propertyApplicationTenancy = property.getApplicationTenancy();
    List<LeaseType> result = Lists.newArrayList();
    for (LeaseType leaseType : leaseTypeRepository.allLeaseTypes()) {
        final ApplicationTenancyLevel propertyAppTenancyLevel = ApplicationTenancyLevel.of(propertyApplicationTenancy);
        final ApplicationTenancyLevel leaseTypeAppTenancyLevel = ApplicationTenancyLevel.of(leaseType.getApplicationTenancy());
        if (propertyAppTenancyLevel.equals(leaseTypeAppTenancyLevel) || propertyAppTenancyLevel.childOf(leaseTypeAppTenancyLevel)) {
            result.add(leaseType);
        }
    }
    return result;
}
Also used : LeaseType(org.estatio.module.lease.dom.LeaseType) ApplicationTenancyLevel(org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 5 with ApplicationTenancyLevel

use of org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel in project estatio by estatio.

the class BrandMenu method validateNewBrand.

public String validateNewBrand(final String name, final BrandCoverage coverage, final Country countryOfOrigin, final String group, final Country countryIfAny) {
    final String atPath = meService.me().getAtPath();
    final ApplicationTenancyLevel userAtPath = ApplicationTenancyLevel.of(atPath);
    if (countryIfAny == null && (userAtPath == null || !userAtPath.isRoot())) {
        return "You may only create country-specific brands";
    }
    final ApplicationTenancy applicationTenancy = estatioApplicationTenancyRepository.findOrCreateTenancyFor(countryIfAny);
    if (brandRepository.findByNameLowerCaseAndAppTenancy(name, applicationTenancy).size() > 0) {
        return String.format("Brand with name %s exists already for %s", name, applicationTenancy.getName());
    }
    return null;
}
Also used : ApplicationTenancyLevel(org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Aggregations

ApplicationTenancyLevel (org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel)5 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)2 Predicate (com.google.common.base.Predicate)1 LeaseType (org.estatio.module.lease.dom.LeaseType)1