Search in sources :

Example 16 with ApplicationTenancy

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

the class EstatioApplicationTenancyRepositoryForProperty method findOrCreateTenancyFor.

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

Example 17 with ApplicationTenancy

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

the class ChargeImport method importData.

@Override
@Programmatic
public List<Object> importData(Object previousRow) {
    ChargeGroup chargeGroup = null;
    if (getChargeGroupReference() != null) {
        chargeGroup = findOrCreateChargeGroup(chargeGroupReference, chargeGroupName);
    }
    final ApplicationTenancy applicationTenancy = securityApplicationTenancyRepository.findByPath(atPath);
    final Applicability applicability = this.applicability != null ? Applicability.valueOf(this.applicability) : Applicability.IN_AND_OUT;
    Tax tax = null;
    if (getTaxReference() != null) {
        tax = taxRepository.findOrCreate(taxReference, taxReference, applicationTenancy);
    }
    if (getReference() == null) {
        setReference(getName());
    }
    final Charge charge = chargeRepository.upsert(getReference(), getName(), getDescription(), applicationTenancy, applicability, tax, chargeGroup);
    if (getParent() != null) {
        Charge parentCharge = chargeRepository.findByReference(getParent());
        if (parentCharge != null) {
            charge.setParent(parentCharge);
        }
    }
    if (externalReference != null) {
        charge.setExternalReference(externalReference);
    }
    if (sortOrder != null) {
        charge.setSortOrder(sortOrder);
    }
    return Lists.newArrayList(charge);
}
Also used : ChargeGroup(org.estatio.module.charge.dom.ChargeGroup) Charge(org.estatio.module.charge.dom.Charge) Tax(org.estatio.module.tax.dom.Tax) Applicability(org.estatio.module.charge.dom.Applicability) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 18 with ApplicationTenancy

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

the class IndexImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final ApplicationTenancy applicationTenancy = applicationTenancyRepository.findByPath(getAtPath());
    // Creator and implement IndexCreator, IndexBaseCreator, IndexValueCreator
    final IndexValue indexValue = indexRepository.findOrCreateIndex(applicationTenancy, indexReference, indexName).findOrCreateBase(indexBaseStartDate, indexBaseFactor).newIndexValue(startDate, value);
    return Lists.newArrayList(indexValue);
}
Also used : IndexValue(org.estatio.module.index.dom.IndexValue) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 19 with ApplicationTenancy

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

the class IndexValuesMaintenanceMenu method uploadIndexValues.

// //////////////////////////////////////
@Action(publishing = Publishing.DISABLED, semantics = SemanticsOf.IDEMPOTENT)
@MemberOrder(sequence = "2")
public List<IndexValueMaintLineItem> uploadIndexValues(@Parameter(fileAccept = ".xlsx") @ParameterLayout(named = "Excel spreadsheet") final Blob spreadsheet, final Country country) {
    final ApplicationTenancy applicationTenancy = estatioApplicationTenancyRepository.findOrCreateTenancyFor(country);
    List<IndexValueMaintLineItem> lineItems = excelService.fromExcel(spreadsheet, IndexValueMaintLineItem.class, IndexValueMaintLineItem.class.getSimpleName());
    for (IndexValueMaintLineItem lineItem : lineItems) {
        lineItem.setAtPath(applicationTenancy.getPath());
    }
    return lineItems;
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder)

Example 20 with ApplicationTenancy

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

the class IndexValueMaintLineItem method apply.

// //////////////////////////////////////
@MemberOrder(sequence = "2")
@ActionSemantics(Of.IDEMPOTENT)
@Bulk
public void apply() {
    if (bulkInteractionContext.isFirst()) {
        String error = check();
        if (error != null) {
            getContainer().raiseError(error);
            return;
        }
    }
    // only null on first pass, then populated
    ApplicationTenancy applicationTenancy = (ApplicationTenancy) scratchpad.get("applicationTenancy");
    if (applicationTenancy == null) {
        final String atPath = getAtPath();
        applicationTenancy = applicationTenancies.findTenancyByPath(atPath);
        scratchpad.put("applicationTenancy", applicationTenancy);
    }
    // only null on first pass, then populated
    Index index = (Index) scratchpad.get("index");
    if (index == null) {
        final String reference = getReference();
        index = indexRepository.newIndex(reference, reference, applicationTenancy);
        scratchpad.put("index", index);
        setIndex(index);
    }
    // only null on first pass, then populated, and only if !existingIndex
    IndexBase previousBase = (IndexBase) scratchpad.get("previousBase");
    final LocalDate baseStartDate = getBaseStartDate();
    final BigDecimal baseFactor = getBaseFactor();
    IndexBase indexBase = indexBaseRepository.findByIndexAndDate(index, baseStartDate);
    if (indexBase == null) {
        indexBase = indexBaseRepository.newIndexBase(index, previousBase, baseStartDate, baseFactor);
    }
    setIndexBase(indexBase);
    // for next time need to create
    scratchpad.put("previousBase", indexBase);
    final LocalDate valueStartDate = getValueStartDate();
    final BigDecimal value = getValue();
    IndexValue indexValue = indexValueRepository.findByIndexAndStartDate(index, valueStartDate);
    if (indexValue == null) {
        indexValue = indexValueRepository.findOrCreate(index, valueStartDate, value);
    } else {
        indexValue.setValue(value);
    }
    setIndexValue(indexValue);
    // belt-n-braces so that subsequent queries succeed...
    getContainer().flush();
}
Also used : Index(org.estatio.module.index.dom.Index) IndexBase(org.estatio.module.index.dom.IndexBase) IndexValue(org.estatio.module.index.dom.IndexValue) LocalDate(org.joda.time.LocalDate) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) BigDecimal(java.math.BigDecimal) ActionSemantics(org.apache.isis.applib.annotation.ActionSemantics) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) Bulk(org.apache.isis.applib.annotation.Bulk)

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