Search in sources :

Example 36 with ApplicationTenancy

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

the class TaxImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final ApplicationTenancy applicationTenancy = securityApplicationTenancyRepository.findByPath(atPath);
    final Tax tax = taxRepository.findOrCreate(reference, name, applicationTenancy);
    tax.setExternalReference(externalReference);
    tax.setDescription(description);
    final TaxRate rate = tax.newRate(rateStartDate, ratePercentage);
    rate.setExternalReference(rateExternalReference);
    return Lists.newArrayList(tax);
}
Also used : TaxRate(org.estatio.module.tax.dom.TaxRate) Tax(org.estatio.module.tax.dom.Tax) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 37 with ApplicationTenancy

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

the class PersonImport method importData.

@Override
public List<Object> importData(Object previousRow) {
    final ApplicationTenancy applicationTenancy = securityApplicationTenancyRepository.findByPath(atPath);
    Person person = (Person) partyRepository.findPartyByReference(reference);
    if (person == null) {
        person = personRepository.newPerson(reference, initials, firstName, lastName, gender == null ? PersonGenderType.UNKNOWN : PersonGenderType.valueOf(gender), applicationTenancy);
    }
    person.setApplicationTenancyPath(applicationTenancy.getPath());
    person.setFirstName(firstName);
    person.setLastName(lastName);
    return Lists.newArrayList();
}
Also used : Person(org.estatio.module.party.dom.Person) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 38 with ApplicationTenancy

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

the class OrganisationBuilder method execute.

@Override
protected void execute(ExecutionContext executionContext) {
    checkParam("atPath", executionContext, String.class);
    checkParam("reference", executionContext, String.class);
    checkParam("name", executionContext, String.class);
    defaultParam("useNumeratorForReference", executionContext, false);
    ApplicationTenancy applicationTenancy = applicationTenancies.findTenancyByPath(atPath);
    this.object = organisationRepository.newOrganisation(reference, useNumeratorForReference, name, applicationTenancy);
    executionContext.addResult(this, object.getReference(), object);
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 39 with ApplicationTenancy

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

the class ApplicationTenancyBuilder method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    checkParam("path", executionContext, String.class);
    checkParam("name", executionContext, String.class);
    ApplicationTenancy applicationTenancy = repository.findByPath(path);
    if (applicationTenancy == null) {
        final ApplicationTenancy parent = path.length() > 1 ? repository.findByPath(pathOfParent) : null;
        applicationTenancy = repository.newTenancy(name, path, parent);
    }
    executionContext.addResult(this, path, applicationTenancy);
    object = applicationTenancy;
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 40 with ApplicationTenancy

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

the class TaxonomyImport method importData.

@Override
public List<Object> importData(final Object previousRow) {
    final TaxonomyImport previousTaxonomyImport = (TaxonomyImport) previousRow;
    final List<Object> createdTaxonomiesAndCategories = Lists.newArrayList();
    if (getTaxonomyReference() == null) {
        final String previousReference = previousTaxonomyImport.getTaxonomyReference();
        if (previousReference == null) {
            throw new IllegalArgumentException("Taxonomy reference is null and previous row's taxonomy reference also null");
        }
        setTaxonomyReference(previousReference);
    }
    final Taxonomy taxonomy;
    Category taxonomyAsCategory = categoryRepository.findByReference(getTaxonomyReference());
    if (taxonomyAsCategory != null) {
        if (!(taxonomyAsCategory instanceof Taxonomy)) {
            throw new IllegalArgumentException(String.format("Ref: '%s' is a reference to a Category, not a Taxonomy", getTaxonomyReference()));
        } else {
            taxonomy = (Taxonomy) taxonomyAsCategory;
        }
    } else {
        taxonomy = categoryRepository.createTaxonomy(getTaxonomyName());
        taxonomy.setReference(getTaxonomyReference());
        taxonomy.setOrdinal(getTaxonomyOrdinal());
        createdTaxonomiesAndCategories.add(taxonomy);
    }
    if (getApplicabilityAtPath() != null) {
        final ApplicationTenancy applicationTenancy = applicationTenancyRepository.findByPath(getApplicabilityAtPath());
        if (applicationTenancy == null) {
            throw new IllegalArgumentException(String.format("No such application tenancy with atPath '%s'", getApplicabilityAtPath()));
        }
        if (getApplicabilityDomainType() != null) {
            final TranslatableString whetherApplicable = taxonomy.validateApplicable(getApplicabilityAtPath(), getApplicabilityDomainType());
            if (whetherApplicable == null) {
                taxonomy.applicable(getApplicabilityAtPath(), getApplicabilityDomainType());
                taxonomy.getAppliesTo();
            }
        }
    }
    // Get Parent category
    Optional<Category> parentCategory = Optional.empty();
    if (getParentCategoryReference() != null && getParentCategoryReference().length() > 0) {
        parentCategory = Optional.ofNullable(categoryRepository.findByTaxonomyAndReference(taxonomy, getParentCategoryReference()));
        if (!parentCategory.isPresent()) {
            throw new IllegalArgumentException(String.format("No category with reference '%s' found", getParentCategoryReference()));
        }
    }
    // 
    if (getCategoryReference() != null) {
        final Category parent = parentCategory.isPresent() ? parentCategory.get() : taxonomy;
        final Optional<Category> categoryIfAny = Optional.ofNullable(categoryRepository.findByTaxonomyAndReference(taxonomy, getCategoryReference()));
        if (!categoryIfAny.isPresent()) {
            createdTaxonomiesAndCategories.add(parent.addChild(getCategoryName(), getCategoryReference(), getCategoryOrdinal()));
        } else {
            // update existing
            final Category category = categoryIfAny.get();
            category.setName(getCategoryName());
            category.setParent(parent);
        }
    }
    return createdTaxonomiesAndCategories;
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) DomainObject(org.apache.isis.applib.annotation.DomainObject) TranslatableString(org.apache.isis.applib.services.i18n.TranslatableString) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) TranslatableString(org.apache.isis.applib.services.i18n.TranslatableString)

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