Support for updating criterion types when importing criterion types has been added.
To update a criterion type, it is only necessary to send the modifications, and not all the state. In consequence, it is only necessary to send modified propert
ies in the criterions and the criterion type itself, and only new or modified cr
iterions need to be sent. Furthermore, any legal change in the criterion hierarchy of the criterion type is allowed.
Finally, a test case has been added to test the updating funcionality.
IMPORTANT: CriterionType and Criterion tables must be removed because they now need "code" column with non-null values. Any row in any other table refering to CriterionType and Criterion instances must also probably be removed. In consequence, it is probably better to remove all databases (navaldev, navaldevtest, navalprod and navalprodtest).
This first version does not implement updates yet (only insertions) and does not detect repeated codes in the entities being imported (repeated codes in database are detected). "code" attribute has now been added to entities, and "num-instance" + "code" + "entity-type" attribute has been added to InstanceConstraintViolationsDTO.
This effort has been implemented creating reusable classes (to facilitate migration of the rest of services) and with a non-invasive approach (to make possible migrate each service individually and minimize the number of changes to the current code [specially testing code]).
Some existing methods/attributes in existing reusable classes (e.g. Util, InstanceConstraintViolationsDTO) have been deprecated (to support migration of services incrementally) and new ones have been implemented.
New reusables clases have been implemented: IntegrationEntity (all entities used in application integration must extend from this one), IIntegrationEntityDAO, IntegrationEntityDAO, InstanceConstraintViolationsDTOId (identifier for an instance causing a list of constraint violations), and IntegrationEntityDTO (all entity DTOs must extend from this one). Please, have a look to the JavaDoc of such classes.
The following improvements have been implemented: (1) criterion type and criterion names are trimmed with StringUtils.trim, (2) case is ignored for criterion type and criterion names, (3) just one constraint violation is reported for a criterion type with a name already used by another criterion type being imported, (4) CriterionType::checkConstraintNonRepeatedCriterionNames now discards criterions with names fulfilling StringUtils.isBlank(criterionName), (5) Criterion::createUnvalidated and CriterionType::createUnvalidated now use BaseEntity::create (to avoid to call setNewObject and other possible future actions), and (6) assertTrue/assertFalse JUnit methods in CriterionServiceTest now make use of the toString method provided by constraint violations related DTOs (to make debugging easier).
The new foler includes a README file (please, update it when adding new scripts), common scripts (base64.sh and rest-common-env.sh), two scripts (post-criterions-types.sh and get-criterion-types.sh) for importing/exporting criterion types, and a sample file (criterion-types-sample.xml) with criterion types to be imported.