Search in sources :

Example 1 with Country

use of org.incode.module.country.dom.impl.Country in project estatio by estatio.

the class SupplierImportLine method importData.

@Override
public List<Object> importData(Object previousRow) {
    SupplierImportLine previous = (SupplierImportLine) previousRow;
    if (getSupplierName() == null && getChamberOfCommerceCode() == null) {
        setSupplierName(previous.getSupplierName());
        setChamberOfCommerceCode(previous.getChamberOfCommerceCode());
    }
    if (getCountry() == null) {
        setCountry(previous.getCountry());
    }
    final Country countryObj = countryRepository.findCountry(getCountry());
    this.message = "";
    Organisation organisation;
    organisation = findExistingOrganisation();
    if (bankAccountRepository.findByReference(getIban()).size() > 0) {
        message = message.concat(String.format("More than one iban found for %s. ", getIban()));
        // only set chamber of commerce code - do not create organisation or bank account
        setChamberOfCommerceCodeIfEmpty(organisation);
    } else {
        if (organisation == null) {
            organisation = organisationRepository.newOrganisation(null, true, getSupplierName(), countryObj);
        }
        bankAccountRepository.newBankAccount(organisation, getIban(), getBic());
        setChamberOfCommerceCodeIfEmpty(organisation);
    }
    if (message != "") {
        messageService.warnUser(message);
    }
    return Lists.newArrayList(message);
}
Also used : Organisation(org.estatio.module.party.dom.Organisation) Country(org.incode.module.country.dom.impl.Country)

Example 2 with Country

use of org.incode.module.country.dom.impl.Country in project estatio by estatio.

the class AdminDashboard_patchDatabase_IntegTest method happyCase.

@Test
public void happyCase() throws Exception {
    // given
    final AdminDashboard dashboard = administrationMenu.openAdminDashboard();
    Country country = Country_enum.GBR.findUsing(serviceRegistry);
    final Long id = factoryService.mixin(Persistable_datanucleusIdLong.class, country).prop();
    // when
    final String newName = "Great Britain";
    final String sql = String.format("UPDATE \"incodeCountry\".\"Country\" SET \"name\" = '%s' WHERE \"id\" = %d", newName, id);
    dashboard.patchDatabase(sql);
    sessionManagementService.nextSession();
    // then
    country = Country_enum.GBR.findUsing(serviceRegistry);
    Assertions.assertThat(country.getName()).isEqualTo(newName);
}
Also used : Persistable_datanucleusIdLong(org.apache.isis.core.metamodel.services.jdosupport.Persistable_datanucleusIdLong) Persistable_datanucleusIdLong(org.apache.isis.core.metamodel.services.jdosupport.Persistable_datanucleusIdLong) Country(org.incode.module.country.dom.impl.Country) AdminDashboard(org.estatio.module.application.app.AdminDashboard) Test(org.junit.Test)

Example 3 with Country

use of org.incode.module.country.dom.impl.Country in project estatio by estatio.

the class LeaseBuilderLEGACY method createLease.

protected Lease createLease(String reference, String name, String unitReference, String brand, BrandCoverage brandCoverage, String countryOfOriginRef, String sector, String activity, String landlordReference, String tenantReference, LocalDate startDate, LocalDate endDate, boolean createManagerRole, boolean createLeaseUnitAndTags, Party manager, ExecutionContext fixtureResults) {
    Unit unit = unitRepository.findUnitByReference(unitReference);
    Party landlord = findPartyByReferenceOrNameElseNull(landlordReference);
    Party tenant = findPartyByReferenceOrNameElseNull(tenantReference);
    Lease lease = leaseRepository.newLease(unit.getApplicationTenancy(), reference, name, null, startDate, null, endDate, landlord, tenant);
    fixtureResults.addResult(this, lease.getReference(), lease);
    if (createManagerRole) {
        final AgreementRole role = lease.createRole(agreementRoleTypeRepository.findByTitle(LeaseAgreementRoleTypeEnum.MANAGER.getTitle()), manager, null, null);
        fixtureResults.addResult(this, role);
    }
    if (createLeaseUnitAndTags) {
        Country countryOfOrigin = countryRepository.findCountry(countryOfOriginRef);
        Occupancy occupancy = occupancyRepository.newOccupancy(lease, unit, startDate);
        occupancy.setBrandName(brand, brandCoverage, countryOfOrigin);
        occupancy.setSectorName(sector);
        occupancy.setActivityName(activity);
        fixtureResults.addResult(this, occupancy);
    }
    if (leaseRepository.findLeaseByReference(reference) == null) {
        throw new RuntimeException("could not find lease reference='" + reference + "'");
    }
    return lease;
}
Also used : Party(org.estatio.module.party.dom.Party) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Lease(org.estatio.module.lease.dom.Lease) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Country(org.incode.module.country.dom.impl.Country) Unit(org.estatio.module.asset.dom.Unit)

