Package org.eclipse.emf.ecore.resource.impl

Examples of org.eclipse.emf.ecore.resource.impl.ResourceSetImpl


            }
            if( !element.getContents().contains(ProjectPlugin.getPlugin().getProjectRegistry()) )
                element.unload();
    }
   
    ResourceSet set=new ResourceSetImpl();
    Project project=(Project) set.getResource(URI.createURI("file://"+file.getAbsolutePath()), true).getAllContents().next(); //$NON-NLS-1$
    assertFalse(project.eIsProxy());
    assertNotNull(project);
    int maps=0;
    boolean foundFirstMap=false;
    boolean foundSecondMap=false;
View Full Code Here


   * Loads the SysML profile. In case of errors, a message is logged in the plugin logger and the eclipse
   * error log
   */
  protected static void loadSysMLProfile() {

    final ResourceSet resourceSet = new ResourceSetImpl();

    try {
      final Resource resource = resourceSet.getResource(sysMLProfileURI, true);
      sysMLProfile = (Profile)EcoreUtil.getObjectByType(resource.getContents(),
          UMLPackage.Literals.PACKAGE);
    } catch (WrappedException we) {
      Activator.log(Status.ERROR, "Can't get the SysML profile !", we);
    }
View Full Code Here

   * Loads the Standard profile. In case of errors, a message is logged in the plugin logger and the eclipse
   * error log
   */
  protected static void loadStandardProfile() {

    final ResourceSet resourceSet = new ResourceSetImpl();

    try {
      final Resource resource = resourceSet.getResource(standardProfileURI, true);
      standardProfile = (Profile)EcoreUtil.getObjectByType(resource.getContents(),
          UMLPackage.Literals.PACKAGE);
    } catch (WrappedException we) {
      Activator.log(Status.ERROR, "Can't get the Standard profile !", we);
    }
View Full Code Here

    private Definitions getDefinitions(String xml) {
        try {
            DroolsFactoryImpl.init();
            BpsimFactoryImpl.init();

            ResourceSet resourceSet = new ResourceSetImpl();
            resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
                .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new Bpmn2ResourceFactoryImpl());
            resourceSet.getPackageRegistry().put("http://www.omg.org/spec/BPMN/20100524/MODEL", Bpmn2Package.eINSTANCE);
            Resource resource = resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
            InputStream is = new ByteArrayInputStream(xml.getBytes("UTF-8"));
            resource.load(is, Collections.EMPTY_MAP);
            resource.load(Collections.EMPTY_MAP);
            return ((DocumentRoot) resource.getContents().get(0)).getDefinitions();
        } catch (Throwable t) {
View Full Code Here

                revisitSequenceFlows(def, bpmn2);
                // another hack if id == name
                revisitNodeNames(def);

                // get the xml from Definitions
                ResourceSet rSet = new ResourceSetImpl();
                rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2", new JBPMBpmn2ResourceFactoryImpl());
                JBPMBpmn2ResourceImpl bpmn2resource = (JBPMBpmn2ResourceImpl) rSet.createResource(URI.createURI("virtual.bpmn2"));
                rSet.getResources().add(bpmn2resource);
                bpmn2resource.getContents().add(def);
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                bpmn2resource.save(outputStream, new HashMap<Object, Object>());
                String fullXmlModel =  outputStream.toString();
                // convert to json and write response
                String json = profile.createUnmarshaller().parseModel(fullXmlModel, profile, pp);
                resp.setContentType("application/json");
                resp.getWriter().print(json);
            } catch(Exception e) {
                _logger.error(e.getMessage());
                resp.setContentType("application/json");
                resp.getWriter().print("{}");
            }
        }  else if (transformto != null && transformto.equals(BPMN2_TO_JSON)) {
            try {
                if(convertServiceTasks != null && convertServiceTasks.equals("true")) {
                    bpmn2in = bpmn2in.replaceAll("drools:taskName=\".*?\"", "drools:taskName=\"ReadOnlyService\"");
                    bpmn2in = bpmn2in.replaceAll("tns:taskName=\".*?\"", "tns:taskName=\"ReadOnlyService\"");
                }

                Definitions def = ((JbpmProfileImpl) profile).getDefinitions(bpmn2in);
                def.setTargetNamespace("http://www.omg.org/bpmn20");

                if(convertServiceTasks != null && convertServiceTasks.equals("true")) {
                    // fix the data input associations for converted tasks
                    List<RootElement> rootElements =  def.getRootElements();
                    for(RootElement root : rootElements) {
                        if(root instanceof Process) {
                            updateTaskDataInputs((Process) root, def);
                        }
                    }
                }


                // get the xml from Definitions
                ResourceSet rSet = new ResourceSetImpl();
                rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2", new JBPMBpmn2ResourceFactoryImpl());
                JBPMBpmn2ResourceImpl bpmn2resource = (JBPMBpmn2ResourceImpl) rSet.createResource(URI.createURI("virtual.bpmn2"));
                bpmn2resource.getDefaultLoadOptions().put(JBPMBpmn2ResourceImpl.OPTION_ENCODING, "UTF-8");
                bpmn2resource.getDefaultLoadOptions().put(JBPMBpmn2ResourceImpl.OPTION_DEFER_IDREF_RESOLUTION, true);
                bpmn2resource.getDefaultLoadOptions().put( JBPMBpmn2ResourceImpl.OPTION_DISABLE_NOTIFY, true );
                bpmn2resource.getDefaultLoadOptions().put(JBPMBpmn2ResourceImpl.OPTION_PROCESS_DANGLING_HREF, JBPMBpmn2ResourceImpl.OPTION_PROCESS_DANGLING_HREF_RECORD);
                bpmn2resource.setEncoding("UTF-8");
                rSet.getResources().add(bpmn2resource);
                bpmn2resource.getContents().add(def);
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                bpmn2resource.save(outputStream, new HashMap<Object, Object>());
                String revisedXmlModel =  outputStream.toString();
                String json = profile.createUnmarshaller().parseModel(revisedXmlModel, profile, pp);
View Full Code Here

     * @throws java.io.IOException
     */
    private Bpmn2Resource unmarshall(JsonParser parser, String preProcessingData) throws JsonParseException, IOException {
        try {
            parser.nextToken(); // open the object
            ResourceSet rSet = new ResourceSetImpl();
            rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2",
                    new JBPMBpmn2ResourceFactoryImpl());
            Bpmn2Resource bpmn2 = (Bpmn2Resource) rSet.createResource(URI.createURI("virtual.bpmn2"));
            rSet.getResources().add(bpmn2);
            _currentResource = bpmn2;

            if(preProcessingData == null || preProcessingData.length() < 1) {
                preProcessingData = "ReadOnlyService";
            }
View Full Code Here

   
    monitor.beginTask("Verifying model '" + o.getName() + "'", 10);

    monitor.subTask("Loading model");
    // try and load the file directly
    ResourceSet resourceSet = new ResourceSetImpl();
    Resource resource = resourceSet.getResource(URI.createFileURI(o
        .getLocation().toString()), true);

    // we can only do one model
    if (resource.getContents().size() != 1) {
      return new Status(
View Full Code Here

   * @throws ModelLoadException if the resource is null, or the resource contains too many elements
   * @deprecated
   *     use {@link ModelLoader#load(File)} to ensure loaded paths are not relative
   */
  public static EObject load(String filename) throws ModelLoadException {
    ResourceSet resourceSet = new ResourceSetImpl();
    URI uri = URI.createFileURI(filename);
    Resource resource = resourceSet.getResource(uri, true);
   
    if (resource == null)
      throw new ModelLoadException(new NullPointerException("Unexpected null resource in '" + filename + "'"));
   
    if (resource.getContents().size() != 1) {
View Full Code Here

   * @param f the file to load
   * @return
   * @throws ModelLoadException if the resource is null, or the resource contains too many elements
   */
  public static EObject load(File f) throws ModelLoadException {
    ResourceSet resourceSet = new ResourceSetImpl();
    URI uri = URI.createFileURI(f.getAbsolutePath());
    Resource resource = resourceSet.getResource(uri, true);
   
    if (resource == null)
      throw new ModelLoadException(new NullPointerException("Unexpected null resource in '" + f + "'"));
   
    if (resource.getContents().size() != 1) {
View Full Code Here

   * @param o
   * @return
   * @throws ModelLoadException if the resource is null, or the resource contains too many elements
   */
  public static EObject load(IFile o) throws ModelLoadException {
    ResourceSet resourceSet = new ResourceSetImpl();
    URI uri = URI.createFileURI(o.getLocation().toString());
    Resource resource = resourceSet.getResource(uri, true);
   
    if (resource == null)
      throw new ModelLoadException(new NullPointerException("Unexpected null resource in '" + o + "'"));
   
    if (resource.getContents().size() != 1) {
View Full Code Here

TOP

Related Classes of org.eclipse.emf.ecore.resource.impl.ResourceSetImpl

Copyright © 2018 www.massapicom. 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.