Ejemplo n.º 1
0
 @Override
 public @NonNull Model getASModel() {
   Model pivotModel2 = pivotModel;
   if (pivotModel2 == null) {
     loadImports(ecoreResource);
     pivotModel2 =
         pivotModel =
             importObjects(ClassUtil.nonNullEMF(ecoreResource.getContents()), createPivotURI());
     @SuppressWarnings("null")
     @NonNull
     Resource asResource = pivotModel2.eResource();
     AliasAdapter ecoreAdapter = AliasAdapter.findAdapter(ecoreResource);
     if (ecoreAdapter != null) {
       Map<EObject, String> ecoreAliasMap = ecoreAdapter.getAliasMap();
       AliasAdapter pivotAdapter = AliasAdapter.getAdapter(asResource);
       Map<EObject, String> pivotAliasMap = pivotAdapter.getAliasMap();
       for (EObject eObject : ecoreAliasMap.keySet()) {
         String alias = ecoreAliasMap.get(eObject);
         Element element = newCreateMap.get(eObject);
         pivotAliasMap.put(element, alias);
       }
     }
     metamodelManager.installResource(asResource);
     installImports();
   }
   return pivotModel2;
 }
Ejemplo n.º 2
0
  public static Ecore2AS loadFromEcore(@NonNull ASResource ecoreASResource, @NonNull URI ecoreURI) {
    EnvironmentFactoryInternal environmentFactory =
        PivotUtilInternal.getEnvironmentFactory(ecoreASResource);
    ResourceSet resourceSet = environmentFactory.getResourceSet();
    Resource ecoreResource = resourceSet.getResource(ecoreURI, true);
    if (ecoreResource == null) {
      return null;
    }
    Ecore2AS conversion = getAdapter(ecoreResource, environmentFactory);
    conversion.loadImports(ecoreResource);
    //		if (asMetamodels != null) {
    //
    //		}
    PivotMetamodelManager metamodelManager = environmentFactory.getMetamodelManager();
    conversion.pivotModel = PivotUtil.createModel(ecoreASResource.getURI().toString());
    //		conversion.installImports();
    conversion.update(ecoreASResource, ClassUtil.nonNullEMF(ecoreResource.getContents()));

    AliasAdapter ecoreAdapter = AliasAdapter.findAdapter(ecoreResource);
    if (ecoreAdapter != null) {
      Map<EObject, String> ecoreAliasMap = ecoreAdapter.getAliasMap();
      AliasAdapter pivotAdapter = AliasAdapter.getAdapter(ecoreASResource);
      Map<EObject, String> pivotAliasMap = pivotAdapter.getAliasMap();
      for (EObject eObject : ecoreAliasMap.keySet()) {
        String alias = ecoreAliasMap.get(eObject);
        Element element = conversion.newCreateMap.get(eObject);
        pivotAliasMap.put(element, alias);
      }
    }
    metamodelManager.installResource(ecoreASResource);
    conversion.installImports();
    return conversion;
  }
Ejemplo n.º 3
0
 /**
  * Convert an (annotated) Ecore object to a pivot element.
  *
  * @param eObject the annotated Ecore object
  * @return the pivot element
  */
 public static Element importFromEcore(
     @NonNull EnvironmentFactoryInternal environmentFactory,
     String alias,
     @NonNull EObject eObject) {
   Resource ecoreResource = ClassUtil.nonNullEMF(eObject.eResource());
   Ecore2AS conversion = getAdapter(ecoreResource, environmentFactory);
   @SuppressWarnings("unused")
   Model pivotModel = conversion.getASModel();
   return conversion.newCreateMap.get(eObject);
 }
Ejemplo n.º 4
0
 @Override
 public @NonNull URI getURI() {
   return ClassUtil.nonNullEMF(ecoreResource.getURI());
 }
 public @NonNull Type getType(@NonNull EClassifier eClassifier) {
   Ecore2AS ecore2as =
       Ecore2AS.getAdapter(ClassUtil.nonNullEMF(eClassifier.eResource()), environmentFactory);
   Type pivotType = ecore2as.getCreated(Type.class, eClassifier);
   return ClassUtil.nonNullState(pivotType);
 }