Manage this page

Display

Feedback

Others

Previous questions

You can post questions related to any of the following technologies

Java
J2EE
XML
Dotnet
Programming
SQL
Html
CSS

GQ - Friday, November 18, 2005 15:31:15

Class Hierarchy Properties

I was wondering if there was any updated document summarizing the different classes available in aspire and what they can do.

docs/aspire_annotated_app_properties_file.html is a good file unfortunately it's dated.

Satya - Friday, November 18, 2005 10:35:25 AM

Thanks for the feedback

Hi, I have thought about multiple times presenting this information. But I could not come up with a reasonable quick way of doing it. I am continuing to think about it and probably I will put something up.

The annotated property file is quite old. So I will make an attempt to publish something on this sometime next week.

Everytime I develop something new, I usually post an article about how to use it in one of the "howto" folders on the left hand side. You can use this list to gaze what is possible with aspire.

To know the latest properties file, in my release notes, there is a login application that I have uploaded a couple of months ago. This application has an aspire.properties file that is more recent.

Nevertheless if you have any specific questions post it here, I will try to answer them fairly quickly.

GQ - Monday, November 28, 2005 08:03:13

Some sample code pls

is it possible to structure a loop tag so that it acts like a FOR-NEXT loop?

is it also possible from a replacement tag to call a function with parameters?

or to embed a key within a replacement tag?

eg {{myfunction({{replacementtagparam.key}})}}

thanks

Satya - Monday, November 28, 2005 10:11:29 AM

You can use jsps instead of aspire tags if you find them limited ...

If you need complex logic on the screen you can use JSPs instead. Look in the howto section. You will see an article on how to use JSPs with aspire.

I am not clear on for-next. Call me on my cell 904-662-5427, as it might be easier to discuss this on the phone.

I believe I do have a facility where functions can be invoked on replacements. Let me look through my docs and I will post another item here later today.

Satya - Monday, November 28, 2005 10:17:58 AM

Here is a document on using function expressions

How to use function expressions

Satya - Monday, November 28, 2005 10:49:11 AM

Nevertheless ...

Nevertheless try using JSPs if you can as they offer more possibilities for complex pages.

GQ - Monday, December 26, 2005 2:16:05 AM

Current Record, Move Previous and Sizeof IHDS

I went the JSP route. Following the examples you gave, I used IHDS type. However, I cant figure out how to access the current record, move to previous (or to particular record) or size of the ihds data returned.

OR am i using the wrong type?

I am currently using randomtablehandler7 in the properties.

thanks

GQ - Monday, December 26, 2005 6:19:34 AM

...continued...

by sizeof, i meant number of rows returned. I notice there is a function written related to this... but i dont know how to access it.

Satya - Tuesday, December 27, 2005 9:43:12 AM

You can use the following article for working with ihds

How to use ihds

Satya - Tuesday, December 27, 2005 9:50:08 AM

RandomTableHandler7 is the right one to use

This class implements

public interface ILoopRandomIterator extends ILoopForwardIterator
{
   public boolean moveToFirstRow();
   public boolean moveToRow(int rownum);
   public int getNumberOfRows();
   public boolean isRowAvailable();
} 

When you get the "ihds" for that spelcific loop name, you can cast it to ILoopRandomIterator and use the getNumberOfRows() on that interface.

Please note that when you use RandomHandler you are increasing the load on the memory. If your intent is to walk forward, you don't want to use the Random one. It is there as a design choice but use it sparingly. If you have questions on that let me know.

Also in the feedback precede your comment paragraphs with a "p". You don't have to close the "p". Just do the view source for these comments and you will know what I mean.

Satya - Tuesday, December 27, 2005 2:07:21 PM

See the following url how I use aspire with jsps

Use this login application as a template for your applications

GQ - Monday, January 02, 2006 7:18:27 AM

Current Record Pointer?

Thanks. The examples were very helpful. How do I access the current record pointer though? (assuming there is an interface for it)

Satya - Monday, January 02, 2006 11:53:43 AM

The current record is implicit

See the following api

public interface ILoopForwardIterator
{
   /**
    * getValue from the current row matching the key
    */
   public String getValue(final String key);

   public void moveToFirst() throws DataException;

   public void moveToNext() throws DataException;

   public boolean isAtTheEnd() throws DataException;
}

ihds implements one of these. when moveToNext() is called and pointing to a specific row, the "getValue" will give the value for a given key on that record. That record is not directly exposed. You can use the IMetaData on the ihds to know what the column names or keys are for that row.

Or if you want a finer control you can use the "IDataCollection" interface from relational data access side of the fence.

