Here is a proposal for using property datatype names to determine database character storage lengths. If a UML data type is "String", we can do what the code does now, ending up with a default length (255). If a UML data type is "String50", generate a "string" datatype with a length of 50.
This can be implemented using the proposed code change below. It applies to both the 1.3 and 1.4 versions of UmlMdrLoader.java.
For detecting "String" datatypes in getTypeDesc():
Hi Tim.
I think that there is a cleaner way to do that. Your Idea will turn the UML model in something difficult to understand, too much coupled with the importer tool.
The alternative is use tag values in the field. Tools like argo and poseidon enable the definition of tag and values like:
"length"=10
"dbtype"=NUMERIC
for each property in a class. Those informations are exposed to the importer by the getTagValue method of the IUMLMdrLoader class.
Some UML tools don't have tags. In that case, you can still associate stereotypes with the fields.
Other tools like Rational Rose need some configuration to expose tagged values (I don't know how to configure it yet).
I myself think that this information can be entered in the metaspecification too (on eclipse) in those cases were the UML tool is too old fashioned.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is a proposal for using property datatype names to determine database character storage lengths. If a UML data type is "String", we can do what the code does now, ending up with a default length (255). If a UML data type is "String50", generate a "string" datatype with a length of 50.
This can be implemented using the proposed code change below. It applies to both the 1.3 and 1.4 versions of UmlMdrLoader.java.
For detecting "String" datatypes in getTypeDesc():
orginal code:
-------------------------------------------------------------------------
} else if (fullName.equals(String.class.getName())
|| fullName.equals("String"))
fullName = "string";
proposed code:
-------------------------------------------------------------------------
} else if (fullName.equals(String.class.getName())
|| fullName.equals("String")
|| Pattern.matches(".*String\\d+", fullName))
fullName = "string";
For setting "String" lengths in buildProperties():
original:
-----------------------------------------------------------------------
HProperty hp = findAttr(hcl, attr);
...
if (!assocEnum(attr.getType(),cl,hp))
hp.setType(getTypeDesc(attr.getType(), cl));
proposed:
-----------------------------------------------------------------------
HProperty hp = findAttr(hcl, attr);
...
if (!assocEnum(attr.getType(),cl,hp)) {
hp.setType(getTypeDesc(attr.getType(), cl));
if (hp.getType() == "string") {
String typeName = attr.getType().getName();
if (Pattern.matches(".*String\\d+\\z", typeName)) {
String lengthText = typeName.substring(typeName.lastIndexOf("String")+6);
hp.setLength(Integer.parseInt(lengthText));
}
}
}
Hi Tim.
I think that there is a cleaner way to do that. Your Idea will turn the UML model in something difficult to understand, too much coupled with the importer tool.
The alternative is use tag values in the field. Tools like argo and poseidon enable the definition of tag and values like:
"length"=10
"dbtype"=NUMERIC
for each property in a class. Those informations are exposed to the importer by the getTagValue method of the IUMLMdrLoader class.
Some UML tools don't have tags. In that case, you can still associate stereotypes with the fields.
Other tools like Rational Rose need some configuration to expose tagged values (I don't know how to configure it yet).
I myself think that this information can be entered in the metaspecification too (on eclipse) in those cases were the UML tool is too old fashioned.