Search in sources :

Example 11 with ApplicationTenancy

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

the class CreateInvoiceNumerators method execute.

@Override
protected void execute(ExecutionContext ec) {
    final List<FixedAssetRoleTypeEnum> roleTypes = Arrays.asList(FixedAssetRoleTypeEnum.PROPERTY_OWNER, FixedAssetRoleTypeEnum.TENANTS_ASSOCIATION);
    for (final Property property : propertyRepository.allProperties()) {
        for (final FixedAssetRole fixedAssetRole : fixedAssetRoleRepository.findAllForProperty(property)) {
            if (roleTypes.contains(fixedAssetRole.getType())) {
                ApplicationTenancy applicationTenancy = estatioApplicationTenancyRepository.findOrCreateTenancyFor(property, fixedAssetRole.getParty());
                final Numerator numerator = estatioNumeratorRepository.createInvoiceNumberNumerator(property, PropertyOwnerBuilder.numeratorReferenceFor(property), bi(0), applicationTenancy);
                ec.addResult(this, property.getReference(), numerator);
            }
        }
    }
}
Also used : Numerator(org.estatio.module.numerator.dom.Numerator) FixedAssetRole(org.estatio.module.asset.dom.role.FixedAssetRole) FixedAssetRoleTypeEnum(org.estatio.module.asset.dom.role.FixedAssetRoleTypeEnum) Property(org.estatio.module.asset.dom.Property) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 12 with ApplicationTenancy

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

the class InvoiceNumeratorImport method importData.

@Override
public List<Object> importData(Object previousRow) {
    // find or create app tenancy (because of use wildcards)
    ApplicationTenancy applicationTenancy = securityApplicationTenancyRepository.newTenancy(atPath, atPath, securityApplicationTenancyRepository.findByPath(atPath.split("/%/")[0]));
    Property property = propertyRepository.findPropertyByReference(propertyReference);
    Numerator numerator;
    if (atPath.contains("/%/")) {
        numerator = numeratorRepository.findScopedNumeratorIncludeWildCardMatching(Constants.NumeratorName.INVOICE_NUMBER, property, applicationTenancy);
    } else {
        numerator = numeratorRepository.findNumerator(Constants.NumeratorName.INVOICE_NUMBER, property, applicationTenancy);
    }
    if (numerator == null) {
        numerator = numeratorRepository.createScopedNumerator(Constants.NumeratorName.INVOICE_NUMBER, property, formatStr, lastIncrement, applicationTenancy);
    }
    return Lists.newArrayList(numerator);
}
Also used : Numerator(org.estatio.module.numerator.dom.Numerator) Property(org.estatio.module.asset.dom.Property) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 13 with ApplicationTenancy

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

the class PropertyOwnerNumeratorBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    checkParam("property", ec, Property.class);
    checkParam("owner", ec, Party.class);
    ApplicationTenancy applicationTenancy = estatioApplicationTenancyRepository.findOrCreateTenancyFor(property, owner);
    this.object = estatioNumeratorRepository.createInvoiceNumberNumerator(property, numeratorReferenceFor(property), bi(0), applicationTenancy);
    ec.addResult(this, property.getReference(), object);
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 14 with ApplicationTenancy

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

the class OrganisationImport method importData.

@Override
public List<Object> importData(final Object previousRow) {
    final ApplicationTenancy applicationTenancy = applicationTenancyRepository.findByPath(atPath);
    Organisation org = (Organisation) partyRepository.findPartyByReference(reference);
    if (org == null) {
        try {
            if (applicationTenancy == null) {
                throw new IllegalArgumentException("atPath not found");
            }
            org = organisationRepository.newOrganisation(reference, false, name, applicationTenancy);
        } catch (Exception e) {
            LOG.error("Error importing organisation : " + reference, e);
        }
    }
    org.setApplicationTenancyPath(atPath);
    org.setName(name);
    org.setFiscalCode(fiscalCode);
    org.setVatCode(vatCode);
    if (chamberOfCommerceCode != null && !chamberOfCommerceCode.matches("[ \t]+")) {
        org.setChamberOfCommerceCode(chamberOfCommerceCode.replace(" ", ""));
    }
    return Lists.newArrayList(org);
}
Also used : Organisation(org.estatio.module.party.dom.Organisation) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 15 with ApplicationTenancy

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

the class EstatioApplicationTenancyRepositoryForProperty method findOrCreateLocalNamedTenancy.

public ApplicationTenancy findOrCreateLocalNamedTenancy(final ApplicationTenancy propertyTenancy, final String child, final String suffix) {
    ApplicationTenancyLevel propertyLevel = ApplicationTenancyLevel.of(propertyTenancy);
    ApplicationTenancyLevel localDefaultLevel = propertyLevel.child(child);
    ApplicationTenancy childTenancy = applicationTenancies.findByPath(localDefaultLevel.getPath());
    if (childTenancy == null) {
        childTenancy = applicationTenancies.newTenancy(propertyTenancy.getName() + " " + suffix, localDefaultLevel.getPath(), propertyTenancy);
    }
    return childTenancy;
}
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