Let me know what you are trying to do at a higher level. May be I will be able to suggest something.

GQ - Tuesday, January 03, 2006 9:52:51 AM

Row Number or Current Record Pointer

I was hoping that the row number of the current record was exposed. So i could just skip maintaining my own recordnumber variable and just do a call like:

recordnumber()-1 or recordnumber()+1

Of course, it is possible to do it another way just as you showed in one of your examples. It just seemed cleaner to just access the rownumber counter which seems internal to your code?

Satya - Tuesday, January 03, 2006 10:28:02 AM

I see your point

I might consider adding that in the future. For now as you may have guessed you may have to keep a local variable like "i". I actually have a pluggable class name to the ihds that can add columns on the fly and also aggregated values. But on the down side you have to write that class in java.

GQ - Tuesday, January 10, 2006 7:57:08 PM

JSP code for property change

I'm trying to do something like this... pageData.setAttribute("request.rtpageForm.dataloop.query_request.stmt","select * from phppos.sales"); in my JSP code. Can you show me how to do this properly?

I put values in the properties file...then midway i want to change the value and override the values read from the maindata section

Satya - Tuesday, January 10, 2006 9:37:13 AM

Are you saying ...

Are you saying depending on what is read in the main data, you want to change the sql executed for a particular loop?

There are a couple of ways you can go about it

On the previous page that is passing control to this display url, you could have retrived the main data values (essentially moving your main select to the previous page). And then in javascript redirect it to different display urls one for each variation.

Or you can use the whole select statement for your phppos.sales a substitution varialbe and use an if part in the maindata executor to insert sql statement dynamically. I personally think option 1 is cleaner.

Or you can do option 1 on the server side instead of in the java script and redirect the page based on an if part again.

Are you willing to write any java code on the server side? do you know how to write parts? Let me know if you need some help. If that is not the case your option 1 java script is a good bet.

Although the parts in aspire gives you some control on the execution logic, the real power is writing specialized java parts when needed.

Let me know ..

Satya - Tuesday, January 10, 2006 10:35:22 AM

Or you can also do this in the controller jsp ..

In this approach

1. You will let the main data execute and load up your page data

2. Let the jsp get control of that data

3. In the jsp make the decission as to which page you want to go to

4. Each page will be a separate url with its own data set

5. In this scernario your controller jsp page will just be a decission maker

6. You can use the request.redriect and go to the display url you want.

This is really option 3 in the above scenario.

GQ - Friday, January 13, 2006 9:59:35 AM

scenario for property change

maybe the following pseudo code scenario may make the question more defined:

 
         --for(i=0;i lt X;i ++ ) {
           --read from data source( newsqlstatement[i] ) 
                   --select   
             --for(z=0;z lt XX;z ++ ) {
                   --options
             }
                   -- end select
         }

I'm really hoping there was a way to use JSP code to overwrite/override the data/properties written within the properties file so that i can change the sqlstatement on the same page. Unless there is more capability in aspire i still do not know.. from my understanding properties files have to be written during design time and may not add additional loops on the fly..

or is it possible to add/define new loops on the fly?

Satya - Friday, January 13, 2006 3:27:37 PM

I will answer this tomorrow ..

I am a bit busy today. Let me think about this. I will let you know in a day or two

Satya - Friday, January 13, 2006 5:02:16 PM

Have you looked at this

How to retrieve tree structures from database

You can try using a substitution parameter for the sql statement.

Satya - Friday, January 13, 2006 5:07:40 PM

At the moment you can not define loops on the fly ..

The property files are static definitions. It is possible to change the values of those static definitions using substitutions at run time.

Satya - Friday, January 13, 2006 5:13:08 PM

If the data doesn't fit into a well known pattern you can always do this ..

Aspire's ihds is implemented by the pre defined aspire class as below

blogsURL=aspire:\\reports\\blogs\\blogs.html
blogsURL.formHandlerName=BUFH
Request.BUFH.form_handler.class_request.classname\
com.ai.htmlgen.DBHashTableFormHandler1

If the data gets too complicated you can do this

Request.BUFH.form_handler.class_request.classname\
com.MyPageDataGenerator

Where MyClass is derived from an AbstractPart and returns a java object like MyPageData. Inside the MyPageDataGenerator you can use the low level Aspire relational data access apis to construct your object.

And on the JSP page when you retrieve your data you will get this object instead. But you will have to write this java class though.

Satya - Friday, January 13, 2006 5:57:37 PM

Let me know if you need sample code or examples for any of this ..

Let me know if you need sample code or examples for any of this. I am hoping the tree structure I have pointed out might work for you. You may have to use a multi-exec for constructing your sql dynamically.

