JoKo
JoKo

Reputation: 23

How to select data of a built-in AnyLogic-database within an AnyLogic-class?

in my anylogic-model i want to query some data from the build-in-database. Within a function in an agent-type that's no problem. For better encapsulating i want to put my code into a class.

I already searched the AnyLogic-help, but i couldn't find the correct way to access the database from within a class.

The provided examples only work within the agent-type (https://help.anylogic.com/nav/0_15_10), since the function is provided by the abstract class Utilities which every agent is inherited from (https://help.anylogic.com/topic/com.anylogic.help/html/javadoc/com/anylogic/engine/Utilities.html).

Tuple item = selectFrom( team_knowledge ).
                        where( team_knowledge.idteam_social.eq( idmember ) ).
                        where( team_knowledge.idteam_technology.eq( idtechnology ) ).
                        firstResult(team_knowledge.id, team_knowledge.idteam_social,
                            team_knowledge.idteam_technology, team_knowledge.is_skill,
                            team_knowledge.necessary_skill);

Error: The method selectFrom(Qteam_knowledge) is undefined for the type TeamKnowledgeModel

Do you can name the correct class to use for this problem?

Upvotes: 0

Views: 502

Answers (1)

Stuart Rossiter
Stuart Rossiter

Reputation: 2517

Just have the class accept an instance of any Agent in the model within its constructor. Then it has to use that to do any queries (e.g., agent.selectFrom).

That is, the class stores an instance of an Agent which it delegates queries to.

Upvotes: 0

Related Questions