@SecurityPermission(serviceName = ServiceName.UPDATE_CONTRACTOR) @AuditTrail(serviceName = ServiceName.UPDATE_CONTRACTOR) @Override public Contractor updateContractor(Contractor contractor) { /* Validations */ /* State validation */ contractor.validate(); /* Service logic */ EntityValidator entityValidator = new EntityStateValidator(); if (entityValidator.isValidateEntityBeforeUpdate(contractor)) { getEntityManager().merge(contractor); } return contractor; }
@SecurityPermission(serviceName = ServiceName.ADD_CONTRACTOR) @AuditTrail(serviceName = ServiceName.ADD_CONTRACTOR) @Override public Contractor addContractor(Contractor contractor) { /* Validations */ /* State validation */ contractor.validate(); /* Service logic */ EntityValidator entityValidator = new EntityStateValidator(); if (entityValidator.isValidateEntityBeforeCreate(contractor)) { getEntityManager().persist(contractor); /* At this stage the property object will not have an id assigned, until after the return, the transaction has committed. */ } return contractor; }