Dependency Field validation in Camel? - apache-camel

Apache camel bean validation:
I have one field dependent on another can some one help me how to Validate e.g. If manufacturer field data is SPECIFIC then licensePlate field is mandatory.
<?xml version="1.0" encoding="UTF-8"?>
<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
<default-package>org.apache.camel.component.bean.validator</default-package>
<bean class="CarWithoutAnnotations" ignore-annotations="true">
<field name="manufacturer">
<constraint annotation="javax.validation.constraints.NotNull" />
</field>
<field name="licensePlate">
<constraint annotation="javax.validation.constraints.NotNull" />
</field>
</bean>
</constraint-mappings>

Please use org.hibernate.validator.constraints.ScriptAssert for cross field validation.

Related

Composite index in datastore-index.xml not created

Here is my datastore-index file:
<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes autoGenerate="true">
<datastore-index kind="Stock" ancestor="false" source="manual">
<property name="code" direction="asc" />
<property name="endTime" direction="asc" />
</datastore-index>
</datastore-indexes>
The index entry was created exactly as suggested by App Engine in error log.
I put the index file in folder webapp/WEB-INF.
Despite all my efforts, no index were necer displayed on the Datastore index page and when I query I get the same error message: no matching index found.
Could you help me?

create a new file from payload in wso2

I am new to wso2 and working on a few POCs where i have to create a file at some location , i have looked into all vfs examples where there is always a file processed and written to a new location.
What i want to achieve is write a new file to a directory by the content i receive in a sequence.
For my requirement process i have exposed a REST service and it calls this sequence.
The sequence configuration is as follows.
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="FileWriteSequence">
<clone>
<target>
<sequence>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<property name="transport.vfs.ReplyFileName" value="myOutputFile.txt" scope="transport" type="STRING"/>
<send>
<endpoint name="FileEpr">
<address uri="vfs:file://D:/Tools"/>
</endpoint>
</send>
</sequence>
</target>
</clone>
This sequence creates a file from the latest message from the REST resource but the file name is always the project name.
Whatever i try it doesnt change.
I have tried giving other proxy parameters shown below as property above my sequence as well .Instead of paramters i passed them above the property <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
Namely :-
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file://D:/Tools</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file://D:/backup</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
Still no progress.
Can anyone help me here?
Regards,
Rahul.
In case anyone wants to know i have made a workaround for this i called a proxy service from my rest resource and it worked .
In my resource i called endpoint like this
<send>
<endpoint key="FileProxyEndPt"/>
</send>
Then i created a proxy service as follows
<proxy xmlns="http://ws.apache.org/ns/synapse" name="FileWriteProxy"
transports="http https vfs" startOnLoad="true" trace="enable">
<target>
<inSequence>
<clone>
<target sequence="FileWriteSequence" />
</clone>
</inSequence>
<outSequence />
<faultSequence />
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file://D:/Tools</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file://D:/backup</parameter>
<parameter name="transport.vfs.ContentType">text/plain; charset=ISO-8859-1</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
This way it worked it but never worked exactly in a resource.So had to take a longer route , hope somebody provides a solution which can be implemented directly.

solr 4.4 multiple datasource connection

in my db-data-config.xml i have configured two datasource, each with his parameter name,
for example:
<dataSource name="test1"
type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/firstdb"
user="username1"
password="psw1"/>
<dataSource name="test2"
type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/seconddb"
user="username2"
password="psw2"/>
<document name="content">
<entity name="news" datasource="test1" query="select...">
<field column="OTYPE_ID" name="otypeID" />
<field column="NWS_ID" name="cntID" />
....
</entity>
<entity name="news_update" datasource="test2" query="select...">
<field column="OTYPE_ID" name="otypeID" />
<field column="NWS_ID" name="cntID" />
....
</entity>
</document>
</dataConfig>
but when in solr from dataimport i execute the second entity-name-query it launch an exception:
"Table 'firstdb.secondTable' doesn't exist\n\tat"
could someone help me? thank you in advance
A think that your query for news_update is wrong. You must have an error on name of table.
I'm pretty sure this question showed up on the solr-user mailing list. The answer given there was that you are using datasource in your entity tags instead of dataSource. It's case sensitive. If I recall the thread correctly, changing this solved your problem.

How to include another XML file from within a Solr schema.xml?

