Telosys does not generate column definition (i.e. for CHAR-columns) - telosys

When using Telosys to generate entities with the java7-persistence-commons-jpa-T300 templates the column annotation never includes columnDefinition when generating the #Column annotation in JpaRecord-classes. That forces database schemageneration with hbm2ddl always to generate VARCHAR columns.
But when the origin database column is an CHAR-column the generated record-class should also generate columnDefinition... i.e.: #Column(columnDefinition = "CHAR(xx)", name = "VVT_NR", nullable = false, length = 20)
Is there a way to force telosys to generate the columnDefinition (with correct length for xx of course)?

The JPA function "$jpa.fieldAnnotations()”
used in the mentioned template is a shortcut to generate the "classical" JPA annotations for a given field and indeed it doesn’t generated all the “#Column” optional elements (for example “table”, “insertable”, “updatable” and “columnDefinition” are not generated)
In version 3 there's no way to force the generator to produce the "columnDefinition".
But if you really want to generate the “columnDefinition” you can create a specific function or a specific macro.
To create a Velocity macro see :
http://www.telosys.org/templates-doc/velocity/macro.html
http://people.apache.org/~henning/docbook/html/ch07.html
To create a specific function see this other question :
Is it possible in a Telosys template to call a function created specifically?
For a specific function you can reuse the "$jpa" class source code :
https://github.com/telosys-tools-bricks/telosys-tools-generator/blob/master/src/main/java/org/telosys/tools/generator/context/Jpa.java

Related

Azure DevOps Access Custom Field From Script

I have a required custom field on any ticket created (Bug, Tasks, PBI).
I have a pipeline that creates tickets automatically, but the values that are used to create these tickets doesn't have a value for my custom field. I want to set this custom field by adding an entry to the pipeline variables, but I don't know the variable name of the custom field.
How can I find the variable name of the custom field so I can access it?
I found out how to determine your custom variable name.
ADO has a bunch of APIs. The following will give you all the details of a specific work type. For my case I needed the "bug" work type.
/*
Api to display work type fields in JSON format
Replace {} with correct values
*/
https://dev.azure.com/{orginization}/{project}/_apis/wit/workitemtypes/{type}/fields?api-version=6.0
The resulting JSON will give you a whole list of variables. Here is what the System Variable and a Custom Variable look like.
The referenceName is the variable name you would use in your scripts, etc.
TL;DR -
Take your field name and remove all spacing and then put Custom. in front of it.
Custom.FieldNameWithNoSpace

How to get a Row representation of a generated table?

I want to get Row[N]<...> representation of a generated JOOQ table type. I want to use it in this context:
val p = PROJECTS.`as`("p")
val pmu = PROJECTMEMBERUSERS.`as`("pmu")
val query = db
.select(p.asterisk(), DSL.arrayAgg(DSL.rowField(<-- insert Row[N]<...> here -->)))
.from(p.join(pmu).on(p.ID.eq(pmu.PROJECTID)))
.groupBy(p.ID)
I already tried inserting pmu.fieldsRow(), but DSL.rowField(...) expects another parameter type.
Error:(39, 58) Kotlin: None of the following functions can be called with the arguments supplied [...]
This question is a follow up question to Using PosgreSQL array_agg with join alias in JOOQ DSL but should be self contained.
Missing feature in jOOQ 3.11
There seems to be a missing feature in the jOOQ code generator, a generated Table.fieldsRow() overridden method that provides a more narrow, covariant Row[N]<...> return type. I've created a feature request for this, to be implemented in jOOQ 3.12:
https://github.com/jOOQ/jOOQ/issues/7809
Also missing, an overloaded DSL.rowField(RowN) method:
https://github.com/jOOQ/jOOQ/issues/7810
Workaround, list columns explicitly
This is the most obvious workaround, which you obviously want to avoid: Listing all the column names explicitly:
row(pmu.COL1, pmu.COL2, ..., pmu.COLN)
Workaround, use generated records
There already is such a generated method in generated records. As a workaround, you could use
new ProjectMembersUsersRecord().fieldsRow();
Workaround, extend the code generator
You can implement #7809 yourself already now, by extending the JavaGenerator with a custom code section:
https://www.jooq.org/doc/latest/manual/code-generation/codegen-custom-code

Auto generate random long in IntelliJ Live Template

How do I auto generate an arbitrary number (Long) for use in a Live Template in IntelliJ?
Example:
public static final long uid = $randomLong$;
where randomLong is replaced with a random long value. I have tried adding the following as an expression for the variable on the live template definition but nothing is generated when the template outputs.
new Random().nextLong()
What I am trying to achieve is very similar to what the IDEA code inspector generates for the Serialization version UID field but with a live template.
Please try adding groovyScript("new Random().nextLong()") as the variable expression instead.

How to use variable value in live templates in Intellij IDEA?

I want to create live template for setter.
I've created this template
How can I use value of par variable to generate value of var variable? Basically, I want to avoid redundancy here and put name of variable only once and other one will be generated automatically by some algorithm.
UPDATE
I want to clarify a little bit what I want to achieve.
Suppose I want to create setter with name setTime which has parameter time.
public void setTime(long time)
{
// ...
}
I don't want to type "time" twice - capitalized and non-capitalized. I want to type just parameter name so method name will be generated automatically.
UPDATE (Answer)
Turned out that variable order is important. This is final result of what I want
You can use the soutv as an example, notice how it defines a copy of a variable:
It's also possible to define custom expression for live templates via plugins or Groovy code:
How can i add custom expression functions for Live templates in Intellij.

How do I use Team Build Properties in MSBuild?

I have a simple tfs-2010 build definition using the default process template. In it I defined the Build Number Format using $(BuildID) to define part of the computed field. This works and I can see what BuildID's value is.
Now I try to pass the BuildID property to MSBuild as an argument:
/p:SomeProperty=$(BuildID)
However when I look at the build log I see SomeProperty literally equals $(BuildID) rather then the value of BuildID.
What am I missing?
Update for clarity: What I'm asking is how to reference as a Build Process Parameter in the Build Definition. For example Build Number Format has a default expression of $(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)
You need to use a VB.NET expression. For example:
String.Format("/p:SomeProperty={0}", BuildDetail.BuildNumber)
The Build Number tokens, e.g. $(BuildDefinitionName), are specific to the Build Number Format process parameter. They aren't tokens that you can use anywhere else in the build process. Most are available in the BuildDetail object or from the environment. The Build Id is a bit of a special case, however. It comes from the identity column of the builds table and isn't directly exposed in our public API. You could extract it from the BuildNumber, like this:
BuildDetail.BuildNumber.Substring(BuildDetail.BuildNumber.LastIndexOf('/') + 1)
Note that you would need to do this in the XAML directly rather than putting a VB expression into the build process parameter editor GUI. That's because those values just get passed through as literal strings.