public void importAnnotations(
@ContextParam(ContextType.TRIGGER_EVENT) Event event) {
for (AnnotationImport annotationImport : importedAnnotations) {
Book annotationImportBook = annotationImport.getBook();
String concept = annotationImport.getConcept();
Annotation annotationToCreate = null;
if (annotationImportBook instanceof PropertyBook) {
// property book
if (annotationImport.getTwoDecimalLongCodifiedAmount() >= 0) {
PropertyIncomeAnnotation propertyIncomeAnnotation = new PropertyIncomeAnnotation();
propertyIncomeAnnotation.setUpDefaults();
annotationToCreate = propertyIncomeAnnotation;
} else {
PropertyExpensesAnnotation propertyExpensesAnnotation = new PropertyExpensesAnnotation();
propertyExpensesAnnotation.setUpDefaults();
annotationToCreate = propertyExpensesAnnotation;
}
} else if (annotationImportBook instanceof StocksBook) {
// stocks book
if (annotationImport.getTwoDecimalLongCodifiedAmount() >= 0) {
StockIncomeAnnotation stockIncomeAnnotation = new StockIncomeAnnotation();
annotationToCreate = stockIncomeAnnotation;
} else {
StockExpensesAnnotation stockExpensesAnnotation = new StockExpensesAnnotation();
annotationToCreate = stockExpensesAnnotation;
}
} else {
// general books
if (annotationImport.getTwoDecimalLongCodifiedAmount() >= 0) {
IncomeAnnotation incomeAnnotation = new GeneralIncomeAnnotation();
annotationToCreate = incomeAnnotation;
} else {
ExpensesAnnotation expensesAnnotation = new GeneralExpensesAnnotation();
annotationToCreate = expensesAnnotation;
}
}
if (annotationToCreate != null) {
annotationToCreate.setConcept(concept);
annotationToCreate.setTwoDecimalLongCodifiedAmount(annotationImport
.getTwoDecimalLongCodifiedAmount());
annotationToCreate.setBook(annotationImportBook);
annotationToCreate.setDate(annotationImport.getDate());
AnnotationsBusiness.createAnnotation(annotationToCreate);
}
}
importedAnnotations.clear();
Clients.clearBusy();