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);
}
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;
}
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);
}
}));
}
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;
}
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;
}
Aggregations