use of org.apache.isis.applib.annotation.ActionSemantics in project estatio by estatio.
the class IndexValueMaintLineItem method apply.
// //////////////////////////////////////
@MemberOrder(sequence = "2")
@ActionSemantics(Of.IDEMPOTENT)
@Bulk
public void apply() {
if (bulkInteractionContext.isFirst()) {
String error = check();
if (error != null) {
getContainer().raiseError(error);
return;
}
}
// only null on first pass, then populated
ApplicationTenancy applicationTenancy = (ApplicationTenancy) scratchpad.get("applicationTenancy");
if (applicationTenancy == null) {
final String atPath = getAtPath();
applicationTenancy = applicationTenancies.findTenancyByPath(atPath);
scratchpad.put("applicationTenancy", applicationTenancy);
}
// only null on first pass, then populated
Index index = (Index) scratchpad.get("index");
if (index == null) {
final String reference = getReference();
index = indexRepository.newIndex(reference, reference, applicationTenancy);
scratchpad.put("index", index);
setIndex(index);
}
// only null on first pass, then populated, and only if !existingIndex
IndexBase previousBase = (IndexBase) scratchpad.get("previousBase");
final LocalDate baseStartDate = getBaseStartDate();
final BigDecimal baseFactor = getBaseFactor();
IndexBase indexBase = indexBaseRepository.findByIndexAndDate(index, baseStartDate);
if (indexBase == null) {
indexBase = indexBaseRepository.newIndexBase(index, previousBase, baseStartDate, baseFactor);
}
setIndexBase(indexBase);
// for next time need to create
scratchpad.put("previousBase", indexBase);
final LocalDate valueStartDate = getValueStartDate();
final BigDecimal value = getValue();
IndexValue indexValue = indexValueRepository.findByIndexAndStartDate(index, valueStartDate);
if (indexValue == null) {
indexValue = indexValueRepository.findOrCreate(index, valueStartDate, value);
} else {
indexValue.setValue(value);
}
setIndexValue(indexValue);
// belt-n-braces so that subsequent queries succeed...
getContainer().flush();
}
use of org.apache.isis.applib.annotation.ActionSemantics in project estatio by estatio.
the class ApiItaly method putLandRegister.
// //////////////////////////////////////
@ActionSemantics(Of.IDEMPOTENT)
public void putLandRegister(@Named("propertyReference") final String propertyReference, @Named("unitReference") final String unitReference, @Named("comuneAmministrativo") @Optional final String comuneAmministrativo, @Named("comuneCatastale") @Optional final String comuneCatastale, @Named("codiceComuneCatastale") @Optional final String codiceComuneCatastale, @Named("rendita") @Optional final BigDecimal rendita, @Named("foglio") @Optional final String foglio, @Named("particella") @Optional final String particella, @Named("subalterno") @Optional final String subalterno, @Named("categoria") @Optional final String categoria, @Named("classe") @Optional final String classe, @Named("consistenza") @Optional final String consistenza) {
Unit unit = units.findUnitByReference(unitReference);
if (unit == null) {
unit = units.findUnitByReference(unitReference.replace(" ", "+"));
}
if (unit == null) {
throw new IllegalArgumentException("Unknown unit: ".concat(unitReference));
}
LandRegister landRegister = null;
List<FixedAssetRegistration> farts = fixedAssetRegistrations.findBySubject(unit);
if (!farts.isEmpty()) {
landRegister = (LandRegister) farts.get(0);
}
if (landRegister == null) {
landRegister = (LandRegister) fixedAssetRegistrationTypes.findByTitle("LandRegister").create(getContainer());
landRegister.setSubject(unit);
landRegister.setComuneAmministrativo(comuneAmministrativo);
landRegister.setComuneCatastale(codiceComuneCatastale);
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);
persistIfNotAlready(landRegister);
}
}
Aggregations