use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.
the class Api method putPerson.
// //////////////////////////////////////
@ActionSemantics(Of.IDEMPOTENT)
public void putPerson(@Named("atPath") final String atPath, @Named("reference") final String reference, @Named("initials") @Optional final String initials, @Named("firstName") final String firstName, @Named("lastName") final String lastName, @Named("Gender") @Optional final String gender) {
final ApplicationTenancy applicationTenancy = applicationTenancies.findTenancyByPath(atPath);
Person person = (Person) parties.findPartyByReference(reference);
if (person == null) {
person = persons.newPerson(reference, initials, firstName, lastName, gender == null ? PersonGenderType.UNKNOWN : PersonGenderType.valueOf(gender), applicationTenancy);
}
person.setApplicationTenancyPath(applicationTenancy.getPath());
person.setFirstName(firstName);
person.setLastName(lastName);
}
use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.
the class EstatioApplicationTenancyRepositoryForCountry method findOrCreateTenancyFor.
// called in lots of places...
// - BrandRepository, BrandMenu
// - TaxMenu
// - OrganisationMenu, OrganisationRepository, PersonRepository,
// - IndexMenu, IndexValuesMaintenanceMenu
// - EstatioApplicationTenancyRepositoryForProperty
// - NumeratorForOrganisationBuilder
// - ProgramRepository
public ApplicationTenancy findOrCreateTenancyFor(final Country countryIfAny) {
if (countryIfAny == null) {
return findOrCreateTenancyForGlobal();
}
final String countryPath = pathFor(countryIfAny);
ApplicationTenancy countryTenancy = applicationTenancies.findByPath(countryPath);
if (countryTenancy != null) {
return countryTenancy;
}
final ApplicationTenancy rootTenancy = findOrCreateTenancyForGlobal();
return applicationTenancies.newTenancy(countryIfAny.getReference(), countryPath, rootTenancy);
}
use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.
the class EstatioApplicationTenancyRepository_Test method tenancy.
private static ApplicationTenancy tenancy(final String path, final String name) {
ApplicationTenancy applicationTenancy = new ApplicationTenancy();
applicationTenancy.setPath(path);
applicationTenancy.setName(name);
return applicationTenancy;
}
use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy 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.isisaddons.module.security.dom.tenancy.ApplicationTenancy 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