Search in sources :

Example 16 with Country

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

the class PropertyImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final Party owner = partyRepository.findPartyByReference(ownerReference);
    final Country country = countryRepository.findCountry(countryCode);
    final ApplicationTenancy appTenancy = applicationTenancyRepository.findByPath(atPath);
    Property property = propertyRepository.findPropertyByReference(reference);
    if (property == null) {
        property = propertyRepository.newProperty(reference, name, PropertyType.valueOf(type), city, country, acquireDate);
    }
    property.setName(name);
    property.setFullName(fullName);
    property.setCountry(country);
    property.setCity(city);
    property.setType(PropertyType.valueOf(type));
    property.setAcquireDate(acquireDate);
    property.setDisposalDate(disposalDate);
    property.setOpeningDate(openingDate);
    property.setExternalReference(externalReference);
    property.addRoleIfDoesNotExist(owner, FixedAssetRoleTypeEnum.PROPERTY_OWNER, null, null);
    property.setParkingSpaces(parkingSpaces);
    property.setArea(grossLettableArea);
    property.setDisplayOrder(displayOrder);
    return Lists.newArrayList(property);
}
Also used : Party(org.estatio.module.party.dom.Party) Country(org.incode.module.country.dom.impl.Country) Property(org.estatio.module.asset.dom.Property) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 17 with Country

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

the class CommunicationChannelImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    List<Object> results = new ArrayList<>();
    // Party
    final Party party = fetchParty(partyReference);
    if (party == null)
        throw new ApplicationException(String.format("Party with reference [%s] not found", partyReference));
    // Address
    if (address1 != null || address2 != null || address3 != null) {
        final Country country = countryRepository.findCountry(countryCode);
        PostalAddress comm = (PostalAddress) postalAddressRepository.findByAddress(party, address1, address2, address3, postalCode, city, country);
        if (comm == null) {
            comm = communicationChannelRepository.newPostal(party, CommunicationChannelType.POSTAL_ADDRESS, address1, address2, address3, postalCode, city, stateRepository.findState(stateCode), countryRepository.findCountry(countryCode));
        }
        if (legal != null && legal) {
            comm.setLegal(true);
        }
        // attach to lease
        if (leaseReference != null) {
            Lease lease = fetchLease(leaseReference);
            if (lease != null && addressType != null) {
                final AgreementRoleType art = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.TENANT);
                final AgreementRoleCommunicationChannelType arcct = agreementRoleCommunicationChannelTypeRepository.findByTitle(addressType);
                lease.findRoleWithType(art, lease.getStartDate()).addCommunicationChannel(arcct, comm, lease.getStartDate());
            }
        }
    }
    // Phone
    if (phoneNumber != null) {
        CommunicationChannel comm = phoneOrFaxNumberRepository.findByPhoneOrFaxNumber(party, phoneNumber);
        if (comm == null) {
            comm = communicationChannelRepository.newPhoneOrFax(party, CommunicationChannelType.PHONE_NUMBER, phoneNumber);
            comm.setReference(leaseReference);
        }
    }
    // Fax
    if (faxNumber != null) {
        CommunicationChannel comm = phoneOrFaxNumberRepository.findByPhoneOrFaxNumber(party, faxNumber);
        if (comm == null) {
            comm = communicationChannelRepository.newPhoneOrFax(party, CommunicationChannelType.FAX_NUMBER, faxNumber);
            comm.setReference(leaseReference);
        }
    }
    // Email
    if (emailAddress != null) {
        CommunicationChannel comm = emailAddressRepository.findByEmailAddress(party, emailAddress);
        if (comm == null) {
            comm = communicationChannelRepository.newEmail(party, CommunicationChannelType.EMAIL_ADDRESS, emailAddress);
            comm.setReference(leaseReference);
        }
    }
    return results;
}
Also used : PostalAddress(org.incode.module.communications.dom.impl.commchannel.PostalAddress) Party(org.estatio.module.party.dom.Party) ApplicationException(org.apache.isis.applib.ApplicationException) AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) Lease(org.estatio.module.lease.dom.Lease) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) ArrayList(java.util.ArrayList) Country(org.incode.module.country.dom.impl.Country) DomainObject(org.apache.isis.applib.annotation.DomainObject) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 18 with Country

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

the class StatesRefData method execute.

