Hi, forum followers
On a screen controller class there are coded following rules:
@Install(to = "ubicacionsTable.edit", subject = "enabledRule")
private boolean ubicacionsTableEditEnabledRule(){
boolean swEditar;
MovimentUbicacio movimentUbicacio = ubicacionsTable.getSingleSelected();
Ubicacio ubicacio = movimentUbicacio.getUbicacio();
//Comprovació si aquesta instància de MovimentUbicacio està gravada a la BBDD:
MovimentUbicacio movubiBD = movimentUbicacioService.tornaRegistre(movimentUbicacio.getUuid());
//Si no està gravat a la BD no cal comprovar el darrer moviment en la ubicació, perquè vol dir que estàs editant un registre del qual encara no s'ha fet el commit.
if (movubiBD == null){
swEditar = true;
} else {
swEditar = ubicacioService.esDarrerMoviment(ubicacio, movimentUbicacio);
if (!swEditar){
//La ubicació té com a darrer moviment una altra instància de MovimentUbicacio diferent a la que volem editar. No permetre l'edició
notifications.create(Notifications.NotificationType.ERROR).withCaption("No es permet editar el moviment d'aquesta ubicació perqué s'hi ha fet algun moviment posterior").show();
}
}
return swEditar;
}
@Install(to = "ubicacionsTable.remove", subject = "enabledRule")
private boolean ubicacionsTableRemoveEnabledRule(){
boolean swEditar;
MovimentUbicacio movimentUbicacio = ubicacionsTable.getSingleSelected();
Ubicacio ubicacio = movimentUbicacio.getUbicacio();
//Comprovació si aquesta instància de MovimentUbicacio està gravada a la BBDD:
MovimentUbicacio movubiBD = movimentUbicacioService.tornaRegistre(movimentUbicacio.getUuid());
//Si no està gravat a la BD no cal comprovar el darrer moviment en la ubicació, perquè vol dir que estàs editant un registre que encara no s'ha fet el commit.
if (movubiBD == null){
swEditar = true;
} else {
swEditar = ubicacioService.esDarrerMoviment(ubicacio, movimentUbicacio);
if (!swEditar) {
//La ubicació té com a darrer moviment una altra instància de MovimentUbicacio diferent a la que volem editar. No permetre l'edició
notifications.create(Notifications.NotificationType.ERROR).withCaption("No es permet eliminar el moviment d'aquesta ubicació perqué s'hi ha fet algun moviment posterior").show();
}
}
return swEditar;
}
When user presses edit button, first the “TableEditEnabledRule” is thrown and afterwards the “TableRemoveEnabledRule” is thrown too and this last rule would act when user presses delete button.
Is it an anomalous behaviour or didn’t I understand well the how does it work?
Regards,