AXMLS check constraint - adodb

I am creating q site using Conreate 5 CMS.
I am creating a new block and I have to use AXMLS to create a database table.
I have been able to create a basic table but I would like to extend it to add an check constraint. Below is the code I have written so far.
<?xml version="1.0"?>
<schema version="0.3">
<table name="btAddVehicle">
<field name="bID" type="I">
<key />
<unsigned />
</field>
<field name="title" type="C" size="100">
<NOTNULL />
</field>
<field name="imgLocation" type="X"></field>
<field name="year" type="I" size="4"></field>
<field name="desciption" type="X"></field>
</table>
</schema>
so for the line I was intending to that size="4" would restrict the number of values to 4. eg 1990,1999 but this didn'st work
I have read this http://phplens.com/lens/adodb/docs-datadict.htm#foreignkey
but it seems unclear
It says
CONSTRAINTS Additional constraints defined at the end of the field definition."
SO would it be something like
<field name="year" type="I" constraint="check([year] LIKE REPLICATE ('[0-9]', 4)) "></field>
Or do I need to add an at the end of this code
`<sql>
add some kind of alter table to add the constraint
AlTER tblTable etc....
</sql>`

The size=4 only restrict it to a number between 0 and 9999. So no, that won't work.
I don't know how to use CONSTRAINTS either, but I have never needed that. Normally I use Concrete5's validation helper to validate values before saving them to the database. This also makes it a lot easier to get it printed out to the user in your view, if needed, using the validation error helper
Hope this helps you...

Related

Odoo13 QWEB report pdf name

On my custom modules that generate pdf reports the field "print_report_name" not name the report. I need report name + datetime actual.
Always take the name of the "name" field from the report definition.
I used it with Odoo10CE and it works perfectly.
Maybe there is another way to do it from the v10? I found nothing in the documentation.
You have to use this tag for your custom report name print under report tag. Right now I am using basic module. You can use your custom field and model for your use.
<field name="print_report_name">'%s - %s' % (object.name, object.date_done)</field>
Block of code for your reference.
<record id="action_report_lot_label" model="ir.actions.report">
<field name="name">Lot/Serial Number (PDF)</field>
<field name="model">stock.production.lot</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">stock.report_lot_label</field>
<field name="report_file">stock.report_lot_label</field>
<field name="print_report_name">'%s - %s' % (object.name, object.date_done)</field>
<field name="binding_model_id" ref="model_stock_production_lot"/>
<field name="binding_type">report</field>
</record>

Ignoring diacritics when sorting facet values in Solr 4

