Beispiel #1
0
 protected boolean isPivot(@NonNull Collection<EObject> ecoreContents) {
   if (ecoreContents.size() != 1) {
     return false;
   }
   EObject ecoreRoot = ecoreContents.iterator().next();
   if (!(ecoreRoot instanceof EPackage)) {
     return false;
   }
   EPackage ecorePackage = (EPackage) ecoreRoot;
   if (ClassUtil.basicGetMetamodelAnnotation(ecorePackage) != null) {
     return true;
   }
   // FIXME Following code should be redundant
   if (ecorePackage.getEClassifier(PivotPackage.Literals.ENUMERATION_LITERAL.getName()) == null) {
     return false;
   }
   if (ecorePackage.getEClassifier(PivotPackage.Literals.EXPRESSION_IN_OCL.getName()) == null) {
     return false;
   }
   if (ecorePackage.getEClassifier(PivotPackage.Literals.OPERATION_CALL_EXP.getName()) == null) {
     return false;
   }
   if (ecorePackage.getEClassifier(PivotPackage.Literals.TEMPLATE_PARAMETER_SUBSTITUTION.getName())
       == null) {
     return false;
   }
   return true;
 }
Beispiel #2
0
 @Override
 public RootPackageId getMetamodelId(
     @NonNull EnvironmentFactoryInternal environmentFactory, @NonNull EPackage ePackage) {
   assert !"http://www.eclipse.org/uml2/5.0.0/UML".equals(ePackage.getNsURI());
   assert !"http://www.eclipse.org/uml2/5.0.0/Types".equals(ePackage.getNsURI());
   RootPackageId metamodel = null;
   if (ClassUtil.basicGetMetamodelAnnotation(ePackage) != null) {
     metamodel = IdManager.METAMODEL;
   } else {
     String nsURI = ePackage.getNsURI();
     String sharedNsURI = environmentFactory.getCompleteModel().getCompleteURI(nsURI);
     if ((sharedNsURI != null) && !sharedNsURI.equals(nsURI)) {
       metamodel = IdManager.getRootPackageId(sharedNsURI);
     }
   }
   return metamodel;
 }
Beispiel #3
0
 protected void loadImports(@NonNull EPackage ePackage, @Nullable URI baseURI) {
   if (ClassUtil.basicGetMetamodelAnnotation(ePackage) != null) {
     if (asMetamodels == null) {
       asMetamodels = new HashSet<EPackage>();
     }
     asMetamodels.add(ePackage);
   }
   EAnnotation importAnnotation = ePackage.getEAnnotation(PivotConstants.IMPORT_ANNOTATION_SOURCE);
   if (importAnnotation != null) {
     EMap<String, String> details = importAnnotation.getDetails();
     for (String key : details.keySet()) {
       URI uri = URI.createURI(details.get(key));
       uri = resolveImportURI(uri, ePackage, baseURI);
       assert uri != null;
       ResourceSet resourceSet = environmentFactory.getResourceSet();
       EObject importedEObject = null;
       String fragment = uri.fragment();
       if (fragment == null) {
         importedEObject = resourceSet.getPackageRegistry().getEPackage(uri.toString());
       } else {
         importedEObject = resourceSet.getEObject(uri, true);
       }
       if (importedEObject != null) {
         if (importedEObjects == null) {
           importedEObjects = new HashSet<EObject>();
         }
         if (importedEObjects.add(importedEObject) && (importedEObject instanceof EPackage)) {
           Resource importedResource = importedEObject.eResource();
           if (importedResource != null) {
             URI baseURI2 = getBaseURI(importedResource);
             loadImports((EPackage) importedEObject, baseURI2);
           }
         }
       }
     }
   }
   for (EPackage eSubPackage : ePackage.getESubpackages()) {
     if (eSubPackage != null) {
       loadImports(eSubPackage, baseURI);
     }
   }
 }