Author: tchemit Date: 2010-11-28 02:01:44 +0100 (Sun, 28 Nov 2010) New Revision: 1010 Url: http://nuiton.org/repositories/revision/eugene/1010 Log: fix tag value importing with stereotype Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelReader.java Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelReader.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelReader.java 2010-11-28 00:29:07 UTC (rev 1009) +++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelReader.java 2010-11-28 01:01:44 UTC (rev 1010) @@ -91,7 +91,9 @@ * fr.isisfish.entities.Population.operation.getRegion.tagvalue.pk=... */ protected Pattern propertiesPattern = Pattern - .compile("^((?:[_a-zA-Z0-9]+\\.)+(?:_?[A-Z][_a-zA-Z0-9]*\\.)+)(?:(class|attribute|operation))\\.(?:([_a-zA-Z0-9]+)\\.)?(?:(stereotype|tagvalue|tagValue)?)\\.([_a-z0-9][_a-zA-Z0-9]*)?$"); + .compile("^((?:[_a-zA-Z0-9]+\\.)+(?:_?[A-Z][_a-zA-Z0-9]*\\.)+)(?:(class|attribute|operation))\\.(?:([_a-zA-Z0-9]+)\\.)?(?:(tagvalue|tagValue)?)\\.([_a-z0-9][_a-zA-Z0-9]*)?$"); + protected Pattern propertyStereotypePattern = Pattern + .compile("^((?:[_a-zA-Z0-9]+\\.)+(?:_?[A-Z][_a-zA-Z0-9]*\\.)+)(?:(class|attribute|operation))\\.(?:([_a-zA-Z0-9]+)\\.)?(?:(stereotype)?)$"); /** * Pattern to define tag values authorized at model level in the model @@ -242,7 +244,7 @@ modelImpl.setVersion(value); } if (isVerbose()) { - log.info("import model tag value " + key); + log.info("import model tag value " + key + " --> " + tag + " = " + value); } modelImpl.addTagValue(tag, value); numberImportedTagValues++; @@ -257,10 +259,17 @@ } if (!matcher.find()) { - if (log.isWarnEnabled()) { - log.warn("Invalid tag value [" + key + "] : syntax is not correct."); + + // try with the stereotype + matcher = propertyStereotypePattern.matcher(key); + + if (!matcher.find()) { + + if (log.isWarnEnabled()) { + log.warn("Invalid tag value [" + key + "] : syntax is not correct."); + } + continue; } - continue; } String fqn = matcher.group(1); @@ -271,8 +280,17 @@ String targetName = matcher.group(3); // type is stereotype or tagvalue String type = matcher.group(4).toLowerCase(); - String tag = matcher.group(5); + String tag; + + if (STEREOTYPE.equals(type)) { + + // using a stereotype means nothing after the type + tag = null; + } else { + tag = matcher.group(5); + } + if (log.isDebugEnabled()) { log.debug("Propriete: '" + key + "' => " + "fqn:" + fqn + " target:" + target