I've got a number of different cores, each with its own schema, but they all share the same field types. I'd like to remove the duplication of the field type declarations and do something like this in my schema.xml files:
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="foo" version="1.5">
<fields>
<field name="_version_" ...
<field name="id" ...
...
</fields>
<uniqueKey>id</uniqueKey>
<include "/path/to/field_types.xml">
</schema>
I don't see any mechanism in the docs to accomplish this however. I found one post referring to this:
<xi:include href="/path/to/field_types.xml" />
But that gives me a launch error: The prefix "xi" for element "xi:include" is not bound.
Anybody have an idea how to perform this type of raw include?
From this past Solr Issue - SOLR-3087, it looks like <xi:include> is the correct syntax, you just need to include the xi namespace reference inline.
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="foo" version="1.5">
<fields>
<field name="_version_" ...
<field name="id" ...
...
</fields>
<uniqueKey>id</uniqueKey>
<xi:include href="/path/to/field_types.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</schema>
Another clean solution at this problem is add resources as external entities:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE schema
[
<!ENTITY schemafieldtypes SYSTEM "schemafieldtypes.xml">
]>
then, in the xml, you can add everywhere this:
&schemafieldtypes;

Example Databases

I am new to oracle. I wanted a huge sample database ( with a million tuples ) . I couldn't find any using google.
I'am using oracle 10g..
You guys know anywhere from where i can download?
Thank you ..
I don't know of any "ready-made" sample database of that size
As far as I can see, you have two options:
Use PolePosition to create a sample database. It's originally a benchmark frameworks but comes with it's own database schema and the necessary tools to generate a large database (you can define which size)
Use a test data generator like Benerator to completely create your test data from scratch. It seems a bit intimidating at first, but it's a really powerful tool. It also has generators to create meaningful names, zip codes and so on. So you'll get test data that "looks" real and doesn't contain gibberish.
The following benerator script generates a million rows for the table items and for each row in items it generates 10 rows in item_details (so you wind up with 1 million and 10 million rows)
<?xml version="1.0" encoding="iso-8859-1"?>
<setup xmlns="http://databene.org/benerator/0.7.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://databene.org/benerator/0.7.0 http://databene.org/benerator-0.7.0.xsd">
<import defaults="true"/>
<import platforms="csv"/>
<generate type="items" count="1000000">
<consumer class="org.databene.platform.csv.CSVEntityExporter">
<property name="uri" value="items.csv"/>
<property name="separator" value="|"/>
<property name="encoding" value="ISO-8859-1"/>
</consumer>
<id name="item_id" type="big_integer" generator="IncrementalIdGenerator"/>
<attribute name="item_name" type="string" pattern="[A-Z][a-z ]{6,25}"/>
<generate type="item_details" count="10">
<consumer class="org.databene.platform.csv.CSVEntityExporter">
<property name="uri" value="item_details.csv"/>
<property name="separator" value="|"/>
<property name="encoding" value="ISO-8859-1"/>
</consumer>
<id name="item_detail_id" type="big_integer" generator="IncrementalIdGenerator"/>
<attribute name="item_id" script="items.item_id"/>
<attribute name="sort_sequence" type="int" />
</generate>
</generate>
</setup>
If you want more "realistic" names, have a look a the following script which generates products with valid EAN Codes and some "normal" looking manufacturer names:
<?xml version="1.0" encoding="iso-8859-1"?>
<setup xmlns="http://databene.org/benerator/0.7.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://databene.org/benerator/0.7.0 http://databene.org/benerator-0.7.0.xsd">
<import platforms="csv"/>
<import domains="product"/>
<import domains="organization" />
<setting name="product_count" value="100000"/>
<generate type="product" count="{product_count}">
<consumer class="CSVEntityExporter">
<property name="uri" value="products.csv" />
<property name="separator" value=","/>
</consumer>
<id name="id" type="long"/>
<attribute name="ean_code" unique="true" generator="EANGenerator"/>
<attribute name="product_code" unique="true" pattern="[A-Z]{3}[0-9]{6}"/>
<variable name="cust" generator="CompanyNameGenerator" dataset="DE" locale="de_DE"/>
<attribute name="manufacturer_name" source="cust.shortName"/>
</generate>
</setup>
Once you have created the data files, you can use SQL*Loader to import them into the database.
This approach has the advantage that you have full control over the tables in your test database and you can tailor them to whatever you are trying to do with it.

Resources