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