[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.modeling.m2m] Re: [ATL]Launching ATL programmatically problem

Hi Shan,

I think there is a problem with the paths we give on tarnsfromation, and 
models.

1- there is also a problem in teh function loadModel, PLZ see below that I 
omited resolve(cwd)

2- I turned the parsparam function to setTransfContext. you can set all the 
parameters (String) by the path of each file. For example

String inputModelPath 
"file:///D:/runtime-EclipseApplication/Sample2/models/book.xml";

        main.setTransfContext(transfPath,inputModelPath, 
inputMetaModelPath,outputModelPath,outputMetaModelPath) ;

        // run the transformation
        main.run();

I hope it helps

Maher

------------------------------------------ 1--------------------
    public static ASMModel loadModel(AtlModelHandler amh, String modelId, 
ASMModel metaModel, String uri)
    throws FileNotFoundException {
        ASMModel model = null;
        if (amh instanceof AtlEMFModelHandler) {
            URI absURI = URI.createURI(uri) ; //.resolve(cwd);
            model = ((AtlEMFModelHandler)amh).loadModel(
                    modelId, metaModel, absURI);
            try {
                Method getReferencedExtents = 
model.getClass().getMethod("getReferencedExtents", null);
                System.out.println("Referenced extents: " +
                        getReferencedExtents.invoke(model, null));
            } catch (Exception e) {
                System.out.println("The EMF4ATL version used does not 
support referenced extents (multiple-file models)");
            }
        } else {
            model = amh.loadModel(modelId, metaModel, new 
FileInputStream(uri));
        }
        return model;
    }

--------------------------------- 2 ------------------------------------
public void setTransfContext(String transfPath,
         String inputModelPath,
         String inputMetaModelPath,
         String outputModelPath,
         String outputMetaModelPath) {

     try {
      trans = new URL(transfPath);
  } catch (MalformedURLException e1) {
   // TODO Auto-generated catch block
   e1.printStackTrace();
  }
     try {
   addInputModel(
     "IN=" + inputModelPath,
     "UMLClass=" + inputMetaModelPath,
     "EMF");
  } catch (Exception e1) {
   // TODO Auto-generated catch block
   e1.printStackTrace();
  }
     try {
   addOutputModel(
     "OUT=" + outputModelPath,
     "RDB=" + outputMetaModelPath,
     "EMF");
  } catch (Exception e1) {
   // TODO Auto-generated catch block
   e1.printStackTrace();
  }
-------------------------------------------------

"Shan" <xxcs214@xxxxxxx> a écrit dans le message de news: 
2e5891197b146e7ccc3cd7dc047dfba1$1@xxxxxxxxxxxxxxxxxx
> Code is :
>
> public class Test {
> public static void main(String args[]){
> String temp[]=new String[10];
> temp[0]="--trans";
> temp[1]="file:///D:/runtime-EclipseApplication/Sample2/Book2Product.asm";
> temp[2]="--in";
> temp[3]="IN=file:///D:/runtime-EclipseApplication/Sample2/models/book.xml";
> temp[4]="Book=file:///D:/runtime-EclipseApplication/Sample2/metamodels/book.ecore";
> temp[5]="EMF";
> temp[6]="--out";
> temp[7]="OUT=file:///D:/runtime-EclipseApplication/Sample2/models/ss.xml";
> temp[8]="Product=file:///D:/runtime-EclipseApplication/Sample2/metamodels/product.ecore";
> temp[9]="EMF";
>
> Main main=new Main();
> main.main(temp);
> }
>