This page will guide you through the modernization of the business layer of your COBOL modernization project.
This reference guide does not explain the logic of data description in COBOL environment. We assume that readers have enough knowledge in COBOL to understand the equivalents between legacy behaviors and the ones computed by the bean modernization process.
In your COBOL legacy inputs, the business layer you will be able to modernize is located into the DATA division of your cblmf files, and more precisely in the FILE, WORKING-STORAGE and LINKAGE sections.
The Outline view can be helpful to describe the hierarchy of these sections.
The following steps allow you to modernize the business layer of a cblmf file :
- Open an UML model;
- Open the cblmf file containing the beans you want to modernize with the Cobol Annotation Editor;
The Bean Modernization can be triggered via multiple actions :
- The first way is to use the Segment View. Open this view by using the Window -> Show View -> Other... entry (left) or via the Quick Access menu (right) :
Then, you can then select a record in your Cobol Annotation Editor by clicking somewhere in its definition and its corresponding hierarchy will be displayed in the Segment View. Right-click on the root element and select the Legacy Object Modernization entry;
- If you want to handle multiple records at a time, you can also select the Legacy Objects Modernization menu entry in the Reverse menu. A window appears showing the list of all records found in the opened file. Select the ones you want to modernize, then click on OK;
The following screen appears :
The beans you have selected in the previous window are shown in (1).
- The type of each element is described by the following table :
Icon Description Class Redefines/Redefined By Class Property Redefines/Redefined By Property Duplicated bean Getter operation Setter operation
- The names of all entities and their properties
are changed to be in accordance with the target language naming
Java : The naming convention is camel case for properties and operations, capitalized camel case for classes and upper snake case for constants.
.NET : The naming convention is capitalized camel case for properties, operations and classes and upper snake case for constants.
- The type of each element is described by the following table :
If you click on an element, the panel shown in (2) provides useful information such as :
- Name : The modernized name of the element;
- Legacy Mapping : The full path to the corresponding element in the legacy environment;
- Type : The modernized type of the element (for properties);
- Cardinality : Whether or not the element will be modernized as a list (for properties);
- Default Value : The default value of the element if it has successfully been computed from the legacy one (for properties);
- Legacy Type : The legacy type of the element (for properties);
- Legacy Occurs : The occurs count of the element in the legacy layer (for properties);
- Redefines : The modernized property redefined by the element (for properties);
- Redefined by : The modernized property the element is redefined by (for properties);
- Return Type : The modernized return type of the element (for operations);
- Kind : The kind of the element : getter or setter (for operations);
- Body : The modernized logic of the element (for operations).
The Use local mappings checkbox shown in (3) allows, when enabled, to file-scope the relationship between the modernized element and the legacy one. Default behavior is global-scope, meaning that same hierarchies in multiple cblmf files will result in binding to the same modernized element.
The Class options panel shown in (4) allows you to select the kind of modernized class which will be generated by the wizard. For more information about the kind of entities present in the UML layer, please refer to the business modeling page.
- is transient object : Allows, when enabled, to generate the beans as not persisted elements, for beans with no database relationship purpose;
- generate "AsString" attributes : Allows, when enabled, to generate AsString utilitarian methods for Value Objects.
The Generation target panel shown in (5) allows to to select the modernization behavior of the wizard :
- Generate beans : The beans will be completely added to the UML model;
- Store beans : The beans will be stored in an EMF catalog;
- Merge beans : The beans will be merged into a previously created bean. You can then select the target merging class using the Select button shown in (6).
You can also modify elements shown in (1) for more advanced generation use cases. The section Bean modification covers the tools provided by the Legacy Objects Modernization.
When the modernization is ready to be started, click on Finish. The resulting elements will appear under the generatedModel folder of your UML model, or in the merging class for a Merge beans behavior.
The wizard provides several refactoring operations, available when right-clicking on an element in the panel shown in (1).
- Rename... : Allows to rename the element;
- Add Root Class : Allows to create an other class to be generated;
- Delete : Allows to delete the element (for classes and properties);
- Move To... : Allows to move the element into an other class (for properties);
- Change Type... : Allows to modify the computed modernized type of the element (for properties);
- To synthetic stubs : Allows to transform the element to a getter/setter combination (for properties).
Note that the body of these methods will be generated as TODO.
- Remove duplicate beans : Allows to search for duplicated beans (same name and same attribute number/name/type).
If such duplicates are found, only one instance will be generated, bearing all mappings.
Mass Property Renaming
You can also use a substitution file to automatically rename existing patterns in your COBOL element names.
- Add a file called dictionary.properties under the mappings/ folder of your COBOL Reverse Project;
- For each pattern you want to replace, add an entry key=value;
- In the next bean modernization process, all matching patterns in your COBOL elements names will be replaced by the value you specified.
mappings/dictionary.properties : TX=Tax
INV-TX-CODE -> invTaxCd
Modernizing redefinitions can be done using the wizard. Let's take an example :
The Bean Modernization Wizard on these two structures gives the following result :
Both TestRedefines2 and TestRedefines2R have a red icon to indicate the redefinition between them. The properties panel on the right gives the information about which structures redefines/are redefined by others.
To resolve the redefinition, choose the structure you want to keep, then right-click on it and select the Use as master redefinition entry.
The redefined element is deleted as well as its properties. Instead, getters and setters are used to recreate redefined properties based on master properties. In the above example, the result is as follow :
NOTE : For the time being, this operation is only available between structures whose sizes match.
Global preferences regarding bean modernization behaviors can be found in the Window -> Preferences Eclipse menu, in the Blu Age -> Blu Age Reverse -> Bean Modernization entry menu.
The following table describes each bean modernization preference :
|Transform attribute/class name containing underscore '_' into camelcase||Classes and properties names with underscores in the legacy layer are converted into camelcase naming convention.||False|
|Generate "AsString" attributes in VOs||Whether or not to generate AsString utilitarian methods for Value Objects.||True|
|Generate attributes default values||Whether or not to generate default values for properties.|
These default values are either computed from the legacy elements or computed from the standard default values of the modernized type of the property. The Empty default values choice allows to generate empty strings as default values, whereas the fixed-sized default values allows to generate a string filled with spaces, at the size of its legacy equivalent.
|True / Empty default values|
|Initialize collection attributes||Whether or not to apply appropriate configuration to collection
attributes and associations in order to further automatically
generate their initialization / fill.||False|
|Generate getters/setters operations||Whether or not to generate getters/setters process operations for each modernized