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