GQ - Saturday, January 14, 2006 8:58:42 AM

Substitution

Substitution is more similar to what i have in mind. As i understand it, data/keys used for the substitution is stored in some kind of hash table or object type (or maybe ihds - not too sure) The values in this data/key table can be retrieved using getValue().

Somewhere there is a handler that parses URL data into this table. The maindata loop also adds data into this key table.

Therefore, i was thinking if it was possible to change the values in this hash table and cause a data refresh/requery. Is it possible for aspire to do requery/data refresh from within JSP?

Satya - Saturday, January 14, 2006 11:24:43 AM

I am still somewhat unclear ...

The main data belonging to an ihds is a set of key value pairs maintained in a hash table. All key values from url are retrieved and stored here. All mainline sql statements are executed and their key values are also stored in the same hash table. key/values from the session are also stored in this table. So the "getValue" retrieves values from url, session, sql, and also application level configuration file.

Aspire has no mechanism to restart a query automatically.

..But aspire will use values from the main line to execute subsequest selects. Which means the following is possible

#basics
blogsURL=/reports/blogs/blogs.jsp
blogsURL.transformType=JSP
request.blogsURL.transform.classname=com.ai.jsp.JSPTransform
blogsURL.formHandlerName=BUFH

#Data definition
Request.BUFH.form_handler.class_request.classname=\
com.ai.htmlgen.DBHashTableFormHandler1

#main data
request.BUFH.maindatarequest.classname=com.ai.db.DBRequestExecutor2
request.BUFH.maindatarequest.db=reportsDB
request.BUFH.maindatarequest.stmt=\
select * from some table

#Suppose this maindata returns an sql statement
#in a variable called somevar-select-statement
#you can use that in a subsequent loop
#or you can return a table name and use that table name 
#in a substitution

#the loop that uses the whole select
request.BUFH.publicitemsloop.class_request.className=\
com.ai.htmlgen.GenericTableHandler6

request.BUFH.publicitemsloop.query_request.className=\
com.ai.db.DBRequestExecutor2

request.BUFH.publicitemsloop.query_request.db=reportsDB
request.BUFH.publicitemsloop.query_request.stmt=\
{somevar-select-statement}


#the loop that uses a table name
request.BUFH.publicitemsloop2.class_request.className=\
com.ai.htmlgen.GenericTableHandler6

request.BUFH.publicitemsloop2.query_request.className=\
com.ai.db.DBRequestExecutor2

request.BUFH.publicitemsloop2.query_request.db=reportsDB
request.BUFH.publicitemsloop2.query_request.stmt=\
select * from {somevar-table-name}

Satya - Saturday, January 14, 2006 11:30:51 AM

Is this what you are looking for?

Earlier you seem to indicate you have two for loops. That seem to imply loops inside loops. Same substitution trick applies to inside loops as well.

You can do the following to make me understand the problem a bit more. You can create a sample xml document representing your typical data you would like to retrieve and post that sample here. You can "(" for your "lt" signs and "gt" signs.

That xml structure will tell me what your data definition will look like. Then I may be able to sugest an appropriate properties definition to retrive that kind of a structured data.

Do remember that aspire is an open framework. You can override almost all its behavior with java. But before I suggest something let me see if we can not solve the problems with existing mechanisms.

Satya - Saturday, January 14, 2006 12:04:12 PM

On a side note, see if the following simplifies your syntax

Slightly streamlined syntax for jsp pages

Satya - Saturday, January 14, 2006 3:29:19 PM

You can always get an ihds in your java code any time ..

You can do this even in your jsp. Imagine you have defined an ihds in your config file as follows

request.MyData.classname=com.ai.htmlgen.DBHashTableFormHandler1
...rest of the main data and loop data definitions

Then you can do the following on your jsp page or in any java code


ihds mydata = null;
try
{
   Hashtable args = new Hashtable();
   args.put("lowercased-key1","hello");
   args.put("lowercased-key2","hello2");
   
   mydata = (ihds)AppObjects.getObject("MyData",args);
   //use mydata however you choose
}
finally
{
   if (mydata != null)
   {
      mydata.close();
   }   
}

Ofcourse you will have to import the "AppObjects" class into the jsp page.

But hopefully your need can be met by other means.

GQ - Monday, January 16, 2006 9:30:16 AM

Multiple SQL loop

Thanks for all the feedback. I was trying to do something like shown below:


testpageURL=/jsps/testpage.jsp
testpageURL.transformType=JSP
testpageURL.transform.className=com.ai.jsp.JSPTransform
testpageURL.dataRequestName=testpageForm
request.testpageForm.className=com.ai.htmlgen.DBHashTableFormHandler1
request.testpageForm.mainDataRequest.className = com.ai.db.DBRequestExecutor2
request.testpageForm.mainDataRequest.db =kendev
request.testpageForm.mainDataRequest.stmt =select * from projects

request.testpageForm.sqlloop.class_request.className=com.ai.htmlgen.RandomTableHandler7
request.testpageForm.sqlloop.query_request.className=com.ai.db.DBRequestExecutor2
request.testpageForm.sqlloop.query_request.db=kendev
request.testpageForm.sqlloop.query_request.stmt=select onesqlstatement from sqlstatements

request.testpageForm.dbloop.class_request.className=com.ai.htmlgen.RandomTableHandler7
request.testpageForm.dbloop.query_request.className=com.ai.db.DBRequestExecutor2
request.testpageForm.dbloop.query_request.db=kendev
request.testpageForm.dbloop.query_request.stmt={onesqlstatement}

where the number of sqlstatements is determined by the input from sqlstatements table. Also where dbloop is a loop within sqlloop. I guess within the aspire framework this might not be possible.

As you may guess from the property declaration above, I am actually trying to create a horizontal component from the dbloop. I was hoping to change the values of the dbloop stmt and requery. (and still stay within the aspire framework)

Satya - Monday, January 16, 2006 12:25:07 PM

It is possible to set the "dbloop" as a child of the "sqlloop"

It is possible to set the "dbloop" as a child of the "sqlloop". Will that solve the problem? In such a case for each row of "sqlloop" you will have 'n' rows returend by the "dbloop"?

Or if you want a finer control you can declare the "dbloop" in its own "ihds" definition and invoke that ihds programmatically as shown above.

satya - Monday, January 16, 2006 12:48:43 PM

web site is going through some changes ..

web site is facing some issues today. If you have problems posting try it in a day or two. or you can email me at satya at activeintellect.com. Sorry for the inconvenience.

Satya - Monday, January 16, 2006 1:53:09 PM

Here is how you define the parent child relationships for the above properties

testpageURL=/jsps/testpage.jsp
testpageURL.transformType=JSP
testpageURL.transform.className=com.ai.jsp.JSPTransform
testpageURL.dataRequestName=testpageForm

#main data
request.testpageForm.className=com.ai.htmlgen.DBHashTableFormHandler1
request.testpageForm.mainDataRequest.className = com.ai.db.DBRequestExecutor2
request.testpageForm.mainDataRequest.db =kendev
request.testpageForm.mainDataRequest.stmt =select * from projects

#a child of main data 
request.testpageForm.sqlloop.class_request.className=com.ai.htmlgen.RandomTableHandler7
request.testpageForm.sqlloop.query_request.className=com.ai.db.DBRequestExecutor2
request.testpageForm.sqlloop.query_request.db=kendev
request.testpageForm.sqlloop.query_request.stmt=select onesqlstatement from sqlstatements
request.testpageForm.sqlloop.loopNames=dbloop

#a child of sqlloop
request.testpageForm.dbloop.class_request.className=com.ai.htmlgen.RandomTableHandler7
request.testpageForm.dbloop.query_request.className=com.ai.db.DBRequestExecutor2
request.testpageForm.dbloop.query_request.db=kendev
request.testpageForm.dbloop.query_request.stmt={onesqlstatement}

See the sqlloop has a "loopnames" property pointing to the child loop.

Satya - Monday, January 16, 2006 2:08:33 PM

Small correction to the above ..

Sorry I made a small booboo. The child loop definitions should read

#a child of sqlloop
request.dbloop.class_request.className=com.ai.htmlgen.RandomTableHandler7
request.dbloop.query_request.className=com.ai.db.DBRequestExecutor2
request.dbloop.query_request.db=kendev
request.dbloop.query_request.stmt={onesqlstatement}

Notice how the child loop name (only for the child loops) is disconnected from the form name and stands by itself

GQ - Thursday, January 19, 2006 5:50:39 PM

EJBs as datasource

Using JSP/Aspire on tomcat, I am hoping to get data from an EJB container. I read from the docs about deploying aspire in an EJB container, but what about a FileReader/DBRequestExecutor replacement to stuff EJB entity data into an IHDS?

Perhaps something similar to this scenario: http://www.onjava.com/pub/a/onjava/2003/02/12/ejb_tomcat.html?page=1

I was wondering if i could see a sample of how this would work in aspire like in the scenario below?


 request.dbloop.class_request.className=com.ai.htmlgen.RandomTableHandler7
 request.dbloop.query_request.className=com.ai.db.EJB_Executor2
 request.dbloop.query_request.db=bean_name

Satya - Thursday, January 19, 2006 7:55:34 AM

Very easy to write one, but ..

I am glad you are able to conclude that such a thing is possible. And you are right. But I don't have the code written for it. I can send you a sample or psuedo code for it. Let me know if you would like to do it.

Couple of caveats. Most likely the session bean will return an object or a collection of objects. The key is how much control you have over the session bean to return data that is easily convertible to an ihds.

If the data that is returned falls into an idea of rows and columns then it would be pretty straight forward.

If it is objects and nested objects then you have to do some work using reflection to convert an object to an equivalent ihds.

The other option is to slightly extend the ihds so that it can return an object representation for a given key (not just a string). This approach can directly pass through the session bean object.

The above approach should work for entity beans as well.

Has the above loop idea worked for you?

Satya - Thursday, January 19, 2006 8:08:50 AM

I will post some sample code for creating an ihds and return

Weather it is ejb or not, it will be useful to see some sample code for constructing an ihds. I will post this sometime later today

GQ - Friday, January 20, 2006 12:53:00 PM

Rows and Columns EJB

I think it is safe to assume some kind of row/column for the entity bean. Example code would really be great!

While on topic of ihds extension, an extension to allow you to pass a string/primarykey to the ihds and return the row its at would really be useful in the future. Currently, i work around this by iterating and searching the whole ihds. Of course, one could presort the data and use a search algorithm. Still, it would make a useful feature.

The sample loop code you showed me is exactly what i need! I will test it out in the coming week.

Satya - Friday, January 20, 2006 10:55:30 AM

Take a look at this sample code ..

How to add data retrieval parts

Although I haven't put EJB details in there, as long as you know how ejbs work, you should be able to tailr your part...

Satya - Friday, January 20, 2006 11:01:58 AM

For specialized needs ..

If you are processing the ihds rows and columns other than just painting them, you may want to think of writing a java class and pass that java class the "ihds" and have it do your specialized processing.

Do you use any ide for java?

GQ - Sunday, January 22, 2006 9:21:22 PM

IDE for java

thanks for the sample code, i will see if i can get it tailor fit for EJB's.

no, i dont use any ide for java. if you can recommend any lite weight ones, it would be good. I find eclipse rather heavy.

Satya - Monday, January 23, 2006 12:58:46 PM

How do you compile your java files

Just curious, how do you compile ejb related stuff or your java files ..?

GQ - Wednesday, January 25, 2006 6:45:02 PM

JAVA compiler

I use command line with javac and ant.

GQ - Wednesday, January 25, 2006 9:15:35 PM

Document Typo?

Is there a document typo in this page: url=DisplayNoteMPURL&reportId=603&ownerUserId=aspire

is there a PreTranslateArgsMultiRequestExecutor? or shouldit be DBPreTranslateArgsMultiRequestExecutor?

Satya - Wednesday, January 25, 2006 8:40:19 AM

I don't see anything wrong with the url ...

I type the following in a browser

http://72.242.78.151/akc/display?url=DisplayNoteMPURL&reportId=603&ownerUserId=aspire

And that seem to work. Here is the link with that url

Click here to see that document

I usually skip the absolute address if I could when not needed. The following redirector works for the same url as well

http://www.activeintellect.com/akc/go.html?url=DisplayNoteMPURL&reportId=603&ownerUserId=aspire

This url is there if I were to change the akc url to a different web server. I know I should be getting a proper domain name. Just time frames.

Did I answer your question?

Satya - Wednesday, January 25, 2006 8:43:54 AM

Pre and DBPre ...

There are both parts in aspire. The DBPre .. is the database version of PreTran.. The DBPre is aware of connections and does the commits and rolebacks. The regular Pre .. is used when you don't have any need for database operations.

I mostly use DBPre .. as most of the times there is database access. If a dbrequestexecutor is wrapped in a DBPre .. then it won't try to get its own connection but use the one obtained by DBPre ..

GQ - Thursday, January 26, 2006 11:57:47 AM

Substitute Key

Thanks. The difference between DBPre... and PreTra.. is clearer now. I was using PreTra... from one of the examples in my database connection.

I know you have a parts example for generic updates with attributes but...

