Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 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: 330
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: 1252
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: 330
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: 124
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 messageGo to next message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 330
Registered: August 2011
Senior Member
I did not know this one : "StatusCodeType statuses = CODES.getCodeType(StatusCodeType.class);"

Thanks, it works now
Re: CodeType with codes from the database [message #1830995 is a reply to message #789632] Sat, 08 August 2020 11:19 Go to previous message
Marco Dörfliger is currently offline Marco DörfligerFriend
Messages: 46
Registered: January 2015
Member
This "CODES.getCodeType(StatusCodeType.class);" syntax seems to have been dropped from newer versions of scout (I currently have Eclipse 2020-06). You can say "CODES.getCodeTypes(StatusCodeType.class)", but that returns an untyped list. So to get an instance of a code using the value, I have to do this:

@SuppressWarnings("unchecked")
ICodeType<Long, Long> ct = (ICodeType<Long, Long>) CODES.getCodeTypes(VisibleScopeCodeType.class).get(0);
ICode<Long> code = ct.getCode(searchFormData.getVisibileScope().getValue());


Is there a way to get a typed CodeType instance?

<edit>
Ah, I found it.

BEANS.get(StatusCodeType.class)

[Updated on: Sat, 08 August 2020 11:25]

Report message to a moderator

Previous Topic:Scout 10 HelloWorld sample application Maven build issue
Next Topic:Send notificatiom after job is completed
Goto Forum:
  


Current Time: Tue Apr 16 12:11:47 GMT 2024

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

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

Back to the top