Querying Multiple Schemas

X-Application Version: 3.1.2
Tamino Version : 3.1.1
Platform :Win2k
WebContainer : Tomcat 3.3
JDK Version : 1.3.1

Hi All,
i have two schemas
schema1 has details - ProjectName,Description.
schema2 - EmployeeName,ProjectName

1) I want to display the list of employees and their projects(concatenated) in a list box while loading the page.

2) When a particular choice is selected the respective project details from the schema1 have to be displayed in a text box below.

The instances for both schemas are created separately.

How can i write queries to this case?

i face the following problems:

1) How to loop thru(or manipulate) a queryresult set which was queried using directcommand.

2) write a query multiple schemas using joins

i have gone thru the topic “Extended Tutorial Using Multiple Schemas” in documentation but i didn’t get any clue for this particular case.

I tried with only jsp tags.

Its really cracking my head.

Hello,

when working with more than one schema, the doctypes of the schemas must be mapped to the collections where the documents of these doctypes are stored. To define this mapping edit the web.xml file of your application (see also chapter ?configuration? of the X-Application documentation).

Now, to your wishes:

1) I want to display the list of employees and their projects(concatenated) in a list box while loading the page.

If I understand you right you want to create a list of employees, e.g.

<BR>Name 				Project<BR>------------------------------------------------------------------------------´-<BR>John Smith 			list box with all projects John Smith works on<BR>Adam Miller			list box with all projects Adam Miller works on<BR>...<BR>


For this page, my propose is a query for employees (directcommand tag or query page) and within the browse tag you use to display the employees add a X-Application select tag. The expression for the ?text? attribute must be dynamically evaluated. Therefore, use the variable mechanism of X-Application.

2) When a particular choice is selected the respective project details from the schema1 have to be displayed in a text box below.


The select box must be part of a HTML form which refers to a page to display the project details. Since you have more than one select box use JavaScript to set the value of the selected project to a hidden parameter.

On the page for displaying the project use a directcommand of type query. The ?arg? attribute of the directcommand must contain the reference to the hidden parameter which contains the id/name/… of the project.

After the directcommand use a browse tag of pagesize One to display the result of the query (the selected project).

This is a roughly description, but I hope, it helps you. If not or my understanding of your application was not correct, send a further post.

Bye,
Christian.

Hello,

i didn’t get ur first solution. I think by mentioning xapplication tag you mean ‘fillselect’ tag, because, i didn’t see any select tag in documentation.

Also, in fillselect tag the ‘text’ attribute is used only for display purpose. can u throw some light on how xapplication variable mechanism can be helpful in dynamically evaluating it?

can we perform join operation on data of two schemas. I didn’t get the explanation given to perform join operation in documentation.Because i want to perform all operation i do in a RDBMS(like joins) on tamino data also.Any help will be highly appreciated.
Is this approach good? else how can be it achieved. If needed i will give the exact situation where i needed to have a join operation.

regards,

Hello,

Christians answer refers to the X-Application version 3.1.3 that is available for download since end of July.
The fillselect tag has been replaced by the select tag (a preview for version 3.1.2 has been posted to the Contribution Forum).
Also with X-Application 3.1.3 a variable concept has been introduced.

Is it possible for you to switch to this new version?

Regards, Harald

Thanks for ur reply,

we are planning to commence a pilot application using x-application this month-end.we were asked to work on 3.1.2.

But I will have to discuss this with my manager.Can we perform complex queries(subqueries,joins) using 3.1.3.

I will be glad to know the extra features 3.1.3 offers than 3.1.2.

Also, is it possible to perform joins using the existing version.

regards,
jag

Hello,

when you look at the ‘information’ area of X-Application, there are the new features of X-Application 3.1.3 listed.

A link to a more detailed pdf-document is also available.

For your question about document join:

A join to get a new document containing information of two documents with different schema is possible if you program this join functionality via plugin. It is not directly supported by X-Application.

However, it is possible to use directcommand of type ‘query’ or ‘read’ to request documents related to a current document instance. Therefore, it may not be necessary to build a new document.

Bye,
Christian.

Hi,
with respect to xapplication 3.1.2,
can u give an example on how to get related records?

let me present a scenario where tools,subtools are schemas
tools-> tool-id,toolname
subtools->subtool-id,subtoolname,parent-tool-id

How can i have a complete list of tools with their respective subtools in a table

we can get list of subtools if a tool is selected
from a select box by using select box as query field.

I tried to get the complete list using nested directcommands but i couldnot get the resultsets of two directcommands simultaneously(i think only one directcommand-query can be used at any given point of time).

can u guide me…

Hello,

to your requirement using X-Application 3.1.2:

list all tools and display the sub-tools for each tool

For the following example I assumed:
1) the schema tools defines a doctype ?tool? consisting of the elements ?tool-id? and ?toolname?.
2) the schema ?subtools? defines a doctype tool consisting of the elements ?subtoolname? and ?parent-tool-id?

If this is not the case please send me schema.

The following example may contain typos, but the main idea should be clear:

The first directcommand loads all ?tool? documents within the set ?toolsList?.
The following browse iterates through this set.
The nested directcommand loads all ?subtool? documents related to the currently iterated ?tool? document. It creates the document set ?subtoolsList?. This set is created for each iteration.
The nested browse iterates the sub-tools list.

<BR><bdm:module id="xxx"><BR><BR><bdm:form><BR>  <bdm:directcommand type="query" queryparm=".~='*'" schema="tools" document="toolsList"/><BR></bdm:form><BR><BR><table><BR><tr><BR>  <td>tool name</td><BR>  <td>sub tools</td><BR></tr><BR><BR><bdm:browse document="toolsList" pagesize="1000" moduleid="xxx"><BR><tr><BR>  <td><bdm:display select"/tool/toolname"/></td><BR><BR>  <td><BR>    <table><BR>      <tr><BR>        <td>sub-tool name</td><BR>      </tr> <BR><BR>      <bdm:directcommand type="query" queryparm="USEBODY" schema="subtools" document="subtoolsList"><BR>        ./parent-tool-id='<bdm:form document="toolsList"><bdm:display select="tool/tool-id"/></bdm:form>'<BR>      </bdm:directcommand><BR><BR>      <bdm:browse document="subtoolsList" pagesize="1000" moduleid="xxx"><BR>      <tr><BR>        <td><bdm:display select="/subtool/subtoolname</td><BR>      </tr><BR>      </bdm:browse><BR>    </table><BR></td><BR></tr><BR></bdm:browse><BR><BR></table><BR><BR></bdm:module><BR>



Bye,
Christian.

Thanks christian,
I got it.

By reading the documentation i thought that the “document” parameter has to be used if the directcommand is used to search on it. so i was wondering how to initialize a document with a resultset.

Now its clear.
One suggestion: The documentation is incomplete. It gives a particular case rather than a general case to cover all scenarios.Even the explanation of concepts doesn’t cover whole topic.

Without you and your colleagues’ help its difficult to get thru the documentation.

Finally Thanks for ur team’s prompt replies.

Regards,
jag

Hello,


Thanks for the hint. I will check the documentation of 3.1.3. If it also does not clearly describe the meaning of the document attribute of the directcommand tag, we should improve this for the next version of X-Application and post a general hint to the community.

Bye,
Christian.