companion object {
private const val serialVersionUID = -8600988577624886948L
}
}
Screen controllers will look pretty familiar for anyone who worked with CUBA before:
@UiController("petclinic_Vet.edit")
@UiDescriptor("vet-edit.xml")
@EditedEntityContainer("vetDc")
@LoadDataBeforeShow
class VetEdit : StandardEditor<Vet>() {
@Inject
private lateinit var vetService: VetService
@Subscribe("assignVisit")
private fun onAssignVisitClick(event: Button.ClickEvent) {
vetService.scheduleVisit(editedEntity, LocalDateTime.now());
}
}
And service:
interface VetService {
companion object {
const val NAME = "petclinic_VetService"
}
fun scheduleVisit(vet: Vet, visitDate: LocalDateTime): Visit
}
@Service(VetService.NAME)
class VetServiceBean : VetService {
@Inject
private lateinit var dataManager: DataManager
override fun scheduleVisit(vet: Vet, visitDate: LocalDateTime): Visit {
//Business logic for a visit scheduling
}
}
@EntityAccess(target = Customer.class,
allow = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE})
@Override
public EntityPermissionsContainer entityPermissions() {
return super.entityPermissions();
}
@EntityAttributeAccess(target = Customer.class, modify = {&quot;name&quot;, &quot;email&quot;})
@Override
public EntityAttributePermissionsContainer entityAttributePermissions() {
return super.entityAttributePermissions();
}
@ScreenAccess(allow = {&quot;application-demo&quot;, &quot;demo_Customer.browse&quot;, &quot;demo_Customer.edit&quot;})
@Override
public ScreenPermissionsContainer screenPermissions() {
return super.screenPermissions();
}
}
String hello(String input);
}
@Service(HelloService.NAME)
@Profile("dev")
public class HelloDevServiceBean implements HelloService {
@Override
public String hello(String input) {
return "Development stub: hello " + input;
}
}
@Service(HelloService.NAME)
@Profile("prod")
public class HelloProdServiceBean implements HelloService {
@Override
public String hello(String input) {
return "Production service: hello " + input;
}
}