Accesing children of Rollbase objects in a custom Java trigg

Posted by nicoleta.riter on 13-Nov-2014 07:34

Hello,

We are using a custom Java trigger when creating/updating an object. Object has a parent-child relation to another object. We can see the parent object information in the trigger method, but we also need children object information. Is there a way we can see/get child object information in a trigger set on the parent object of a relation?

Kind regards,

Nicoleta Riter

All Replies

Posted by Gian Torralba on 13-Nov-2014 09:10

Hello,

Can you provide the code you are using for this custom java trigger?

Thank you,

Gian

Posted by nicoleta.riter on 13-Nov-2014 09:56

I can not provide the exact code, but this is a glance of what I am trying:

public class CustomTrigger extends RuntimeTrigger {

public CustomTrigger(TriggerDef triggerDef, DataObject data,

Date eventDate) {

super(triggerDef, data, eventDate);

}

@Override

public void trigger(TriggerRunner triggerRunner) throws Exception {

Person person = new Person();

String name = m_data.getFieldValue("name").toString();

String surname = m_data.getFieldValue("surname").toString();

// get relatives of a person from a child table of Person

List<Relatives> relatives = m_data.getFieldValue("relatives");

}

}

The problem that I'm facing is as follows: I have a trigger in Rollbase on table A, and table A has a one to many relation with table B, in Java when I access m_data object, I can see all fields of table A, but the fields of B look like this: [J@6ea4a825. Is there a posibility to get the list of B objects from this [J@6ea4a825?

Posted by romain.pennes@foederis.fr on 13-Nov-2014 10:05

Hello,

Excuse me for asking but,

Why do you feel the need of having a custom Java trigger?

We have been using Rollbase for 3 years on advanced issues and we never really needed it and always found workarounds in Rollbase.

Regards,

Romain

Posted by nicoleta.riter on 13-Nov-2014 10:10

We need to call a soap webservice and this is the current solution that we have.

Posted by Gian Torralba on 13-Nov-2014 10:17

Hello,

Since you have a 1-many relationship it might be returning an array of data. Can you parse the return value to see if it is indeed an array?

Thank you,

Gian

Posted by Gian Torralba on 13-Nov-2014 10:26

Hello,

I am reading the Java document and there is a Java method called getAllRelated(). I think this is what you need to get all related object's field info and then use the getFieldValue again for each return object.

Let me know if I understand the question.

Thank you,

Gian

Posted by nicoleta.riter on 13-Nov-2014 10:41

Hello,

Can you send a link with the Java document where you found this information? The object that I am using, m_data, does not have method getAllRelated() available.

Yes, you understood the question well.

Thank you,

Nicoleta

Posted by pvorobie on 13-Nov-2014 10:58

You can use APIs defined in RelationshipHandler class:

RelationshipHandler.getObjects(RelationshipDef rel, DataObject data1, com.rb.util.interfaces.IUser user)

Posted by Gian Torralba on 13-Nov-2014 10:59

Hello,

You can access it here: https://www.progress.com/products/rollbase/try/try-it/private-cloud.

After logging in, you can download the Custom Development Toolkit zip file. After downloading the file you can open the html page from customt > JavaDoc > index.html and go to the Relationship Class Page.


Thank you,

Gian

This thread is closed