Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: dadebb2d3e41f1978d4075dd3c869d378d44d107 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright (c) 2009, 2011, 2012, 2015 Eike Stepper (Berlin, Germany) and others.
 * 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:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.emf.cdo.examples;

import org.eclipse.emf.cdo.examples.company.Company;
import org.eclipse.emf.cdo.examples.company.CompanyPackage;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
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.impl.XMLResourceFactoryImpl;

import java.io.IOException;

/**
 * @author Eike Stepper
 * @since 2.0
 */
public class Webinar20090129
{
  private static final EPackage MODEL = CompanyPackage.eINSTANCE;

  public static void xmlSetup() throws IOException
  {
    ResourceSet rs = new ResourceSetImpl();
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap() //
    .put("xml", new XMLResourceFactoryImpl()); //$NON-NLS-1$
    rs.getPackageRegistry().put(MODEL.getNsURI(), MODEL);

    URI uri = URI.createFileURI("C:/business/company.xml"); //$NON-NLS-1$
    Resource resource = rs.getResource(uri, true);
    resource.setTrackingModification(true);

    Company company = (Company)resource.getContents().get(0);
    executeBusinessLogic(company);

    if (resource.isModified())
    {
      resource.save(null);
    }
  }

  private static void executeBusinessLogic(Company company)
  {
  }
}

Back to the top