This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 123186

Summary: Two Domain Templates with same mappings - only one is used during code generation
Product: uml Reporter: Craig Conover <conover>
Component: Code GenerationAssignee: Craig Conover <conover>
Status: VERIFIED FIXED    
Severity: blocker CC: mmirilovic, sustaining
Priority: P2    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description Craig Conover 2007-11-30 19:55:41 UTC
Reproduction steps:

- Create two template files to be used for code generation. For a really simple example, create a file called foo.txt
with the contents "foo". Another file named bar.txt with the contents "bar".
- Goto Tools->Templates: navigate to UML/Code Generation
- Add the two files: foo.txt and bar.txt
- Goto Tools->Options, UML, Templates tab
- Add a new domain (select Java node and click Add button)
- Set properties for the domain:
  Element type = Class
  Stereotype = foobar
  Output Parameters:
  Click Add Template: 
    Filename Format = {name}Foo
    Template File = foo.txt
- Add another new domain (select Java node and click Add button)
- Set properties for the domain:
  Element type = Class
  Stereotype = foobar
  Output Parameters:
  Click Add Template: 
    Filename Format = {name}Bar
    Template File = bar.txt

- Create a UML project with a Class Diagram
- In project customizer, enable the two new Domain Templates
- Add one Class element, name it TestClass
- Add a Stereotype to the class element called twofiles
- Create a Java project
- Generate code for the class element

The result should be two files: TestClassFoo.txt and TestClassBar.txt. 

Only the TestClassBar.txt file is created.

Cause: the hashmap of domain templates is keyed, but elementType:stereotype pairs and each duplicate pairing overwrites
the previous one so only the final one is used for code generation.
Comment 1 Craig Conover 2007-12-05 18:20:11 UTC
Solution was to check if a particular elementType:stereotype key already existed in the domain template hashmap. If so,
get the value (list of templates) and add the new templates to the end of that list and add back to the hashmap.
Comment 2 Craig Conover 2007-12-06 18:02:15 UTC
fix checked in to trunk and unstable_uml_visualcomponent branch
Comment 3 Petr Blaha 2008-02-01 12:32:04 UTC
The bug wasn't verified before cut-off date for 6.0.1patch1 and will be included in 6.0.1patch2.
Comment 4 Peter Lam 2008-02-22 23:55:31 UTC
verified in NB 6.1 build 200802191203.
Also verified in latest Meteora build (unstable_uml_visualcomponent branch).
Comment 5 Marian Mirilovic 2008-02-26 12:12:45 UTC
http://hg.netbeans.org/main/rev/a1a217c9c090
Comment 6 khu 2008-03-05 18:45:35 UTC
The fix has been ported into the release601_fixes branch

Checking in DomainTemplatesManagerPanel.form;
/cvs/uml/codegen/src/org/netbeans/modules/uml/codegen/ui/Attic/DomainTemplatesManagerPanel.form,v  <-- 
DomainTemplatesManagerPanel.form
new revision: 1.13.6.1; previous revision: 1.13
done
Checking in DomainTemplatesManagerPanel.java;
/cvs/uml/codegen/src/org/netbeans/modules/uml/codegen/ui/Attic/DomainTemplatesManagerPanel.java,v  <-- 
DomainTemplatesManagerPanel.java
new revision: 1.27.6.1; previous revision: 1.27
done
Checking in DomainTemplatesRetriever.java;
/cvs/uml/codegen/src/org/netbeans/modules/uml/codegen/dataaccess/Attic/DomainTemplatesRetriever.java,v  <-- 
DomainTemplatesRetriever.java
new revision: 1.7.6.1; previous revision: 1.7
done