Example 4 with Country

use of org.incode.module.country.dom.impl.Country in project estatio by estatio.

the class PostalAddressDtoFactory method newDto.

@Programmatic
public PostalAddressDto newDto(final PostalAddress postalAddress) {
    PostalAddressDto dto = new PostalAddressDto();
    dto.setSelf(mappingHelper.oidDtoFor(postalAddress));
    dto.setAddress1(postalAddress.getAddress1());
    dto.setAddress2(postalAddress.getAddress2());
    dto.setAddress3(postalAddress.getAddress3());
    dto.setCity(postalAddress.getCity());
    final State postalAddressState = postalAddress.getState();
    if (postalAddressState != null) {
        dto.setStateReference(postalAddressState.getReference());
        dto.setStateName(postalAddressState.getName());
    }
    final Country postalAddressCountry = postalAddress.getCountry();
    if (postalAddressCountry != null) {
        dto.setCountryReference(postalAddressCountry.getReference());
        dto.setCountryAlpha2Code(postalAddressCountry.getAlpha2Code());
        dto.setCountryName(postalAddressCountry.getName());
    }
    return dto;
}
Also used : PostalAddressDto(org.estatio.canonical.communicationchannel.v1.PostalAddressDto) State(org.incode.module.country.dom.impl.State) Country(org.incode.module.country.dom.impl.Country) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 5 with Country

use of org.incode.module.country.dom.impl.Country in project estatio by estatio.

the class OrganisationCommsBuilder method createPostalAddress.

private void createPostalAddress(final ExecutionContext ec) {
    defaultParam("legalAddress", ec, true);
    final Country country = objectFor(this.country_d, ec);
    final State state = stateRepository.findState(stateReference);
    this.postalAddress = communicationChannelRepository.newPostal(organisation, CommunicationChannelType.POSTAL_ADDRESS, address1, address2, null, postalCode, city, state, country);
    postalAddress.setLegal(legalAddress);
    transactionService.flushTransaction();
    ec.addResult(this, organisation.getReference() + "/postalAddress", postalAddress);
}
Also used : State(org.incode.module.country.dom.impl.State) Country(org.incode.module.country.dom.impl.Country)

Aggregations

Country (org.incode.module.country.dom.impl.Country)20 Test (org.junit.Test)6 EstatioApplicationTenancyRepositoryForCountry (org.estatio.module.countryapptenancy.dom.EstatioApplicationTenancyRepositoryForCountry)4 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 Party (org.estatio.module.party.dom.Party)3 State (org.incode.module.country.dom.impl.State)3 Property (org.estatio.module.asset.dom.Property)2 Lease (org.estatio.module.lease.dom.Lease)2 Organisation (org.estatio.module.party.dom.Organisation)2 Expectations (org.jmock.Expectations)2 ArrayList (java.util.ArrayList)1 ApplicationException (org.apache.isis.applib.ApplicationException)1 DomainObject (org.apache.isis.applib.annotation.DomainObject)1 Persistable_datanucleusIdLong (org.apache.isis.core.metamodel.services.jdosupport.Persistable_datanucleusIdLong)1 PostalAddressDto (org.estatio.canonical.communicationchannel.v1.PostalAddressDto)1 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)1 AgreementRoleCommunicationChannelType (org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType)1 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)1 AdminDashboard (org.estatio.module.application.app.AdminDashboard)1