How to take data from my decision table?

Hi, I need to instantiate the decision table that I have active in the project in an object of class IDTBDecisionTable. The only thing I was able to do was this:

IDTBDecisionTableEditorDiagramUIModel decisionTableDiagram = (IDTBDecisionTableEditorDiagramUIModel) diagramManager.getActiveDiagram();

But I still haven’t figured out the difference between an object of class IDTBDecisionTableEditorDiagramUIModel and one of IDTBDecisionTable. How can I instantiate the table I have in the project in an IDTBDecisionTable object? I need it to extract internal values ​​and do checks to optimize the table itself.

Hi m.ricchiuti13,

Could you tell me more about your need? What do you mean by “internal values”? What do you want to do with your decision table through the API?

Best regards,
Jick Yeung

Hi Jick,
I need the data inside the decision table, i.e. the values ​​of the action, of the conditions and of the rules to check for probable anomalies and if they are found then correct them.
So I think I should instantiate an object of class IDTBDecisionTable and then extract the data I need.
I don’t know if I expressed that the right way.

Hi m.ricchiuti13,

Thank you for your reply. I have forwarded your case to our team to study. When there is an answer, I will let you know.’

Best regards,
Jick Yeung

Hi m.ricchiuti13,

The class diagram below shows the classes and their relationships:
image

You can create a DTBDecisionTableEditorDiagram diagram. Then, set its decisionTableModelAddress to reference to the IDTBDecisionTable’s address.

Best regards,
Jick Yeung

Hi Jick,
I’m so sorry, but I’ve tried and still don’t understand which classes and methods I need to use to set the reference to the IDTBDecisionTable so that I can access the data. Can I ask you for a code example please?

Hi m.ricchiuti13,

Please see if the following code can help:

		IDiagramUIModel[] diagrams = ApplicationManager.instance().getProjectManager().getProject().toDiagramArray();
		for (int i = 0; i < diagrams.length; i++) {
			IDiagramUIModel iDiagramUIModel = diagrams[i];
			
			if (iDiagramUIModel instanceof IDTBDecisionTableEditorDiagramUIModel) {
				IDTBDecisionTableEditorDiagramUIModel diagram = (IDTBDecisionTableEditorDiagramUIModel)iDiagramUIModel;
				String decisionTableAddress = diagram.getDecisionTableModelAddress();
				
				IModelElement modelElement = ApplicationManager.instance().getProjectManager().getProject().getModelElementByAddress(decisionTableAddress);
				if (modelElement instanceof IDTBDecisionTable) {
					IDTBDecisionTable decisionTable = (IDTBDecisionTable)modelElement;

					decisionTable.toActionArray();
					// ...
					decisionTable.toConditionArray();
					// ...
					decisionTable.toRuleArray();
					// ...
					
				}
				
			}
			
		}

Best regards,
Jick Yeung