Tl;dr: How can I get Solr 4 to ignore diacritics when sorting facet values?
I've added the following four documents to the "collection1" Solr core in the default Solr example:
<doc>
<field name="id">1</field>
<field name="cat">manuka</field>
<field name="cat">mystery</field>
</doc>
<doc>
<field name="id">2</field>
<field name="cat">mānuka</field>
<field name="cat">stuff</field>
</doc>
<doc>
<field name="id">3</field>
<field name="cat">management</field>
<field name="cat">stuff</field>
</doc>
<doc>
<field name="id">4</field>
<field name="cat">abc</field>
<field name="cat">stuff</field>
</doc>
The "cat" field is defined as:
<field name="cat" type="string" indexed="true" stored="true" multiValued="true"/>
and the "string" type is defined as:
<fieldType name="string" class="solr.StrField" sortMissingLast="true" />
When I do a facet query on the "cat" field, sorted by value (http://localhost:8983/solr/collection1/select?q=*%3A*&rows=0&wt=json&indent=true&facet=true&facet.field=cat&facet.sort=index), I get:
....
"facet_fields":{
"cat":[
"abc",1,
"management",1,
"manuka",1,
"mystery",1,
"mānuka",1,
"stuff",3]},
....
Note that mānuka comes after mystery. I'd like to have mānuka come after manuka and before stuff, that is, I'd like the sort to ignore diacritics including the macron.
If this was a non-facet search, it looks like I could achieve what I want by setting up Collation for a separate copy field and sort by that (I can't set up collation for the field itself because the stored data will be a binary representation of the collation key). However, it looks like this approach isn't possible for facet queries since they can only be sorted by index or count.
Am I overlooking something? Is there some trick to get this working in an environment where I do need to display the value of the "cat" field?
The question is about customizing the index-order of a facet.
Your suggestion is to use Collation. You can do this and the order of your facets will be correct. The problem is that neither CollationField nor ICUCollationField are overriding the indexedToReadable method.
The two classes cannot override indexedToReadable because in general the mapping from word to term is not invertible. But for your case possible you can implemenent a subclass of ICUCollationField which overrides indexedToReadable in a sencefull way.
Your starting point could be TestICUCollationField with
<fieldType name="sort_fr_t" class="solr.ICUCollationField" locale="fr" strength="primary"/>
...
<field name="sort_fr" type="sort_fr_t" indexed="true" stored="true" docValues="true" multiValued="true"/>
as you will see in this case the names of the facet values are very unreadable.

Conditional validation of format or required property in Beanio

I have a requirement to conditionally validate the format or required=true/false based another fields in a beanmapper configuration.
Example:
<stream name="stream1" format="fixedlength" minlength="101" maxlength="101">
<record name="record1" class="a.b.c.SomeClassName">
<field name="updateType" required="true" length="1" regex="A|C" />
<field name="firstName" required=? length="50" format=?/>
<field name="lastName" required=? length="50" format=?/>
</record>
</stream>
Condition scenario 1: for updateType="A", I need firstName to have not null ( not all spaces as this is a fixed length format record) and for updateType="C", firstName must be all blanks.
Condition scenario 2: for firstName=some value, lastName must also have some value (non blank)
How can I achieve this in Beanio? I am using spring-batch 3x for my job execution.
I could not get any BeanIO utility for this, out of the box. The way I am handling this now is performing those conditional validations in the spring batch processor.

how to xpath field before <label for="street" string="Address"/>

i want to xpath "field_name" before <label for="street" string="Address"/>
but i can xpath just label :'(
<xpath expr="//label[#for='street']" position="after">
<field name="field_name"/>
</xpath
Some one please help me and thank you for you time to reading my word
try this, You can give position like after, before, attributes
<xpath expr="//label[#string='Address']" position="before">
<field name="field_name"/>
</xpath>
OR You can use another way like
<label for="street" position="before">
<field name="field_name"/>
<label for="field_name"/>
</label>
For this kinds of problems (where you don't have a name reference), you have to play with paths. Let's say that you have your label in an structure like this:
<form>
<sheet>
<div>
<label string='street'/>
<label string='postal code'/>
<div>
</sheet>
</form>
Now, you need to reach the firs label, so you can do something like this:
<xpath expr='//sheet/div/label[1]' position="after">
<field name="field_name"/>
</xpath>
Explanation:
With the expression, we're calling, in first place, the relative path of the first sheet we have (// are for relative path), so we can reach it anywhere in the code, second the absolute path of that div (/ is for absolute path) and finally, since we have to labels, but we want the second one, we use [1] to get it. This exact path is not always necessary, I am just suggesting it because usually we have multiples divs, but just one sheet, that's why I took it to be the root, but of course you have to adapt this to your own structure. For more information about xpath, you can read https://www.w3schools.com/xml/xpath_syntax.asp

How to use validate-digits-range validation in magento?

Hi Friends I want to validate number range in magento. I also got validation class validate-digits-range. But i don't know to how to pass that minimum and maximum value for that validation.
If anybody know means kindly share that example. Thanks in advance
You should use in text form field like :
... class="required-entry validate-digits-range digits-range-10-20"...
This will validate the value to be between 10 and 20.
See the following example for a range between 1 and 50:
validate-number-range number-range-1-50
<field id="radius" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Delivery radius</label>
<validate>validate-number validate-number-range number-range-1-50</validate>
</field>

Resources