Generate #Indexed annotation using Jaxb or HyperJaxb - annotations

I want to implement lucene based hibernate search in my assignment. For generating domain objects I am using HyperJaxb3.
I want #Indexed annotation to be added during domain object creation using HyperJaxb.
I tried googling for this, but unable to find solutions.
Any pointer in this regard will be of great help.

Annotate plugin is the right answer. See this example.
This is how it looks in schema:
....
xmlns:hs="http://annox.dev.java.net/org.hibernate.search.annotations"
...
<xsd:complexType name="USAddress">
<xsd:sequence>
<xsd:element name="name" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>
<annox:annotate>
<hs:FieldBridge impl="org.jvnet.hyperjaxb3.ejb.tests.annox.Items">
<params>
<hs:Parameter name="foo" value="bar"/>
</params>
</hs:FieldBridge>
</annox:annotate>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="state" type="xsd:string"/>
<xsd:element name="zip" type="xsd:decimal"/>
</xsd:sequence>
<xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>
</xsd:complexType>
You can also use extra binding files (see the example).

Related

Properties allowed in Liquibase - Constraints

I am trying to add a new table in the DB using Liquibase.
I am putting Constraints inside the table definition and have a foreign key in it. Without having an extra addForeignKey code snippet.
So I am trying to use this. But it says onDelete is not allowed in constraints . Its also a little hard to find any documentation related to this. Other properties do get allowed though.
<createTable tableName="relationship_view_person">
<column name="view_id" type="BIGINT">
<constraints nullable="false" foreignKeyName="fk_view_person_reln" referencedTableName="configured_view" referencedColumnNames="view_id" onDelete="CASCADE" />
</column>
<column name="person_id" type="TEXT">
<constraints nullable="false" foreignKeyName="fk_person_view_reln" referencedTableName="persons" referencedColumnNames="person_id" onDelete="CASCADE" />
</column>
</createTable>
I get this error
cvc-complex-type.3.2.2: Attribute 'onDelete' is not allowed to appear in element 'constraints'.
Please checkout this documentation for add column in liquibase. And scroll till you are on Constraints tag section. You will find all the attributes allowed with liquibase constraints tag.
As per the error you are getting for onDelete is not allowed, please try using attribute deleteCascade="true" like below:
<createTable tableName="relationship_view_person">
<column name="view_id" type="BIGINT">
<constraints nullable="false" foreignKeyName="fk_view_person_reln" referencedTableName="configured_view" referencedColumnNames="view_id" deleteCascade="true" />
</column>
<column name="person_id" type="TEXT">
<constraints nullable="false" foreignKeyName="fk_person_view_reln" referencedTableName="persons" referencedColumnNames="person_id" deleteCascade="true" />
</column>
</createTable>
On running updateSQL it will generate the expected SQL query for you (which you can verify before executing it directly on DB):
CREATE TABLE public.relationship_view_person (view_id BIGINT NOT NULL, person_id TEXT NOT NULL, CONSTRAINT fk_view_person_reln FOREIGN KEY (view_id) REFERENCES public.configured_view(view_id) ON DELETE CASCADE, CONSTRAINT fk_person_view_reln FOREIGN KEY (person_id) REFERENCES public.persons(person_id) ON DELETE CASCADE);
Note: onDelete attribute works with addForeignKeyConstraint tag in liquibase. Find documentation for it here.
TL;DR
You said
I am putting Constraints inside the table definition and have a foreign key in it. Without having an extra addForeignKey code snippet.
As exception suggest you are not allow to set unknown element line onDelete with in <constraint> tag, furthermore the set of possible configuration with in <constraint> till the latest version (4.*.*) are as follow.
<!-- Attributes for constraints -->
<xsd:attributeGroup name="constraintsAttributes">
<xsd:attribute name="nullable" type="booleanExp"/>
<xsd:attribute name="primaryKey" type="booleanExp"/>
<xsd:attribute name="primaryKeyName" type="xsd:string"/>
<xsd:attribute name="primaryKeyTablespace" type="xsd:string"/>
<xsd:attribute name="unique" type="booleanExp"/>
<xsd:attribute name="uniqueConstraintName" type="xsd:string"/>
<xsd:attribute name="references" type="xsd:string"/>
<xsd:attribute name="referencedTableName" type="xsd:string"/>
<xsd:attribute name="referencedColumnNames" type="xsd:string"/>
<xsd:attribute name="foreignKeyName" type="xsd:string"/>
<xsd:attribute name="deleteCascade" type="booleanExp"/>
<xsd:attribute name="deferrable" type="booleanExp"/>
<xsd:attribute name="initiallyDeferred" type="booleanExp"/>
<xsd:attribute name="checkConstraint" type="xsd:string"/>
</xsd:attributeGroup>

