I can’t figure it out how to delete relations from class.
Here is the code how to retrieve them, but how to DELETE!?
/*
-
retrieve relationship model from a class model
-
there are 2 kinds of relationships: IRelationship and IEndRelationship
*/
// assume in a code segment
IClass classModel = …; // retrieved the class model from somewhere
// retrieve a generalization (IRelationship)
Iterator genIter = classModel.fromRelationshipIterator();
while (genIter.hasNext()) {IRelationship relationship = (IRelationship) genIter.next();
// found out the another side’s model of the relationship
IModelElement otherModel = relationship.getTo();
}
// retrieve am association (IEndRelationship)
Iterator assoIter = classModel.fromRelationshipEndIterator();
while (assoIter.hasNext()) {
IRelationshipEnd relationshipEnd = (IRelationshipEnd) assoIter.next();
IModelElement otherModel = relationshipEnd.getEndRelationship().getToEnd().getModelElement();
}