Moqui entity field-type-options boolean - moqui

I want to create a Entity in which there is a field of type Boolean. But according to XSD for entity-defintion in Moqui type of boolean is not defined. Is there a way to create a Boolean field in Entity?

There is no consistent boolean data type across different databases so to remain relational database agnostic Moqui uses a single character column with the text-indicator entity field type. The convention in Moqui Framework and the business artifacts in Moqui ecosystem is to use Y for yes/true and N for no/false.

I find the solution, all you have to do is add this property inside tag <database-list> in MoquiDefaultConf.xml .
<dictionary-type type="boolean" java-type="java.lang.Boolean" default-sql-type="BOOLEAN"/>
I am using PostgreSQL maybe its different in other database systems.
<dictionary-type type="boolean" java-type="java.lang.Boolean" default-sql-type="BOOLEAN"/>

Related

Is there a way to reuse a regex pattern as both a patternProperties key and string type pattern in a json schema?

For example, in the GBFS project, top level keys in the gbfs.json['properties']['data'] object are described as:
language: The language that will be used throughout the rest of the files. It MUST match the value in the system_information.json file.
This is enforced by a patternProperties definition in the gbfs.json schema. But as described by the explanation of the field, this property should match a string property with the same regex pattern in system_information.json.
Would there be a way to define this regex pattern once and use it both as a patternProperties key and string type pattern for the language field?
Not in JSON Schema syntax itself, but you could go up one level and generate your schema programmatically, say with a template that used a placeholder variable for that regex. You could then use the template to regenerate the schema whenever it changed -- for example, if your schema is normally kept in git, then you could use a git commit hook to update the regex in all the places it is used. Or if you deploy your schema with ansible, you can generate the file with a template there too.
As mentioned, not with JSON Schema itself.
The common approach to solving this problem is to use Jsonnet, which is a templating language for JSON.
https://jsonnet.org
Having not used it myself, I have no opinions on it, beyond I've seen it used effectively in large scale projects in the course of researching JSON Schema use cases.

Standard deep nested data type?

I took the nice example clientPrintDescription.py and create a HTML form from the description which matches the input data types for the particular RFC function.
In SAP data types can contain data types which can contain data types, and I want to test my HTML form generator with a very nested data type.
Of course I could create my own custom data type, but it would be more re-usable if I would use an existing (rfc-capable) data type.
Which data type in SAP contains a lot of nested data types? And maybe a lot of different data types?
I cannot tell which structure is the best for your case but you could filter the view DD03VV (now that is a meaningful name) using the transaction se16h. If you GROUP BY the column TABNAME and filter on WHERE TABCLASS = 'INTTAB' the number of entries is an indicator for the size of the structure.
You could also aggregate and in a next step filter on the maximum DEPTH value (like a SQL HAVING, which afaik does not exist in SAP R/3). On my system the maximum depth is 12.
Edit: If you cannot access se16h, here's a workaround: Call se37 and execute SE16N_START with I_HANA = 'X'. If you cannot access se37 use sa38 and call RSFUNCTIONBUILDER (the report behind se37).
PS: The requests on DD03VV are awfully slow, probably due to missing optimzation for complex requests on ABAP dictionary views.
If I had to give only one DDIC structure, I would give this one:
FDT_TEST_DDIC_BIND_DEEP_S
It contains many elements of miscellaneous types, including nested ones, and it exists in any ABAP-based system (it belongs to the "BASIS" layer).
As it contains some data and object references in sub-levels which are invalid in RFC, you'll have to copy it and remove those reference fields.
There are also these structures (column "TABNAME") with fields of some interest:
TABNAME FIELDNAME Description
-------------------- ------------- ------------------------------------------------
SFW_BF FROM_RELEASE elementary built-in type
SAUNIT_S_ALERT WHEN data element
SAUNIT_S_ALERT HEADER structure
SAUNIT_S_ALERT TEXT_INFOS table type
SAUNIT_PROG_INFO .INCLUDE include structure SAUNIT_S_TADIR_KEY
SKWF_IOFLD .INCLU-FLD include structure SKWF_IO
SWFEXPSTRU2 .INCLU--AP append structure SWFEXPSTRU3
APPEND_BAPI0002_2_2 .APPEND_DU append structure recursive (append of BAPI0002_2) (unique component of APPEND_BAPI0002_2_2)
SOADDRESS Structure with nested structures on 2 levels
Some structures may not be valid in some ABAP releases. They used to exist in ABAP basis 7.02 and 7.52.
Try the function module RFC_METADATA_TEST...
It has some deeply nested parameters.
In Se80 under Enterpise service browser, you will find examples of Proxy structures that are complex DDIC structures. With many different types.
Example edo_tw_a0401request
Just browse around, you will find something you like.
I found STFC_STRUCTURE in the docs of test_datatypes of PyRFC.
Works find for testing, since it is already available in my SAP system. I don't need a dummy rfc for testing. Nice.

