Search in sources :

Example 1 with ApplicationTenancy

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

the class EstatioApplicationTenancyRepositoryForProperty_Test method testFindOrCreateLocalNamedTenancy_whenExists.

@Test
public void testFindOrCreateLocalNamedTenancy_whenExists() throws Exception {
    ApplicationTenancy localTenancy = estatioApplicationTenancyRepositoryForProperty.findOrCreateLocalNamedTenancy(grande, "_", "Default");
    assertThat(localTenancy).isEqualTo(grandeDefault);
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Test(org.junit.Test)

Example 2 with ApplicationTenancy

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

the class EstatioApplicationTenancyRepositoryForProperty_Test method testFindOrCreateLocalNamedTenancy_whenDoesNotExist.

@Test
public void testFindOrCreateLocalNamedTenancy_whenDoesNotExist() throws Exception {
    final ApplicationTenancy newApplicationTenancy = new ApplicationTenancy();
    context.checking(new Expectations() {

        {
            oneOf(mockApplicationTenancies).findByPath("/ITA/GRA/abc");
            will(returnValue(null));
            oneOf(mockApplicationTenancies).newTenancy("Grande (Italy) ABC", "/ITA/GRA/abc", grande);
            will(returnValue(newApplicationTenancy));
        }
    });
    ApplicationTenancy localTenancy = estatioApplicationTenancyRepositoryForProperty.findOrCreateLocalNamedTenancy(grande, "abc", "ABC");
    assertThat(localTenancy).isEqualTo(newApplicationTenancy);
}
Also used : Expectations(org.jmock.Expectations) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Test(org.junit.Test)

Example 3 with ApplicationTenancy

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

the class Api method putApplicationTenancy.

// //////////////////////////////////////
@ActionSemantics(Of.IDEMPOTENT)
public void putApplicationTenancy(@Named("path") final String path, @Named("name") final String name) {
    ApplicationTenancy applicationTenancy = applicationTenancies.findTenancyByPath(path);
    if (applicationTenancy == null) {
        final ApplicationTenancyLevel parentLevel = ApplicationTenancyLevel.of(path).parent();
        final ApplicationTenancy parentApplicationTenancy = parentLevel != null ? applicationTenancies.findTenancyByPath(parentLevel.getPath()) : null;
        applicationTenancy = applicationTenancies.newTenancy(name, path, parentApplicationTenancy);
    }
    applicationTenancy.setName(name);
    // TODO: EST-467, to remove
    getContainer().flush();
}
Also used : ApplicationTenancyLevel(org.estatio.dom.valuetypes.ApplicationTenancyLevel) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 4 with ApplicationTenancy

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

the class Api method putTax.

// //////////////////////////////////////
@ActionSemantics(Of.IDEMPOTENT)
public void putTax(@Named("atPath") final String atPath, @Named("reference") final String reference, @Named("name") final String name, @Named("description") final String description, @Named("externalReference") @Optional final String externalReference, @Named("ratePercentage") final BigDecimal percentage, @Named("rateStartDate") final LocalDate startDate, @Named("rateExternalReference") @Optional final String rateExternalReference) {
    final ApplicationTenancy applicationTenancy = applicationTenancies.findTenancyByPath(atPath);
    final Tax tax = taxes.findOrCreate(reference, name, applicationTenancy);
    tax.setExternalReference(externalReference);
    tax.setDescription(description);
    final TaxRate rate = tax.newRate(startDate, percentage);
    rate.setExternalReference(rateExternalReference);
}
Also used : TaxRate(org.estatio.tax.dom.TaxRate) Tax(org.estatio.tax.dom.Tax) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 5 with ApplicationTenancy

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

the class Api method putCharge.

// //////////////////////////////////////
@ActionSemantics(Of.IDEMPOTENT)
public void putCharge(@Named("atPath") final String atPath, @Named("reference") final String reference, @Named("name") final String name, @Named("description") @Optional final String description, @Named("taxReference") final String taxReference, @Named("sortOrder") @Optional final String sortOrder, @Named("chargeGroupReference") final String chargeGroupReference, @Named("chargeGroupName") final String chargeGroupName, @Named("externalReference") @Optional final String externalReference) {
    final ChargeGroup chargeGroup = fetchOrCreateChargeGroup(chargeGroupReference, chargeGroupName);
    final ApplicationTenancy applicationTenancy = applicationTenancies.findTenancyByPath(atPath);
    final Tax tax = taxes.findOrCreate(taxReference, taxReference, applicationTenancy);
    final Charge charge = charges.newCharge(applicationTenancy, reference, name, description, tax, chargeGroup);
    charge.setExternalReference(externalReference);
    charge.setSortOrder(sortOrder);
}
Also used : ChargeGroup(org.estatio.dom.charge.ChargeGroup) Charge(org.estatio.dom.charge.Charge) Tax(org.estatio.tax.dom.Tax) 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