[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[stp-commits] r2961 - org.eclipse.stp.model/trunk/org.eclipse.stp.im.in.sca/src/org/eclipse/stp/im/in/sca/transform

Author: amos
Date: 2009-08-27 04:54:46 -0400 (Thu, 27 Aug 2009)
New Revision: 2961

Removed:
   org.eclipse.stp.model/trunk/org.eclipse.stp.im.in.sca/src/org/eclipse/stp/im/in/sca/transform/IMHandler.java
Modified:
   org.eclipse.stp.model/trunk/org.eclipse.stp.im.in.sca/src/org/eclipse/stp/im/in/sca/transform/SCA2IMTransformer.java
Log:
refactored the use of the IM handler which has been moved to the core .im plugin

Deleted: org.eclipse.stp.model/trunk/org.eclipse.stp.im.in.sca/src/org/eclipse/stp/im/in/sca/transform/IMHandler.java
===================================================================
--- org.eclipse.stp.model/trunk/org.eclipse.stp.im.in.sca/src/org/eclipse/stp/im/in/sca/transform/IMHandler.java	2009-08-27 08:52:25 UTC (rev 2960)
+++ org.eclipse.stp.model/trunk/org.eclipse.stp.im.in.sca/src/org/eclipse/stp/im/in/sca/transform/IMHandler.java	2009-08-27 08:54:46 UTC (rev 2961)
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) {2008} INRIA
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Adrian Mos (INRIA) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.stp.im.in.sca.transform;
-
-import java.io.IOException;
-import java.util.Collections;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.stp.im.ImFactory;
-import org.eclipse.stp.im.Process;
-import org.eclipse.stp.im.ProcessCollection;
-import org.eclipse.stp.im.Service;
-import org.eclipse.stp.im.ServiceCollection;
-import org.eclipse.stp.im.Step;
-import org.eclipse.stp.im.StpIntermediateModel;
-
-/**
- * Contains operations for creating elements in the Intermediate Model and writing it to disk
- * It is oriented towards SCA-related elements
- * An instance of this class corresponds to an instance of the IM
- * @author Adrian Mos
- */
-public class IMHandler {
-    private StpIntermediateModel stpIM = null; //the top level element of the Intermediate Model EMF instance
-    private ProcessCollection processCollection;
-    private ServiceCollection serviceCollection;
-    private ImFactory imFactory;
-
-    /**
-     * Instantiates the STP-IM and performs other set-up operations  
-     */
-    public IMHandler() {
-        imFactory = ImFactory.eINSTANCE;
-        stpIM = imFactory.createStpIntermediateModel();
-        //create the IM collections (for processes and services)
-        //each process or service created in the future will be added to these accordingly
-        processCollection = imFactory.createProcessCollection();
-        serviceCollection = imFactory.createServiceCollection();
-        stpIM.setProcessCollection(processCollection);
-        stpIM.setServiceCollection(serviceCollection);
-    }
-
-    /**
-     * Instantiates the STP-IM from a .im file  
-     * @param uri the file to load the IM from
-     */
-    public IMHandler(URI uri){
-        
-    }
-    
-    public StpIntermediateModel getStpIM() {
-        return stpIM;
-    }
-    
-    /**
-     * creates and returns a Process element in the IM
-     * @param name the process name
-     * @return the Process EMF element
-     */
-    public Process createProcess(String name){
-        Process p = imFactory.createProcess();
-        p.setName(name);
-        processCollection.getProcesses().add(p); //add it to the IM collection
-        
-        return p;
-    }
-    
-    /**
-     * creates and returns a Service element in the IM
-     * @param name the service name
-     * @return the Service EMF element
-     */
-    public Service createService(String name){
-        Service s = imFactory.createService();
-        s.setServiceName(name);
-        serviceCollection.getServices().add(s); //add it to the IM collection
-        return s;
-    }
-
-    /**
-     * creates a process step and registers it with the given process
-     * @param stepName the name of the step to create
-     * @param parent the parent to attach the step to
-     * @return the newly created step
-     */
-    public Step createStep(String stepName, Process parent){
-        Step s = imFactory.createStep();
-        s.setName(stepName);
-        parent.getSteps().add(s);
-        return s;
-    }
-    
-    /**
-     * will create a file and save the IM instance in it
-     * @param uri the URI of the file to save to
-     * @throws IOException if the save operation does not succeed
-     */
-    public void persistIM(URI uri) throws IOException {
-        //System.out.println("Attempting to persist the IM in " + uri);
-
-        ResourceSet rs = new ResourceSetImpl();
-
-        Resource resource = rs.createResource(uri);
-        resource.getContents().add(this.stpIM);
-        
-        resource.save(Collections.EMPTY_MAP);
-    }
-    
-}

Modified: org.eclipse.stp.model/trunk/org.eclipse.stp.im.in.sca/src/org/eclipse/stp/im/in/sca/transform/SCA2IMTransformer.java
===================================================================
--- org.eclipse.stp.model/trunk/org.eclipse.stp.im.in.sca/src/org/eclipse/stp/im/in/sca/transform/SCA2IMTransformer.java	2009-08-27 08:52:25 UTC (rev 2960)
+++ org.eclipse.stp.model/trunk/org.eclipse.stp.im.in.sca/src/org/eclipse/stp/im/in/sca/transform/SCA2IMTransformer.java	2009-08-27 08:54:46 UTC (rev 2961)
@@ -22,6 +22,7 @@
 import org.eclipse.stp.im.Step;
 import org.eclipse.stp.im.StpIntermediateModel;
 import org.eclipse.stp.im.in.sca.Activator;
+import org.eclipse.stp.im.util.IMHandler;
 import org.eclipse.stp.sca.Component;
 import org.eclipse.stp.sca.ComponentService;
 import org.eclipse.stp.sca.Composite;