Generate PL/SQL from UML - oracle

Are there any tool (open source or freeware) to generate the PL/SQL code (with objects) from a UML Diagram?
Thanks!

You may try to write your own transformation through the Eclipse Modeling Tool Project. You need Papyrus, as UML graphical editor, to create UML models conform to the Eclipse's ECORE (which is the Eclipse implementation of the MOF meta-meta-model). Then you can write Acceleo scripts describing how to turn UML elements (i.e. classes, stereotypes, properties, operations, etc.) into the code you need (i.e. PL/SQL). Acceleo is the Eclipse implementation of the MOFM2T language which is the OMG standard for model to text transformations (http://www.omg.org/spec/MOFM2T).

I think it would be easier to generate java code from an UML diagram then to add ORM annotations in your java code and then use the dali Eclipse project to generate your SQL code.

Related

Programmatically render (export as Image) Class Diagrams (Visual Studio)

In my projects I actively use class diagrams (*.cd). I'd like to export my diagrams programmatically (e.g. during the build, or on my CI server) in order to use them on Wiki pages, etc.
I know that I can do it manually via "Export Diagram As Image" dialog
But the diagrams change rather often so I'm curious is there a way to do it programmatically (using any library, utility, etc)?
But the diagrams change rather often so I'm curious is there a way to do it programmatically (using any library, utility, etc)?
you can use method named GetObject to get the Diagram of the underlying implementation. This type has a method CreateBitmap. The following link provide a complete code sample for your reference.
https://msdn.microsoft.com/en-us/library/ff469815.aspx
Update:
The UML diagrams support are:
1.Class Diagram
2.UseCase Diagram
3.Sequence Diagram
4.Component Diagram
5.Activity Diagram
6.Layer Diagram

Customizing Linq-to-SQL DBML template

I am using Linq-to-sql for generating code for database interaction. I need the generated code to include Interfaces for each concrete class, and believe the only easy way to achieve this is to modify the Linq-to-SQL code generating template.
I have seen a guide by Damien Guard (http://damieng.com/blog/2008/09/14/linq-to-sql-template-for-visual-studio-2008), however I have 2 constraints prohibiting the approach:
I am on VS2010; and
I am working on a Dev environment in which I cannot install non-approved tools/etc.
Are there any other ways to modify how the Linq-to-sql code is generated the template for VS2010 that do not require installing 3rd party templates/etc?
Alternatively, are there any other easy ways to reverse engineer Interfaces to match existing concrete classes?

Visual Studio UML designer - data types

I'm using the Visual Studio UML designer to create some class diagrams. Since I would like to generate code from the diagrams it need to be accurate.
Now I'm trying to define the type of some properties of my classes, but I can't find a way to give them a type different from bool, string, int and UmlimitedNatural (and my own types of course). I found a tutorials that claims I would have to create custom stereotypes. Really? I mean it's VS, I'm just asking for some build in reference/value types like byte or GUID.
Do I overlook a hidden switch or if there is really now way to tell VS to bring up some commonly used types does anyone know a source for UML profiles that provide it? And how I can define more complex types like generics?
UML is implementation language neutral. Since types differ by platforms it is necessary to define an implementation language profile for any UML tool. Most UML CASE tools include the option to choose the language and apply a built in profile, which should make them available.

Is it possible to generate from code using T4

I have used T4 to generate partial classes from some input file (XML, etc) and then hand code additional partial bits onto those generated classes.
Is it possible to go the other way? To hand craft partial classes, and use T4 to template boiler plate bits to them?
Obviously I can't use reflection to look for the classes since it's not compiled yet, but I see Visual Studio inspect uncompiled code for different utilities. Perhaps Visual Studio offers some feature to support this I don't know about. Long shot, I guess.
Thanks
Also, you can use T4 with VS's CodeModel to read the code in your project without compiling and then generate from that metadata.
There's some pointers to examples here: http://blogs.msdn.com/b/garethj/archive/2009/09/25/dte-and-t4-better-together.aspx
Actually, T4 is used this way frequently. Yes, it requires reflection, but partial classes compile even if bits of them aren't generated yet. I would look at examples for generating strongly typed views as described here for examples of using reflection to generate new files.

For what purposes have YOU used T4?

T4 has existed for several years in Visual Studio, but doesn't get a lot of attention. However, for those that know it, there seems to be some very creative and useful purposes.
I am researching some different ways that T4 is used, and I would appreciate to hear how YOU may have used it for real life scenarios. I am primarily interested in non-standard and creative uses.
Some interesting examples:
Phil Haack uses T4 to create static CSS files from .less
To Generate WPF and Silverlight Dependency Properties using T4 Templates
Note: I realize this is a discussion-oriented question, but the answers could be helpful to others. I have tagged it as subjective and also marked as "community wiki", so please allow the question to remain open. Thanks!
I am not a big fan of the stringy-ness of app.config/web.config, so I use T4 to read those files and make an AppSettings/WebSettings class that wraps the connection strings and key/values in a real class. This means that, as long as I always use AppSettings.SomeValue to reference my app.config, I get compile time checking, which is really nice.
I've used the T4 Templates within the sharp-architecture to generate everything from models to controllers to basic views.
Definitely worth checking out, even if you just want to see some advanced examples of T4 templates in action
I use T4 to:
Generate CRUD SQL Server and Oracle scripts.
Generate Data Access Layer, based on a database schema
Layer Generate Business Logic Layer, based on a database schema
Generate ASP.Net webforms, both HTML and codebehind, based on a database schema (scafolding).
It gives me a good, quick, simple, basic starting point for my projects.
And the best is I'm in control.
Here you can download an example of my templates
SubSonic 3.0 makes heavy use of T4 templates for generating your entity code.
Essentially it calls GetSchema() on your database connection and runs each table it finds through the T4 entity template. The great thing about using T4 here is that if you don't like the way it's handling your database schema, just edit the template.
I've tweaked the T4's to handle MySQL databases better for my situation, as I make use of many tinyint columns which the default T4 maps to byte types. A quick edit to the T4 gave me the type I wanted instead for my application entities.
LINQ to SQL templates for T4
http://l2st4.codeplex.com/
Templates replicating the functionality of the SQLMetal and the LINQ to SQL classes designer code-generators for both C# and VB.Net requiring just Visual Studio 2008.
Check out this podcast on T4 by Scott Hanselman talking with Kathleen Dollard.
http://www.hanselminutes.com/default.aspx?showID=170
I've used T4 to generate:
proxies (design time, for injecting/wrapping monitoring
code/logging/... in a very specific exposed api).
interface generation for a one-on-one interface/class mapping
replace reflection
code by "directly/real" calling code (maintenance advantage of
reflection code, but performance of the actual code) for instance
when allowing access to properties through an indexer, or something
in that direction.
xml generation for a java project (couldn't find a
T4-like solution for java, that is easily shared within a company, T4
is easy because it's build in and you can run it from command line)
generate enums from a master database (we generated them both for a delphi-code base and .Net code base)
T4 Templates are used heavily in the Web Service Software Factory (Service Factory).
See here for a list of more than 30 T4 Generators from the community in several areas including ASP.NET,WCF, UML, ADO.NET, .NET
http://t4-editor.tangible-engineering.com/How-Do-I-With-T4-Editor-Text-Templates.htm

Resources