Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.99 KB | None | 0 0
  1. // set up the load option:
  2. set.getLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE,
  3.     Boolean.TRUE);
  4.  
  5. // sample upgrade function:
  6. private void processModelUpgrades(Resource resource) {
  7.     if (!(resource instanceof XMLResource)) {
  8.         return;
  9.     }
  10.     Map<EObject, AnyType> extensions = ((XMLResource) resource)
  11.             .getEObjectToExtensionMap();
  12.     MApplication application = (MApplication) resource.getContents().get(0);
  13.     TreeIterator<EObject> it = EcoreUtil.getAllContents(resource
  14.             .getContents());
  15.     while (it.hasNext()) {
  16.         EObject obj = it.next();
  17.         if (obj instanceof MBindingTable) {
  18.             AnyType anyType = extensions.get(obj);
  19.             for (Entry feature : anyType.getAnyAttribute()) {
  20.                 if (feature.getEStructuralFeature().getName()
  21.                         .equals("bindingContextId")) {
  22.                     MBindingContext root = getBindingContext(application,
  23.                             (String) feature.getValue());
  24.                     ((MBindingTable) obj).setBindingContext(root);
  25.                     System.out.println("set " + root);
  26.                 }
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement