Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » CodeType with codes from the database(CodeType with codes from the database)
CodeType with codes from the database [message #787448] Tue, 31 January 2012 15:43 Go to next message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 309
Registered: August 2011
Senior Member
Is there an example on how to use codeTypes when the codes should be loaded from the database.

My database has a table Status that is used for Appointments. On my planning form i need these statusus. A status has an id (which is in the Appoinment)a name, a code, and a color. So the idea is to load all this information into a AppointmentStatusCodeType.

When an appointment is presented I want to use the AppointmentStatusCodeType for the persentation and make it possible to use change the status of an appointment.

Regards Bertin

Re: CodeType with codes from the database [message #787515 is a reply to message #787448] Tue, 31 January 2012 17:10 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 817
Registered: October 2011
Senior Member
Overide execLoadCodes() in your CodeTypeClass.
This functions need to return an array of CodeRow.
Have a look at the different CodeRow constructor and/or setter that are available.

You can do a DB Call as usual with SQL.select(..) or SQL.selectInto(..)

Re: CodeType with codes from the database [message #787532 is a reply to message #787515] Tue, 31 January 2012 17:24 Go to previous messageGo to next message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 309
Registered: August 2011
Senior Member
How can I use the codes when I implemented the method execLoadCodes(). How to get the codeType and how can I get the individual codes then. I expected some static method getCodeById.

So when I have a Calendar, an appointment only has aStatus id. I then have to get the rest of the info through the codeType.
Re: CodeType with codes from the database [message #787643 is a reply to message #787532] Tue, 31 January 2012 20:43 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 118
Registered: November 2010
Senior Member
Having a dynamic CodeType (loaded from execLoadCodes()) or a static CodeType (with Codes as inner-class of the code Type - YesOrNoCodeType for example) do not change how you use the code type.

Under Using a CodeType of the CodeType page you will find some examples.

You can access the CodeType instance with:
StatusCodeType statuses = CODES.getCodeType(StatusCodeType.class);


After that if you want to access a code, with its id.
ICode code = statuses.getCode(id);

Do not forget to check if code is not null...

CodeType are often used with SmartField (or smart columns). In a such case the value of the field (or of the column for a row) is the id.

Re: CodeType with codes from the database [message #789632 is a reply to message #787643] Fri, 03 February 2012 08:03 Go to previous message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 309
Registered: August 2011
Senior Member
I did not know this one : "StatusCodeType statuses = CODES.getCodeType(StatusCodeType.class);"

Thanks, it works now
Previous Topic:Start application with parameters
Next Topic:Filter calendar items
Goto Forum:
  


Current Time: Wed Dec 17 21:34:22 GMT 2014

Powered by FUDForum. Page generated in 0.02975 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software