Dos and Don'ts
- 1
Service
per use-case, should mostly delegate toCommands
. Commands
implement use-cases or parts of it, and are thus reusable.- Subclass
ResourceQuery
andOrderQuery
when implementing use-case specific querying - this allows privilege checking. - One Transaction at a time - no TX inside of another TX.
- Commands are added to TXs and performed on close:
tx.addCommand(Command)
and thentx.commitOnClose()
- Use
tx.flush() and as late as possible in your TX
tx.commitOnClose()
- Only access
ElementMap
s if really no other way, mostly usetx.get*By()
,tx.findBy()
and queries - if a specific get is missing, then add the method toStrolchTransaction
and send a pull request! - Don't write logic in REST API beans. Delegate to other classes, making your code reusable!
- Transform to JSON using the
StrolchElementToJsonVisitor
. - References between objects is done by adding a
ParameterBag
with the idrelations
to the object and thenStringParameters
with the value being the ID, the UOM set to the type of element being referenced and the Interpretation set to the class type being referenced.