WSDL contract list occuring with numbers

When I define the fields of a contract in XSD I define a list field with maxOccurs= and minOccurs>0.
Can i declare the XSD in such a way that when the request is received the fields with occurs have occurance number?
e.g.
I hope i make my self clear.
<xsd:complexType name="FieldNameType">
<xsd:sequence>
<xsd:element name="FieldName" type="FieldNameType" minOccurs="1" maxOccurs="8"/>
</xsd:sequence>
</xsd:complexType>
and when the request is send i get something like:
<FieldName_1></FieldName_1>
<FieldName_2></FieldName_2>
<FieldName_3></FieldName_3>
Thanks in advance!
I found a work-around! As i saw i can iterate through the same nodes in an XSLT file.

Trying to create a dynamic temp table (dataset) from a DTD Schema? [OE10.1C]

I am trying to create a dynamic temp table and dataset from an external DTD file. I trying to simplify some xml code POST/GET and take advantage of the READ/WRITE XML functions with datasets.
I referenced the documentation for READ-XMLSCHEMA and it seems to do what I need however, I keep getting errors and can't figure out what I am doing wrong.
Here is a snippet
DEFINE VARIABLE hTable AS HANDLE NO-UNDO.
DEFINE VARIABLE retOK AS LOGICAL NO-UNDO.
DEFINE VARIABLE cSourceType AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFile AS CHARACTER NO-UNDO.
DEFINE VARIABLE lOverrideDefaultMapping AS LOGICAL NO-UNDO.
DEFINE VARIABLE cFieldTypeMapping AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVerifySchemaMode AS CHARACTER NO-UNDO.
CREATE TEMP-TABLE hTable.
ASSIGN
cSourceType = "file"
cFile = "http://xml.cxml.org/schemas/cXML/1.2.025/InvoiceDetail.dtd"
lOverrideDefaultMapping = NO
cFieldTypeMapping = ?
cVerifySchemaMode = ?.
retOK = hTable:READ-XMLSCHEMA (cSourceType,
cFile,
lOverrideDefaultMapping,
cFieldTypeMapping,
cVerifySchemaMode).
Does anyone know how I can achieve this using Openedge 10.1C.
Thanks
Errors that i am receiving...
---------------------------
Error
---------------------------
Error reading XML file 'http://xml.cxml.org/schemas/cXML/1.2.025/InvoiceDetail.dtd'. (13035)
---------------------------
OK
---------------------------
---------------------------
Error
---------------------------
READ-XML encountered an error while parsing the XML Document: FATAL ERROR: file 'http://xml.cxml.org/schemas/cXML/1.2.025/InvoiceDetail.dtd', line '15', column '2', message 'Expected comment or CDATA'. (13064)
---------------------------
OK
---------------------------
I think Progress is looking for an XSD file -- not a DTD. Looking at your link and comparing it to a working XSD file that I use they look nothing alike.
An example of XSD that Progress will like looks like this:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:prodata="urn:schemas-progress-com:xml-prodata:0001">
<xsd:element name="tt_DBId" prodata:proTempTable="true">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="tt_DBIdRow" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="dbidLogName" type="xsd:string" nillable="true" prodata:label="DB Logical Name"/>
<xsd:element name="dbidPhysName" type="xsd:string" nillable="true" prodata:label="DB Physical Name"/>
<xsd:element name="dbidHost" type="xsd:string" nillable="true" prodata:label="DB Host Name"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:unique name="dbidLogName-idx" prodata:primaryIndex="true">
<xsd:selector xpath=".//tt_DBIdRow"/>
<xsd:field xpath="dbidLogName"/>
</xsd:unique>
</xsd:element>
</xsd:schema>
Also, 10.1C isn't going to have the best compatibility. That's a really old release that hasn't seen an update in a long time. A lot of improvements were made in the late 10.2B service packs and OE11.4 or 11.5 should have even better support.

