本文整理汇总了Java中org.eclipse.emf.cdo.eresource.CDOResource.save方法的典型用法代码示例。如果您正苦于以下问题:Java CDOResource.save方法的具体用法?Java CDOResource.save怎么用?Java CDOResource.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.cdo.eresource.CDOResource
的用法示例。
在下文中一共展示了CDOResource.save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startCDOServer
import org.eclipse.emf.cdo.eresource.CDOResource; //导入方法依赖的package包/类
@BeforeClass
public static void startCDOServer() throws IOException, CommitException {
server = new CDOServer(false);
server.start();
IConnector connector = M2DocCDOUtils
.getConnector(CDOServer.PROTOCOL + "://" + CDOServer.IP + ":" + CDOServer.PORT);
CDOSession session = M2DocCDOUtils.openSession(connector, CDOServer.REPOSITORY_NAME, CDOServer.USER_NAME,
CDOServer.PASSWORD);
final CDOTransaction transaction = M2DocCDOUtils.openTransaction(session);
final CDOResource resource = transaction.createResource("anydsl.ecore");
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
final Resource anyDSLResource = resourceSet.getResource(URI.createFileURI("resources/anydsl.ecore"), true);
resource.getContents().addAll(anyDSLResource.getContents());
resource.save(null);
transaction.commit();
transaction.close();
session.close();
connector.close();
if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
ConfigurationProviderService.getInstance().register(CONFIGURATION_PROVIDER);
M2DocUtils.registerServicesConfigurator(SERVICES_CONFIGURATOR_DESCRIPTOR);
}
}
示例2: startCDOServer
import org.eclipse.emf.cdo.eresource.CDOResource; //导入方法依赖的package包/类
@BeforeClass
public static void startCDOServer() throws IOException, CommitException {
server = new CDOServer(true);
server.start();
IConnector connector = M2DocCDOUtils
.getConnector(CDOServer.PROTOCOL + "://" + CDOServer.IP + ":" + CDOServer.PORT);
CDOSession session = M2DocCDOUtils.openSession(connector, CDOServer.REPOSITORY_NAME, CDOServer.USER_NAME,
CDOServer.PASSWORD);
final CDOTransaction transaction = M2DocCDOUtils.openTransaction(session);
final CDOResource resource = transaction.createResource("anydsl.ecore");
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
final Resource anyDSLResource = resourceSet.getResource(URI.createFileURI("resources/anydsl.ecore"), true);
resource.getContents().addAll(anyDSLResource.getContents());
resource.save(null);
transaction.commit();
transaction.close();
session.close();
connector.close();
if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
ConfigurationProviderService.getInstance().register(CONFIGURATION_PROVIDER);
M2DocUtils.registerServicesConfigurator(SERVICES_CONFIGURATOR_DESCRIPTOR);
}
}
示例3: attacheObject
import org.eclipse.emf.cdo.eresource.CDOResource; //导入方法依赖的package包/类
@Test
public void attacheObject() throws Exception {
final CDOMappingBaseListener listener = new CDOMappingBaseListener();
final String path = this.getClass().getCanonicalName() + "/attacheObject.resource";
final CDOResource resource = transaction.createResource(path);
resource.save(null);
transaction.commit();
transaction.getSession().addListener(listener);
final ProductionCompany eObject = AnydslPackage.eINSTANCE.getAnydslFactory()
.createProductionCompany();
resource.getContents().add(eObject);
eObject.setName("MyCompany");
resource.save(null);
transaction.commit();
transaction.getSession().removeListener(listener);
assertEquals(0, MappingUtils.getMappingRegistry().getBases().size());
}
示例4: detacheObject
import org.eclipse.emf.cdo.eresource.CDOResource; //导入方法依赖的package包/类
@Test
public void detacheObject() throws Exception {
final CDOMappingBaseListener listener = new CDOMappingBaseListener();
final String path = this.getClass().getCanonicalName() + "/detacheObject.resource";
final CDOResource resource = transaction.createResource(path);
final ProductionCompany eObject = AnydslPackage.eINSTANCE.getAnydslFactory()
.createProductionCompany();
resource.getContents().add(eObject);
eObject.setName("MyCompany");
resource.save(null);
transaction.commit();
transaction.getSession().addListener(listener);
resource.getContents().clear();
resource.save(null);
transaction.commit();
transaction.getSession().removeListener(listener);
assertEquals(0, MappingUtils.getMappingRegistry().getBases().size());
}
示例5: attacheBase
import org.eclipse.emf.cdo.eresource.CDOResource; //导入方法依赖的package包/类
@Test
public void attacheBase() throws Exception {
final CDOMappingBaseListener listener = new CDOMappingBaseListener();
final String path = this.getClass().getCanonicalName() + "/attacheBase.resource";
final CDOResource resource = transaction.createResource(path);
resource.save(null);
transaction.commit();
transaction.getSession().addListener(listener);
final Base eObject = MappingPackage.eINSTANCE.getMappingFactory().createBase();
resource.getContents().add(eObject);
eObject.setName("MyBase");
resource.save(null);
transaction.commit();
transaction.getSession().removeListener(listener);
assertEquals(1, MappingUtils.getMappingRegistry().getBases().size());
assertEquals("MyBase", MappingUtils.getMappingRegistry().getBases().iterator().next().getName());
MappingUtils.getMappingRegistry().unregister(eObject);
}
示例6: detacheBase
import org.eclipse.emf.cdo.eresource.CDOResource; //导入方法依赖的package包/类
@Test
public void detacheBase() throws Exception {
final CDOMappingBaseListener listener = new CDOMappingBaseListener();
transaction.getSession().addListener(listener);
final String path = this.getClass().getCanonicalName() + "/detacheBase.resource";
final CDOResource resource = transaction.createResource(path);
final Base eObject = MappingPackage.eINSTANCE.getMappingFactory().createBase();
resource.getContents().add(eObject);
eObject.setName("MyBase");
resource.save(null);
transaction.commit();
assertEquals(1, MappingUtils.getMappingRegistry().getBases().size());
assertEquals("MyBase", MappingUtils.getMappingRegistry().getBases().iterator().next().getName());
resource.getContents().clear();
resource.save(null);
transaction.commit();
transaction.getSession().removeListener(listener);
assertEquals(0, MappingUtils.getMappingRegistry().getBases().size());
}
示例7: resourceContentChanged
import org.eclipse.emf.cdo.eresource.CDOResource; //导入方法依赖的package包/类
@Test
public void resourceContentChanged() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(ICDORepositoryLocation.class,
new BaseElementFactory.FactoryDescriptor<TestCDORepositoryLocation>(
TestCDORepositoryLocation.class));
base.getFactory().addDescriptor(ICDOResourceLocation.class,
new BaseElementFactory.FactoryDescriptor<TestCDOResourceLocation>(
TestCDOResourceLocation.class));
base.getFactory().addDescriptor(IEObjectLocation.class,
new BaseElementFactory.FactoryDescriptor<TestEObjectLocation>(TestEObjectLocation.class));
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final String path = this.getClass().getCanonicalName() + "/test.resource";
final CDOResource resource = otherTransaction.createResource(path);
final ProductionCompany eObject = AnydslPackage.eINSTANCE.getAnydslFactory()
.createProductionCompany();
resource.getContents().add(eObject);
eObject.setName("MyCompany");
resource.save(null);
otherTransaction.commit();
final ILocation container = MappingUtils.getConnectorRegistry().createLocation(base, transaction);
final ICDOResourceLocation resourceLocation = (ICDOResourceLocation)MappingUtils
.getConnectorRegistry().createLocation(container, resource);
final IEObjectLocation eObjectLocation = (IEObjectLocation)MappingUtils.getConnectorRegistry()
.createLocation(resourceLocation, eObject);
final String initialXMIContent = resourceLocation.getXMIContent();
final String initialURIFragment = eObjectLocation.getURIFragment();
assertNotNull(otherTransaction.getResourceNode(path));
assertFalse(container.getContents().isEmpty());
assertFalse(initialXMIContent == null || initialXMIContent.isEmpty());
assertFalse(initialURIFragment == null || initialURIFragment.isEmpty());
viewConnector.addBaseToUpdate(base);
eObject.setName("someNewName");
otherTransaction.commit();
viewConnector.removeBaseToUpdate(base);
assertFalse(resourceLocation.getXMIContent().isEmpty());
assertFalse(initialXMIContent.equals(resourceLocation.getXMIContent()));
assertTrue(initialURIFragment.equals(eObjectLocation.getURIFragment()));
}