Package

Source Code of MappingTest

import java.io.IOException;
import java.util.Collections;
import java.util.Map;

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.emf.ecore.xmi.XMIResource;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;

import com.founder.fix.bpmn2extensions.connector.Connector;
import com.founder.fix.bpmn2extensions.connector.ConnectorFactory;
import com.founder.fix.bpmn2extensions.connector.ConnectorPackage;
import com.founder.fix.bpmn2extensions.flowconnector.FlowConnectorDefinition;
import com.founder.fix.bpmn2extensions.flowconnector.FlowConnectorFactory;
import com.founder.fix.bpmn2extensions.flowconnector.FlowConnectorPackage;
import com.founder.fix.bpmn2extensions.flowconnector.Input;
import com.founder.fix.bpmn2extensions.flowconnector.Items;
import com.founder.fix.bpmn2extensions.flowconnector.Page;
import com.founder.fix.bpmn2extensions.flowconnector.Password;
import com.founder.fix.bpmn2extensions.flowconnector.Select;
import com.founder.fix.bpmn2extensions.flowconnector.Text;
import com.founder.fix.bpmn2extensions.flowconnector.Widget;
import com.founder.fix.bpmn2extensions.flowconnector.util.FlowConnectorResourceImpl;
import com.founder.fix.bpmn2extensions.sqlmappingconfig.DataBaseTableConfig;
import com.founder.fix.bpmn2extensions.sqlmappingconfig.RulesConfig;
import com.founder.fix.bpmn2extensions.sqlmappingconfig.Sql;
import com.founder.fix.bpmn2extensions.sqlmappingconfig.SqlMappingConfig;
import com.founder.fix.bpmn2extensions.sqlmappingconfig.SqlmappingconfigFactory;
import com.founder.fix.bpmn2extensions.sqlmappingconfig.SqlmappingconfigPackage;



public class MappingTest {

  /**
   * @param args
   */
  public static void main(String[] args) {
    // TODO Auto-generated method stub
   
   
    FlowConnectorPackage.eINSTANCE.eClass();
 
    SqlmappingconfigPackage.eINSTANCE.eClass();
 
    RulesConfig rulesConfig=SqlmappingconfigFactory.eINSTANCE.createRulesConfig();
   
   
   
    com.founder.fix.bpmn2extensions.sqlmappingconfig.Select select=SqlmappingconfigFactory.eINSTANCE.createSelect();
    select.setId("11");
    rulesConfig.getSelect().add(select);

    // As of here we preparing to save the model content

    // Register the XMI resource factory for the .website extension

    Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
    Map<String, Object> m = reg.getExtensionToFactoryMap();
    m.put("xml", new XMIResourceFactoryImpl());

    // Obtain a new resource set
    FlowConnectorResourceImpl resource = new FlowConnectorResourceImpl(URI
        .createURI("website/My1.xml"));

        resource.setEncoding("UTF-8");

        resource.getContents().add(rulesConfig);

        try {
          resource.save(Collections.EMPTY_MAP);
        } catch (IOException e) {
          e.printStackTrace();
        }
       
        //resource.getDefaultSaveOptions().put(XMLResource.OPTION_KEEP_DEFAULT_CONTENT, Boolean.TRUE);

    // Now save the content.
    try {
      resource.save(Collections.EMPTY_MAP);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    //load();
  }

 
 
  public static FlowConnectorDefinition load() {
    // Initialize the model
    ConnectorPackage.eINSTANCE.eClass();
   
    // Register the XMI resource factory for the .website extension

    Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
    Map<String, Object> m = reg.getExtensionToFactoryMap();
    m.put("xml", new XMIResourceFactoryImpl());

    // Obtain a new resource set
    ResourceSet resSet = new ResourceSetImpl();

    // Get the resource
    Resource resource = resSet.getResource(URI.createURI("website/My1.xml"), true);
    // Get the first model element and cast it to the right type, in my
    // example everything is hierarchical included in this first node
    FlowConnectorDefinition myWeb = (FlowConnectorDefinition) resource.getContents().get(0);
    Select select=(Select)myWeb.getPage().get(0).getWidget().get(0);
    //select.getItems().get(0).getMixed();
    return myWeb;
  }
}
TOP

Related Classes of MappingTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.