[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.modeling.mdt.ocl] Re: changing context of existing query
|
Hi Ed,
thanks for your quick help. I tried using the UsageCrossReferences and it
seems that it's working:
// search for features of old classes
Set<EStructuralFeature> feats = new HashSet<EStructuralFeature>();
for (EClass oldEClass : oldEClasses)
{
feats.addAll(oldEClass.getEAllStructuralFeatures());
}
// find referring features
Map<EObject, Collection<EStructuralFeature.Setting>> usesOfOldEClasses =
EcoreUtil.UsageCrossReferencer
.findAll(feats, OCL_ENV.getEnvironment().getTypeResolver()
.getResource());
// switch old features with new ones
for (Entry<EObject, Collection<EStructuralFeature.Setting>> entry :
usesOfOldEClasses
.entrySet())
{
EStructuralFeature oldFeature = (EStructuralFeature) entry.getKey();
EClass oldClass = (EClass) oldFeature.eContainer();
EClass newClass = metaModelMap.get(oldClass.getName());
EStructuralFeature newFeature = newClass
.getEStructuralFeature(oldFeature.getName());
for (EStructuralFeature.Setting setting : entry.getValue())
{
setting.set(newFeature);
}
}
Regards,
Chris