@Override
protected void execute(ExecutionContext executionContext) {
    Country countryGBR = countryRepository.findCountry(GBR);
    Country countryNED = countryRepository.findCountry(NLD);
    Country countryITA = countryRepository.findCountry(ITA);
    Country countryFRA = countryRepository.findCountry(FRA);
    Country countrySWE = countryRepository.findCountry(SWE);
    createState(countryNED, "-DRN", "Drenthe", executionContext);
    createState(countryNED, "-FLE", "Flevoland", executionContext);
    createState(countryNED, "-FRI", "Friesland", executionContext);
    createState(countryNED, "-GEL", "Gelderland", executionContext);
    createState(countryNED, "-GRO", "Groningen", executionContext);
    createState(countryNED, "-LIM", "Limburg", executionContext);
    createState(countryNED, "-NBT", "Noord-Brabant", executionContext);
    createState(countryNED, "-NOH", "Noord-Holland", executionContext);
    createState(countryNED, "-OIJ", "Overijssel", executionContext);
    createState(countryNED, "-UTR", "Utrecht", executionContext);
    createState(countryNED, "-ZEL", "Zeeland", executionContext);
    createState(countryNED, "-ZUH", "Zuid-Holland", executionContext);
    createState(countryGBR, "-BED", "Bedfordshire", executionContext);
    createState(countryGBR, "-BEK", "Berkshire", executionContext);
    createState(countryGBR, "-BUK", "Buckinghamshire", executionContext);
    createState(countryGBR, "-CMB", "Cambridgeshire", executionContext);
    createState(countryGBR, "-CHE", "Cheshire", executionContext);
    createState(countryGBR, "-COR", "Cornwall", executionContext);
    createState(countryGBR, "-DBY", "Derbyshire", executionContext);
    createState(countryGBR, "-DEV", "Devon", executionContext);
    createState(countryGBR, "-DOR", "Dorset", executionContext);
    createState(countryGBR, "-DUR", "Durham", executionContext);
    createState(countryGBR, "-ESX", "Essex", executionContext);
    createState(countryGBR, "-GLO", "Gloucestershire", executionContext);
    createState(countryGBR, "-HAN", "Hampshire", executionContext);
    createState(countryGBR, "-KNT", "Kent", executionContext);
    createState(countryGBR, "-LAN", "Lancashire", executionContext);
    createState(countryGBR, "-LEI", "Leicerstershire", executionContext);
    createState(countryGBR, "-LIN", "Lincolnshire", executionContext);
    createState(countryGBR, "-NFK", "Norfolk", executionContext);
    createState(countryGBR, "-NTP", "Northamptonshire", executionContext);
    createState(countryGBR, "-NTB", "Northumberland", executionContext);
    createState(countryGBR, "-OXF", "Oxfordshire", executionContext);
    createState(countryGBR, "-RUT", "Rutland", executionContext);
    createState(countryGBR, "-SHR", "Shropshire", executionContext);
    createState(countryGBR, "-SOM", "Somerset", executionContext);
    createState(countryGBR, "-STA", "Staffordshire", executionContext);
    createState(countryGBR, "-SUF", "Suffolk", executionContext);
    createState(countryGBR, "-WAR", "Warwickshire", executionContext);
    createState(countryGBR, "-WIL", "Wiltshire", executionContext);
    createState(countryGBR, "-WOR", "Worcerstershire", executionContext);
}
Also used : Country(org.incode.module.country.dom.impl.Country)

Example 19 with Country

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

the class EstatioApplicationTenancyRepositoryForCountry_Test method testFindOrCreateCountryTenancy_whenDoesNotExist.

@Test
public void testFindOrCreateCountryTenancy_whenDoesNotExist() throws Exception {
    // given
    final Country country = new Country("GBR", "UK", "United Kingdom");
    // expect
    final ApplicationTenancy newlyCreatedTenancy = new ApplicationTenancy();
    context.checking(new Expectations() {

        {
            oneOf(mockApplicationTenancies).newTenancy("GBR", "/GBR", global);
            will(returnValue(newlyCreatedTenancy));
        }
    });
    // when
    ApplicationTenancy countryTenancy = estatioApplicationTenancyRepository.findOrCreateTenancyFor(country);
    // then
    assertThat(countryTenancy).isEqualTo(newlyCreatedTenancy);
}
Also used : Expectations(org.jmock.Expectations) Country(org.incode.module.country.dom.impl.Country) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Test(org.junit.Test)

Example 20 with Country

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

the class EstatioApplicationTenancyRepositoryForCountry_Test method country.

private static Country country(final String reference) {
    Country country = new Country();
    country.setReference(reference);
    return country;
}
Also used : 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