Search in sources :

Example 31 with ApplicationTenancy

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);
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 32 with ApplicationTenancy

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);
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 33 with ApplicationTenancy

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;
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 34 with 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;
}
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 35 with ApplicationTenancy

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;
}
Also used : ApplicationTenancyLevel(org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Aggregations

ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)51 Programmatic (org.apache.isis.applib.annotation.Programmatic)9 Test (org.junit.Test)6 Property (org.estatio.module.asset.dom.Property)4 Lease (org.estatio.module.lease.dom.Lease)4 LeaseItem (org.estatio.module.lease.dom.LeaseItem)4 LeaseType (org.estatio.module.lease.dom.LeaseType)4 Expectations (org.jmock.Expectations)4 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)3 ApplicationTenancyLevel (org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel)3 Charge (org.estatio.module.charge.dom.Charge)3 Numerator (org.estatio.module.numerator.dom.Numerator)3 Country (org.incode.module.country.dom.impl.Country)3 Action (org.apache.isis.applib.annotation.Action)2 DomainObject (org.apache.isis.applib.annotation.DomainObject)2 Charge (org.estatio.dom.charge.Charge)2 IndexValue (org.estatio.module.index.dom.IndexValue)2 PaymentMethod (org.estatio.module.invoice.dom.PaymentMethod)2 LeaseItemStatus (org.estatio.module.lease.dom.LeaseItemStatus)2 LeaseItemType (org.estatio.module.lease.dom.LeaseItemType)2