Search in sources :

Example 21 with ApplicationTenancy

use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.

the class InvoiceForLease_Test method setUp.

@Before
public void setUp() throws Exception {
    numerator = new Numerator();
    numerator.setFormat("XXX-%05d");
    numerator.setLastIncrement(BigInteger.TEN);
    applicationTenancy = new ApplicationTenancy();
    applicationTenancy.setPath("/");
    context.checking(new Expectations() {

        {
            allowing(mockClockService).now();
            will(returnValue(LocalDate.now()));
        }
    });
}
Also used : Expectations(org.jmock.Expectations) Numerator(org.estatio.module.numerator.dom.Numerator) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Before(org.junit.Before)

Example 22 with ApplicationTenancy

use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.

the class EstatioApplicationTenancyRepositoryForLease method findOrCreateTenancyFor.

public ApplicationTenancy findOrCreateTenancyFor(final Property property, final Party party) {
    ApplicationTenancy propertyPartyTenancy = applicationTenancies.findByPath(pathFor(property, party));
    if (propertyPartyTenancy != null) {
        return propertyPartyTenancy;
    }
    final ApplicationTenancy propertyApplicationTenancy = estatioApplicationTenancyRepositoryForProperty.findOrCreateTenancyFor(property);
    final String tenancyName = String.format("%s/%s ", propertyApplicationTenancy.getPath(), party.getReference());
    return applicationTenancies.newTenancy(tenancyName, pathFor(property, party), propertyApplicationTenancy);
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 23 with ApplicationTenancy

use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.

the class InvoiceMenu method newInvoiceForLease.

@ActionLayout(contributed = Contributed.AS_NEITHER)
@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
@MemberOrder(sequence = "1")
public Invoice newInvoiceForLease(final Lease lease, final LocalDate dueDate, @Parameter(optionality = Optionality.OPTIONAL) final PaymentMethod paymentMethod, final Currency currency) {
    final Property propertyIfAny = lease.getProperty();
    final Party seller = lease.getPrimaryParty();
    final Party buyer = lease.getSecondaryParty();
    final ApplicationTenancy propertySellerTenancy = estatioApplicationTenancyRepositoryForLease.findOrCreateTenancyFor(propertyIfAny, seller);
    return invoiceForLeaseRepository.newInvoice(propertySellerTenancy, seller, buyer, paymentMethod == null ? lease.defaultPaymentMethod() : paymentMethod, currency, dueDate, lease, null);
}
Also used : Party(org.estatio.module.party.dom.Party) Property(org.estatio.module.asset.dom.Property) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 24 with ApplicationTenancy

use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.

the class EstatioApplicationTenancyRepositoryForCountry_Test method testFindOrCreateCountryTenancy_whenExists.

@Test
public void testFindOrCreateCountryTenancy_whenExists() throws Exception {
    // given
    Country country = new Country();
    country.setReference("ITA");
    // when
    ApplicationTenancy countryTenancy = estatioApplicationTenancyRepository.findOrCreateTenancyFor(country);
    // then
    assertThat(countryTenancy).isEqualTo(italy);
}
Also used : Country(org.incode.module.country.dom.impl.Country) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Test(org.junit.Test)

Example 25 with ApplicationTenancy

use of org.isisaddons.module.security.dom.tenancy.ApplicationTenancy in project estatio by estatio.

the class EstatioApplicationTenancyRepositoryForCountry_Test method testFindCountryTenancyFor.

@Test
public void testFindCountryTenancyFor() {
    // given
    ApplicationTenancy atGlobalLevel = new ApplicationTenancy();
    atGlobalLevel.setPath("/");
    ApplicationTenancy atGlobalLevel_ = new ApplicationTenancy();
    atGlobalLevel_.setPath("/_");
    ApplicationTenancy atCountryLevel = new ApplicationTenancy();
    atCountryLevel.setPath("/ABC");
    ApplicationTenancy atCountryLevel_ = new ApplicationTenancy();
    atCountryLevel_.setPath("/ABC/_");
    ApplicationTenancy atPropertyLevel = new ApplicationTenancy();
    atPropertyLevel.setPath("/ABC/DEF");
    atPropertyLevel.setParent(atCountryLevel);
    ApplicationTenancy atLandLordLevel = new ApplicationTenancy();
    atLandLordLevel.setPath("/ABC/DEF/GHI");
    atLandLordLevel.setParent(atPropertyLevel);
    // when, then
    assertThat(estatioApplicationTenancyRepository.findCountryTenancyFor(atGlobalLevel).getPath()).isEqualTo("/");
    assertThat(estatioApplicationTenancyRepository.findCountryTenancyFor(atGlobalLevel_).getPath()).isEqualTo("/_");
    assertThat(estatioApplicationTenancyRepository.findCountryTenancyFor(atCountryLevel).getPath()).isEqualTo("/ABC");
    assertThat(estatioApplicationTenancyRepository.findCountryTenancyFor(atCountryLevel_).getPath()).isEqualTo("/ABC/_");
    assertThat(estatioApplicationTenancyRepository.findCountryTenancyFor(atPropertyLevel).getPath()).isEqualTo("/ABC");
    assertThat(estatioApplicationTenancyRepository.findCountryTenancyFor(atLandLordLevel).getPath()).isEqualTo("/ABC");
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Test(org.junit.Test)

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