Package org.eclipse.emf.ecore.resource

Examples of org.eclipse.emf.ecore.resource.ResourceSet


   * @return the de-serialized data graph.
   * @throws IOException
   */
  public static DataGraph loadDataGraph(InputStream inputStream, Map options) throws IOException
  {
    ResourceSet resourceSet = DataObjectUtil.createResourceSet();
    Resource resource = resourceSet.createResource(URI.createURI("all.datagraph"));
    resource.load(inputStream, options);
    return (DataGraph)resource.getContents().get(0);
  }
View Full Code Here


    for (final Iterator iterator = types.iterator(); iterator.hasNext(); ) {
      EClassifier type = (EClassifier)iterator.next()
      packages.add(type.getEPackage());
    }

    ResourceSet resourceSet = ((DataGraphImpl)dataGraph).getResourceSet();

    for (Iterator iterator = packages.iterator(); iterator.hasNext(); ) {
      EPackage typePackage = (EPackage)iterator.next();
      Resource resource = typePackage.eResource();
      if (resource == null) {
        resource = resourceSet.createResource(URI.createURI(".ecore"));
        resource.setURI(URI.createURI(typePackage.getNsURI()));
        resource.getContents().add(typePackage);
      }
      else if (resource.getResourceSet() != resourceSet)
        resourceSet.getResources().add(resource);
    }
  }
View Full Code Here

  protected List /*Type*/define(InputSource inputSource, String schemaLocation)
  {
    try
    {
      ResourceSet resourceSet = DataObjectUtil.createResourceSet();
      Resource model = resourceSet.createResource(URI.createURI(schemaLocation != null ? schemaLocation : "null.xsd"));
      ((XSDResourceImpl)model).load(inputSource, null);
     
      List newTypes = new ArrayList();
      for (Iterator schemaIter = model.getContents().iterator(); schemaIter.hasNext(); )
      {
View Full Code Here

     */
    private static Resource collectAllAndCopyIntoDestResource( Resource projectResource, String dest ) {
        // this is the contents of our project (ie maps and pages and other)
        // note these resources in the resource set (ie the raw form not objects)
        //
        ResourceSet resourceSet = projectResource.getResourceSet();

        // start with the project resource
        List<Resource> resources = gatherAllResourcesToList(projectResource);

        // let us make the new file to write out
        File destFile = new File(dest);
        String absoluteDestPath = destFile.getAbsolutePath();

        URI destURI = URI.createFileURI(absoluteDestPath);
        Resource destResource = resourceSet.createResource(destURI);

        Collection<EObject> collection = new ArrayList<EObject>();
        for( Resource curResource : resources ) {
            collection.addAll(curResource.getContents());
        }
View Full Code Here

            }

            URI registryURI = registryResource.getURI();
            projectURI.deresolve(registryURI, true, true, true);

            ResourceSet registeryResourceSet = registryResource.getResourceSet();
            Resource projectResource = registeryResourceSet.createResource(projectURI);
            try {
                projectResource.load(null);
            } catch (IOException e1) {
                // resource doesn't exist. That is ok.
            }
View Full Code Here

            }
            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

            if (ApplicationGIS.getActiveProject() == project)
                ProjectPlugin.getPlugin().getProjectRegistry().setCurrentProject(null);

            ProjectPlugin.getPlugin().getProjectRegistry().getProjects().remove(project);
            resource.getContents().clear();
            ResourceSet resourceSet = resource.getResourceSet();
            String path = resource.getURI().toFileString();

            resource.unload();

            if (deleteProjectFiles) {
                try {
                    resourceSet.getResources().remove(resource);
                    resource.unload();
                    int lastIndexOf = path.lastIndexOf('/');
                    if (lastIndexOf == -1)
                        lastIndexOf = path.length();
                    path = path.substring(0, lastIndexOf);
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

TOP

Related Classes of org.eclipse.emf.ecore.resource.ResourceSet

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.