WSDL enumeration restriction with key/value pairs

I'm working on a SOAP webservice which features many inputfields using enumeration restrictions.
These enumerations are much like an HTML select/option setup; I expect a certain value to be returned but the label of that value should be exposed using the WSDL as well.
An example: the client wishes to add an insurance policy regarding his/her house and thus needs to specify the type of building involved.
<xsd:restriction base="xsd:string">
<xsd:enumeration value="00001" />
<xsd:enumeration value="00002" />
<xsd:enumeration value="00003" />
</xsd:restriction>
However, the client does not yet understand what these values 1, 2 and 3 are. So, something like this:
<xsd:restriction base="xsd:string">
<xsd:enumeration value="00001" label="Brick and mortar" />
<xsd:enumeration value="00002" label="Straw" />
<xsd:enumeration value="00003" label="Aircastle" />
</xsd:restriction>
would be great for the client to be used to display these labels to the consumer.
Is there any standard WSDL annotation/syntax for this construction?
Is there any standard WSDL annotation/syntax for this construction?
I'm afraid not. The XML Schema enumeration is used to constrain a value to be within a specified set of possible values. When your client sends you the request, the element with the restriction type will only be allowed to have (in your case) a value of 00001, 00002 or 00003 or it won't be valid.
The restriction only specifies the values, you can't add labels. You could at best add an <annotation> but that would be just documentation. In the client UI, it would be the responsibility of each client to say that 00001 is actually "Brick and mortar" and that 00002 is "Straw" etc.
If you don't want to do that, and instead want to also return labels, then you need a slightly more complex object, maybe something like this:
<option>
<key>00001</key>
<label>Brick and mortar</label>
</option>
You provide a label and you restrict the key with a schema like:
<xsd:simpleType name="ValuesType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="00001" />
<xsd:enumeration value="00002" />
<xsd:enumeration value="00003" />
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="OptionType">
<xsd:sequence>
<xsd:element name="key" type="ValuesType" />
<xsd:element name="label" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
You can return a list of options to the clients and they can present it in the interface with key as value and label as the text of options in <select> inputs, while on the request you will get back the selected value (i.e. the selected key).

JPA one-to-one mapping gives sax parse exception

I'm getting org.xml.sax.SAXParseException's when trying to map a one-to-one relation in JPA
Everything is working fine until I change from
<transient name="testCase"/>
to:
<attributes>
..
<one-to-one name="testCase">
<join-column name="test_case_id"/>
</one-to-one>
..
</attributes>
Gives error:
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'one-to-one'. One of '{"http://java.sun.com/xml/ns/persistence/orm":many-to-many, "http://java.sun.com/xml/ns/persistence/orm":embedded, "http://java.sun.com/xml/ns/persistence/orm":transient}' is expected.
I don't understand what the exception message means. Why is these expected for this?
Your orm.xml was not valid according to it's XML Schema. The problem was that the element 'one-to-one' is part of a sequence, which means that the contained elements MUST respect the defined order.
An abstract of the Schema:
<xsd:complexType name="attributes">
<xsd:sequence>
...
<xsd:element name="basic" .../>
<xsd:element name="version" .../>
<xsd:element name="many-to-one" .../>
<xsd:element name="one-to-many" .../>
<xsd:element name="one-to-one" .../>
<xsd:element name="many-to-many" .../>
...
</xsd:sequence>
</xsd:complexType>
see the whole Schema at enter link description here
I found the problem. I moved the one-to-one section so it was before the many-to-many section. Don't know why this happened. The two sections does not have anything in common.