In a webpage one can do subsitutekey(key's key) - but can one call this function from the properties page?? I was hoping to do the following:

select "set keyfld={keyfldval} " as updateclause

request.requestname.stmt=call substituteKey({updateclause})

GQ - Thursday, January 26, 2006 12:12:59 PM

Substitute Key ..contd...

or maybe:

select "set keyfld={keyfldval} " as updateclause

request.requestname.stmt={{substituteKey(updateclause)}}

Satya - Thursday, January 26, 2006 1:43:35 PM

I am a bit confused .. can you elaborate

The following is quite possible

request.rn.stmt=update something set col1={somekey}

Or do you have some kind of recursion?

GQ - Friday, January 27, 2006 10:58:59 AM

Value of a key's key

yes, i was hoping to resolve it the way you resolve substitute key...in some way it is recursive. substitutekey is a function you provide for webpage transforms...i was hoping to access this same function in the properties page.

so the value from a previous query might be keyfldval={srcfld_one} or maybe keyfldval={srcfld_two}

select "set keyfld={keyfldval} " as updateclause request.requestname.stmt=update something {{substituteKey(updateclause)}}

OR could you do a similar thing with multipart update requests like you showed me in the nested loops?

Satya - Friday, January 27, 2006 12:00:48 PM

I am still thinking ..

Let me think this through, I will let you know later today ..

Satya - Friday, January 27, 2006 2:28:16 PM

See if the following will fix the issue

How to use substitutionpart and recursivesubstituionpart

I have added the recursivesubstitutionpart today. If you want I can give you a new build. Or just compile that one class and using ant and drop the jar file in web-inf/lib.

or I can upload the jar file sometime this weekend.

GQ - Saturday, January 28, 2006 12:46:54 PM

Build 22.2

Thanks this is great!

I have build 22.1 but you mention a build 22.2. Is this build 22.2 available already? I cant seem to find the download for it?

Satya - Saturday, January 28, 2006 8:21:51 AM

I will drop a new build today ..

I may not have put the build 22.2 out there yet. I will put the one with the recursive part as build 22.3. Look for it t'row as I will sure drop it today.

But please note that I haven't tested this part. So when you use it and if you have errors let me know I will test it here at that time. This is a simple part. Should work as you can tell from the source code I have posted.

Satya - Saturday, January 28, 2006 9:18:56 AM

Build 22.3

The new build is being uploaded. It should be there in the next 30 mins (really slow connection).

Release notes for build 22.3

Satya - Saturday, January 28, 2006 10:26:27 AM

Upload is complete

Check it now. the build should be up there now.

GQ - Friday, March 31, 2006 6:11:52 PM

Index instead of Associative Name

Hi!

Still working on my aspire project... Is there any way of using index values instead of the associative name of a variable in aspire (in the html template)? or can this only be done jsp?

e.g. instead of {{columnname}} we might have {{somefunc(indexval)}}

Satya - Friday, March 31, 2006 6:16:25 PM

Currently no..

On the aspire template I certainly don't have the capability. But I have to check if you are using "ihds" if ihds allows you to access these values by index. It is quite simple to add for me. I will check and let you know t'row

Satya - Friday, March 31, 2006 6:29:18 PM

Either way let me check and let you know t'row

May be there is a way to write a function. I will let you know.

GQ - Saturday, April 01, 2006 08:11:38

Values by Index

I normally use IHDS. However, I would also like to know how to do it via a function.

Using the foreach part might work for me, but I dont know how to use it in the html templates nor JSP. Some samples would be nice.

Thanks

Satya - Tuesday, April 04, 2006 6:54:18 PM

Sorry for the delay on this ...

I have been a bit busy the last few days. Currently the functions only receive a coceptual "dictionary" of values representing one row. This dictionary is not position dependent.

I will look some more later this week and let you know.

Could you explain your thoughts a bit more what this will buy you? Can you name the columns?

annonymous - Saturday, August 12, 2006 1:17:19 PM

loop-in-loop

###################################
# DomainSelection
###################################
getDomainSelection=/jsptemplates/domainSelection.jsp
getDomainSelection.transformType=JSP
#getDomainSelection.headers=Content-Type=text/xml
request.getDomainSelection.transform.className=com.ai.jsp.JSPTransform
getDomainSelection.formHandlerName=getDomainSelection

#
#Data definition
#
request.getDomainSelection.form_handler.class_request.className=com.ai.htmlgen.DBHashTableFormHandler1
getDomainSelection.loopNames=FoldersLoop1


#first primary loop
request.getDomainSelection.FoldersLoop1.class_request.className=com.ai.htmlgen.GenericTableHandler6
request.getDomainSelection.FoldersLoop1.loopNames=itemsLoop
request.getDomainSelection.FoldersLoop1.query_request.className=com.ai.db.DBRequestExecutor2
request.getDomainSelection.FoldersLoop1.query_request.db=MOVOCO_Prototype
request.getDomainSelection.FoldersLoop1.query_request.stmt=Select Slot_ID from Slot_Definition 

#Child loop 1
request.itemsLoop.class_request.classname=com.ai.htmlgen.GenericTableHandler6
request.itemsLoop.query_request.classname=com.ai.db.DBRequestExecutor2
request.itemsLoop.query_request.db=MOVOCO_Prototype
request.itemsLoop.query_request.stmt=Select Term from Vocabulary Where V_ID = {Slot_ID}

annonymous - Saturday, August 12, 2006 1:32:26 PM

Group by Mahaveer comments

Hello Satya,

I have written LMJGroupSearchResult to group result returned from Lucene. I have attached code for your reference.

In this code here, I check if jid is present in Hashtable rank, insert in the Hashtable. Otherwise, update the rank. The insertion into the rank is working fine. The update "appendToExisting" is not working fine.

if(rank.containsKey(jid)) {

System.out.println("Appending data");

LMJSearchObj lobj = (LMJSearchObj) rank.get(jid);

lobj.appendToExisting(rid, appName);

rank.put(jid, lobj);

} else {

System.out.println("Before Constructor call");

// LMJSearchObj lobj = new LMJSearchObj(jid, appName, rid);

rank.put(jid, new LMJSearchObj(jid, appName, rid)); 

}

Let me know if you find a solution

Mahaveer

annonymous - Saturday, August 12, 2006 1:33:27 PM

LMJSearchObject.java

/*
 * Created on Aug 11, 2006
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.indent.lucene;

/**
 * @author mahaveer
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class LMJSearchObj {
   String journal_id;
   String docList;
   String discList;

   public LMJSearchObj(String jid, String appName, String resource_id) {
      this.journal_id = jid;
      System.out.println("In constructor : Jid = " + jid + ", rid " 
      + resource_id + "appName = " + appName);      
      if(appName.equals("document"))
         this.discList = resource_id;
      else if(appName.equals("discussion"))
         this.docList = resource_id;
   }
   
   public void appendToExisting (String appName, String resource_id) {
      System.out.println("In append Existing");
      if(appName.equals("document"))
         this.discList.concat("," + resource_id);
      else if(appName.equals("discussion"))
         this.docList.concat("," + resource_id);      
   }
   public String getJournal() {
      return this.journal_id;
   }
   public String getDocList() {
      return this.docList;
   }
   public String getDiscList() {
      return this.discList;
   }   
}

annonymous - Saturday, August 12, 2006 1:34:18 PM

LMJGroupSearchResults.java

/*
 * Created on Aug 11, 2006
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.indent.lucene;

import java.util.Map;

import com.ai.application.interfaces.AFactoryPart;
import com.ai.application.interfaces.ConfigException;
import com.ai.application.interfaces.RequestExecutionException;
import com.ai.application.utils.AppObjects;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.queryParser.*;
import org.apache.lucene.search.*;
import org.apache.lucene.document.Document;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Vector;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import com.indent.lucene.LMJSearchObj;
import com.ai.data.*;

/**
 * @author mahaveer
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class LMJGroupSearchResult extends AFactoryPart {
      protected Object executeRequestForPart(String requestName, Map inArgs) 
      throws RequestExecutionException {
         Map rank = new LinkedHashMap();
         try {
            String searchIndexPath = AppObjects.getValue(requestName + ".searchIndexPath");
            searchIndexPath = com.ai.common.FileUtils.translateFileName(searchIndexPath); 
            //replace alias like indent:\\ into real path
            searchIndexPath = 
            com.ai.common.SubstitutorUtils.generalSubstitute(searchIndexPath, inArgs);
            //replace param in curly braces with real values
            
            String keyword = AppObjects.getValue(requestName + ".keyword", null);
            keyword = com.ai.common.SubstitutorUtils.generalSubstitute(keyword, inArgs);//
            
            Hits lmjsearch;
            if(keyword != null) {
               System.out.println("Keyword is not null");
               //call Search method to return search results
               lmjsearch = getSearchResults(searchIndexPath, keyword);
               
               System.out.println("Before grouping");
               // Call a method to group the search data 
               // based on journal id.
               groupResultDoc(lmjsearch, rank);
               
               System.out.println("Before creating hds");
               // I will call a function to insert the data in 
               // iDataCollection
               return getDocumentCollection(rank);
            }
            
         } catch (ConfigException x) {
            throw new RequestExecutionException("Index path is not right" + x);
         }
      
         return null;
      }
      
      private Hits getSearchResults(String sPath, String keyword) 
      throws RequestExecutionException {
         Searcher searcher = null;
         try {
         searcher = new IndexSearcher(sPath);
         Analyzer analyzer = new StandardAnalyzer();
         
         Query lmjQuery = QueryParser.parse(keyword, "content", analyzer);
         Hits lmjHits = searcher.search(lmjQuery);
         
         return lmjHits;
         } catch (IOException ex) {
            throw new RequestExecutionException(" caught a " + ex);
         } catch (Exception e) {
            throw new RequestExecutionException(" caught a " + e);
         } 
         
         finally {
            try {
               searcher.close();
            } catch (IOException e) {
               throw new RequestExecutionException("Error in Finally" + e);
            }
         }
      }
      
      private void groupResultDoc(Hits results, Map rank) throws RequestExecutionException {
         try {
            for (int start = 0; start < results.length(); start ++) {
               Document doc = results.doc(start);
               String jid = doc.get("journal_id");
               int jidInt = Integer.parseInt(jid);
               String rid = doc.get("id"); 
               String appName = doc.get("app");
               System.out.println("Jid = " + jid + ", rid " + rid + "appName = " + appName);
               if(rank.containsKey(jid)) {
                  System.out.println("Appending data");
                  LMJSearchObj lobj = (LMJSearchObj) rank.get(jid);
                  lobj.appendToExisting(rid, appName);
                  rank.put(jid, lobj);
               } else {
                  System.out.println("Before Constructor call");
                  // LMJSearchObj lobj = new LMJSearchObj(jid, appName, rid);
                  rank.put(jid, new LMJSearchObj(jid, appName, rid));    
               }
            }
         } catch (IOException ex) {
               throw new RequestExecutionException(" caught a " + ex);
         } 
      }
      
       private IDataCollection getDocumentCollection(Map rank)
       {
          Vector columnNamesVector = new Vector();
          columnNamesVector.add("journal_id");
          columnNamesVector.add("docList");
          columnNamesVector.add("discList");
          
          ListDataCollection luceneDocumentCollection = new ListDataCollection(columnNamesVector);
          //Fill it up with rows
          Iterator luceneDocItr = rank.entrySet().iterator();
          while(luceneDocItr.hasNext())
          {
             Map.Entry val = (Map.Entry) luceneDocItr.next();
             LMJSearchObj lobj = (LMJSearchObj) val.getValue();
             IDataRow collectionRow = getDataRow(lobj, new VectorMetaData(columnNamesVector));
             luceneDocumentCollection.addDataRow(collectionRow);
          }
          return luceneDocumentCollection;
       }
       
       private IDataRow getDataRow(LMJSearchObj luceneDoc, IMetaData columnMetaData)
       {
          List columnValues = new ArrayList();
          columnValues.add(luceneDoc.getJournal());
          columnValues.add(luceneDoc.getDocList());
          columnValues.add(luceneDoc.getDiscList());
          
          return new ListDataRow(columnMetaData,columnValues);
       }

}

GQ - Sunday, January 14, 2007 11:04:38 PM

Binary Data and Multipart Encoding

Hi, back again...

Any sample on how aspire would go about saving/retrieving binary data from a database, say for instance mysql blobs?

It might be a stretch, but does aspire have a reader/parser support for multipart data?

GQ - Sunday, February 04, 2007 12:54:32 PM

More on Binary Data and Multipart Encoding

Seems to me aspire doesn't have a prewritten way of handling binary data. The way i understand it, blobs are returned as strings, therefore, you are only limited to text files? Of course, I could be mistaken.

As for multipart encoding, there seems to be some kind of support, but I have no idea how it is used.

Satya - Wednesday, February 14, 2007 9:22:59 AM

Sorry, the notifier is broken and i havent seen your message

Let me look into it. I will let you know. You can email me in the future if you are not able to get answers here quick enough. satya at activeintellect.com

Satya - Thursday, February 15, 2007 10:55:02 PM

I will get you some information on this

for multipart I have used the commons library for file uploading. For binary data in databases, people have written some independent java parts to handle those. If you show me how you intend to use them perhaps I can show you how to write a part to handle them or I can write one for you that is general enough.

Even for the multipart let me know what need are you going to address other than file uploads.

GQ - Tuesday, October 16, 2007 7:52:13 PM

Binary Data for Databases

Consider for instance a catalog of diagrams or photography catalog..

Although i have used the commons library for file uploading, I was wondering how this would be possible to insert data into a blob field while still staying within the aspire framework.

I am currently using the DBHashTableFormHandler1 (to parse form data) and DBRequestExecutor2 (to insert into database)... Will it be necessary to write a custom form handler for this? or is there a simpler way?

annonymous - Tuesday, October 16, 2007 11:08:29 PM

Hi, let me answer tomorrow

Hi, let me answer tomorrow