Declaring a property as the same type as a specific other property

I'm using EF code first with a fairly large number of entity types and I am building a number of reports with filter models that refer to the ID (primary key) fields in the different entity types. Depending on the table, the ID field is either a Byte, Short, Integer or Long (depending on how many records I expect in that table and where it is referenced from).
Eg. I may have a "Channel" table which has an ID field of type Short, whereas "Order" has an ID field of type "Integer".
When I create a model for a view to filter on eg. Channel, I would do a ChannelID Property, which would either be a Short or a Short? (as in Nullable(Of Short)). However, this is a pain as I have to look up the correct ID type for the relevant entity type each time I add a filter and in the long run, it is fragile as I may change the ID type on a particular entity and don't want to have to hunt down every reference to it.
Ideally, I would like to have some way of referring to it eg.
Public Property ChannelID As TypeOf([Channel].[ID])
but I can't see any way to do that.
If I was using C, I would probably #define ChannelID short and just refer to the type as ChannelID throughout, but I can't see any way of using the VB.NET compiler to achieve something like that (which isn't quite as good as the above solution either.
I have thought of the idea of implementing it as an interface for each type, but that doesn't work if there are multiple properties filtering on the same entity in a single model (which is possible), and it is messy as it means an interface for every entity type.
I realise that I could just set them all as Long and there isn't really a major disadvantage to doing this, but I am picky about matching types.
Does anyone have any clever ideas for dealing with this?
Type aliasing will work across files - set this on the 'References' tab of the project properties - e.g., test = System.Int32.
Then in any file in the project you can use the type alias 'test'.
e.g.,
Dim myInt As test

Default class for Hibernate Single Table Inheritance Scheme

I have an application that maps views into an existing Hibernate schema that makes extensive use of single table inheritance with a discriminator-value in the CLASSNAME column. What makes my situation unusual is that I do not what to support all the subclasses (discriminator-value in the Hibernate mappings) in the data, just those of interest to the application.
The problem is that if the application encounters an unsupported discriminator-value, Hibernate throws a "org.hibernate.WrongClassException" because it cannot find a mapping with the required discriminator-value.
What I would like to do is to create subclass that Hibernate will use if the discriminator-value is unknown (instead of throwing an exception).
Is there a way to do this?
Thanks,
Ed
I found the answer here for those using annotation:
Mapping Hibernate entity for unknown DiscriminatorValue for InheritanceType.SINGLE_TABLE.
What this does not tell you is what to use in a mapping file. I checked the open source code and it appears that the discriminator-value="<not null discriminator>" will do the trick. Hibernate checks for this value (and <null discriminator>), and gives them special handling.

Can I get NHibernate to enforce that a string property is non-empty?

I know about the not-null attribute. Is there one for enforcing the minimum length of a string property? I don't want empty strings in my database.
I don't know of anything in the mapping file that will let you do this (and I don't see anything in the schema). You could probably define a custom type using NHibernate.IUserType and build your logic into that type (if the string is empty save null). Here is an example of building an IUserType (it would be easy to change this example code to work for you)
The other option is to take advantage of NHibernate.Validations and to handle the validation logic before getting to the point where you are saving the entity to the database.
You are looking for NHibernate Validator! There's a blog post here showing some of its goodness.