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);
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.
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);