use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class LandRegisterImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
counter++;
if (counter == 1) {
System.out.println();
LOG.info("importing");
}
Unit unit = unitRepository.findUnitByReference(unitReference);
if (unit == null) {
unit = unitRepository.findUnitByReference(unitReference.replace(" ", "+"));
}
if (unit == null) {
throw new IllegalArgumentException("Unknown unit: ".concat(unitReference));
}
LandRegister landRegister = null;
List<FixedAssetRegistration> farts = fixedAssetRegistrationRepository.findBySubject(unit);
if (!farts.isEmpty()) {
landRegister = (LandRegister) farts.get(0);
}
if (landRegister == null) {
landRegister = (LandRegister) fixedAssetRegistrationTypeRepository.findByTitle("LandRegister").create(factoryService);
container.persistIfNotAlready(landRegister);
}
landRegister.setSubject(unit);
landRegister.setComuneAmministrativo(comuneAmministrativo);
landRegister.setComuneCatastale(comuneCatastale);
landRegister.setCodiceComuneCatastale(codiceComuneCatastale);
landRegister.setRendita(rendita == null ? null : rendita.setScale(2, RoundingMode.HALF_EVEN));
landRegister.setFoglio(foglio);
landRegister.setParticella(particella);
landRegister.setSubalterno(subalterno);
landRegister.setCategoria(categoria);
landRegister.setClasse(classe);
landRegister.setConsistenza(consistenza);
System.out.print(".");
return null;
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class PartyDtoFactory method newDto.
@Programmatic
public PartyDto newDto(final Party party) {
PartyDto dto = new PartyDto();
dto.setSelf(mappingHelper.oidDtoFor(party));
dto.setName(party.getName());
dto.setReference(party.getReference());
final SortedSet<CommunicationChannel> postalAddresses = communicationChannelRepository.findByOwnerAndType(party, CommunicationChannelType.POSTAL_ADDRESS);
final Optional<CommunicationChannel> postalAddressIfAny = postalAddresses.stream().filter(x -> x.isLegal()).findFirst();
if (postalAddressIfAny.isPresent()) {
dto.setLegalPostalAddress(mappingHelper.oidDtoFor(postalAddressIfAny.get()));
}
return dto;
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class GuaranteeImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
counter++;
if (counter == 1) {
System.out.println();
LOG.info("importing");
}
if (amount == null) {
amount = BigDecimal.ZERO;
}
Guarantee guarantee = guaranteeRepository.findByReference(reference);
if (guarantee == null) {
final Lease lease = fetchLease(leaseReference);
guarantee = guaranteeRepository.newGuarantee(lease, reference, name, guaranteeType, startDate, endDate, description, maximumAmount, null);
}
guarantee.setTerminationDate(terminationDate);
guarantee.setDescription(description);
guarantee.setComments(comments);
FinancialAccountTransaction transaction = financialAccountTransactionRepository.findTransaction(guarantee.getFinancialAccount(), transactionDate);
if (transaction == null && ObjectUtils.compare(amount, BigDecimal.ZERO) > 0 && guarantee.getFinancialAccount() != null) {
transaction = financialAccountTransactionRepository.newTransaction(guarantee.getFinancialAccount(), transactionDate, transactionDescription, amount);
}
// LOG.info("guarantee " + counter + " : " + guarantee.getReference() + " - " + guarantee.getLease().getReference());
System.out.print(".");
return Lists.newArrayList(guarantee);
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class ChargeImport method importData.
@Override
@Programmatic
public List<Object> importData(Object previousRow) {
ChargeGroup chargeGroup = null;
if (getChargeGroupReference() != null) {
chargeGroup = findOrCreateChargeGroup(chargeGroupReference, chargeGroupName);
}
final ApplicationTenancy applicationTenancy = securityApplicationTenancyRepository.findByPath(atPath);
final Applicability applicability = this.applicability != null ? Applicability.valueOf(this.applicability) : Applicability.IN_AND_OUT;
Tax tax = null;
if (getTaxReference() != null) {
tax = taxRepository.findOrCreate(taxReference, taxReference, applicationTenancy);
}
if (getReference() == null) {
setReference(getName());
}
final Charge charge = chargeRepository.upsert(getReference(), getName(), getDescription(), applicationTenancy, applicability, tax, chargeGroup);
if (getParent() != null) {
Charge parentCharge = chargeRepository.findByReference(getParent());
if (parentCharge != null) {
charge.setParent(parentCharge);
}
}
if (externalReference != null) {
charge.setExternalReference(externalReference);
}
if (sortOrder != null) {
charge.setSortOrder(sortOrder);
}
return Lists.newArrayList(charge);
}
use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.
the class IndexImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
final ApplicationTenancy applicationTenancy = applicationTenancyRepository.findByPath(getAtPath());
// Creator and implement IndexCreator, IndexBaseCreator, IndexValueCreator
final IndexValue indexValue = indexRepository.findOrCreateIndex(applicationTenancy, indexReference, indexName).findOrCreateBase(indexBaseStartDate, indexBaseFactor).newIndexValue(startDate, value);
return Lists.newArrayList(indexValue);
}
Aggregations