Get references of a glossary term and create a transition

I’ve tried to get the references of a glossary term by
create list of terms with id, name and alias
ArrayList <ArrayList > termAliasList = new ArrayList <ArrayList >();
ArrayList <ArrayList > termReferencesList = new ArrayList <ArrayList >();
ArrayList termsAliasList = new ArrayList ();
i = 0;
for (IModelElement existingTerm : existingTerms) {
ArrayList record = new ArrayList ();
String id = existingTerm.getId();
String termName = existingTerm.getName();
record.add(id);
record.add(termName);
termsAliasList.add(termName);
System.out.println("Counter: " + i);
if (existingTerm instanceof IGlossary) {
IGlossary g = (IGlossary) existingTerm;
IAlias[] aliases = g.toAliaseArray();
IStereotype[] stereos = g.toStereotypeModelArray();

            IReference[] references = g.toReferenceArray();
            
            if (aliases != null) {
                for (IModelElement alias : aliases) {
                	String a = alias.getName();
                	record.add(a);
                	termsAliasList.add(a);
                }                    
            }
        }
		termAliasList.add(record);
		record = null;
		i++;
	}

but w/o success.
I also tried to create a transition from term to a model object:
IGlossary lTerm = IModelElementFactory.instance().createGlossary();
lTerm.setName(name);
ITransition lTransit = IModelElementFactory.instance().createTransition();
lTransit.setFrom(lTerm);
lTransit.setTo(lModelElement);

What’s wrong?

Hi dgoebel,

Thank you for your post. Your questions have been passed to our team for further studies. When there is any update, we will share it with you.

Best regards,
Jick Yeung

Hi dgoebel,

First of all, about getId(), the following method will return the internal ID.

existingTerm.getId()

You said you wanted to create a of terms with ‘id’, we guess that you are talking about user-id. Please try the following instead:

((IGlossary) existingTerm).getUserID()

To get the references of a term, you called g.toReferenceArray(), and then did nothing. We guess that you don’t know how to get the information from those IReference[]. The following code may help:

IReference provides
   .getUrl() : String, or
   .getUrlAsModel() : IModelElement, or
   .getUrlAsDiagram() : IDiagramUIModel, or
   .getUrlAsShape() : IDiagramElement

To create a transition, you can call .getModelPropertyByName(…) to get the ITransitProperty, then call ITransitProperty.addValue(IModelElement).

Hope this helps. Feel free to contact us if you have any questions.

Best regards,
Jick Yeung

Dear Jick,
thanks for help - everything works fine.
There is one issue left to me: how to get the URL of a referenced link. It means I’ve added an url link to a model object, but I don’t know how to read it.
The attached table shows the references of a model element - in this case a glossary term. I don’t know how to get the URL “http://leonsulting.com” in the column PATH.
One more issue is how to get the referenced model object?
I tried it by using the url but w/o success:
IModelElement referencedModelElement = getModelElement(url);


Hi dgoebel,

Sorry for my late reply. I have forwarded your questions to our team for studying. When there is a reply, I will let you know.

Best regards,
Jick Yeung

Hi dgoebel,

IReference.getUrl() will return the URL you need. Could you try it?

Best regards,
Jick Yeung