本文整理汇总了Java中org.eclipse.emf.ecore.util.EcoreUtil.Copier类的典型用法代码示例。如果您正苦于以下问题:Java Copier类的具体用法?Java Copier怎么用?Java Copier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Copier类属于org.eclipse.emf.ecore.util.EcoreUtil包,在下文中一共展示了Copier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateSavedURIFragment
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
/**
* Updates {@link IEObjectLocation#getSavedURIFragment() saved URI fragment}.
*
* @param container
* the {@link ILocationContainer}
* @param eObjectContainer
* the {@link IEObjectContainer}
* @param newResource
* the new {@link Resource}
* @throws Exception
* if the XMI serialization failed or elements couldn't be created
*/
private static void updateSavedURIFragment(ILocationContainer container,
IEObjectContainer eObjectContainer, Resource newResource) throws Exception {
final IBase base = MappingUtils.getBase(container);
final Copier copier = new Copier();
final Collection<EObject> copiedContents = copier.copyAll(newResource.getContents());
copier.copyReferences();
final XMIResourceImpl newXMIResource = new XMIResourceImpl();
newXMIResource.getContents().addAll(copiedContents);
for (Entry<EObject, EObject> entry : copier.entrySet()) {
final EObject newEObject = entry.getKey();
final EObject savedEObject = entry.getValue();
final ICouple couple = base.getFactory().createElement(ICouple.class);
couple.setKey(newResource.getURIFragment(newEObject));
couple.setValue(newXMIResource.getURIFragment(savedEObject));
eObjectContainer.getSavedURIFragments().add(couple);
}
}
示例2: createNew
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Override
public BTSConfiguration createNew(BTSConfiguration originalconfiguration) {
BTSConfiguration config = createNew();
String dbcoll = config.getDBCollectionKey();
Copier copier = new Copier();
config = (BTSConfiguration) copier.copy(originalconfiguration);
// copyChildrenRecursively(config, originalconfiguration, copier);
// config = EmfModelHelper.mergeChanges(config, originalconfiguration);
config.getRevisions().clear();
config.getReaders().clear();
config.getUpdaters().clear();
config.setDBCollectionKey(dbcoll);
config.setProject(main_project);
super.setId(config, config.getDBCollectionKey());
super.setRevision(config);
return config;
}
示例3: reload
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Override
public E reload(K key, String path)
{
URI uri = URI.createURI(getRemoteDBURL() + "/" + path + "/" + key.toString());
Resource resource = connectionProvider.getEmfResourceSet().getResource(uri, true);
EObject eObject = resource.getContents().get(0);
Copier copier = new Copier();
EClass eClass = eObject.eClass();
if (resource.getContents().size() > 0)
{
ResourceSet tempResourceSet = new ResourceSetImpl();
tempResourceSet.getURIConverter().getURIHandlers().add(0, new CouchDBHandler());
Resource tempResource = tempResourceSet.getResource(uri, true);
EObject copyEObject = tempResource.getContents().get(0);
if (copyEObject instanceof BTSDBBaseObject)
{
eObject = EmfModelHelper.mergeChanges(eObject, copyEObject);
return (E) eObject;
}
}
return null;
}
示例4: makeCopyOfBinaryConstraintForNewPlan
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
private static BinaryTemporalConstraint makeCopyOfBinaryConstraintForNewPlan(
BinaryTemporalConstraint constraint,
Map<String, EPlanChild> idsInDestination) {
BinaryTemporalConstraint result = (BinaryTemporalConstraint) new Copier().copy(constraint);
EPlanChild newA = idsInDestination.get(getDiffId(constraint.getPointA().getElement()));
if (newA == null)
newA = getSameActivityFromPlanMap(idsInDestination, constraint.getPointA().getElement());
EPlanChild newB = idsInDestination.get(getDiffId(constraint.getPointB().getElement()));
if (newB == null)
newB = getSameActivityFromPlanMap(idsInDestination, constraint.getPointB().getElement());
if (newA == null || newB == null) return null;
result.getPointA().setElement(newA);
result.getPointB().setElement(newB);
return result;
}
示例5: initLocationEObject
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Test
public void initLocationEObject() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
final List<EObject> eObjects = new ArrayList<EObject>(copier.copyAll(AnydslPackage.eINSTANCE
.eContents()));
copier.copyReferences();
final EClass producerEClass = (EClass)copier.get(AnydslPackage.eINSTANCE.getProducer());
final Resource resource = createResource("test.xmi");
resource.getContents().addAll(eObjects);
container.setResource(resource);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
final IEObjectLocation location = new TestEObjectLocation();
location.setContainer(container);
final TestEObjectContainerConnector testEObjectContainerConnector = new TestEObjectContainerConnector();
MappingUtils.getConnectorRegistry().register(testEObjectContainerConnector);
final EObjectConnector eObjectConnector = new EObjectConnector();
MappingUtils.getConnectorRegistry().register(eObjectConnector);
super.initLocation(container, location, producerEClass);
final Object element = eObjectConnector.getElement(location);
assertTrue(element instanceof EObject);
assertEquals(producerEClass, element);
assertNull(location.getFeatureName());
MappingUtils.getConnectorRegistry().unregister(testEObjectContainerConnector);
MappingUtils.getConnectorRegistry().unregister(eObjectConnector);
}
示例6: initLocationSetting
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Test
public void initLocationSetting() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
final List<EObject> eObjects = new ArrayList<EObject>(copier.copyAll(AnydslPackage.eINSTANCE
.eContents()));
copier.copyReferences();
final EClass producerEClass = (EClass)copier.get(AnydslPackage.eINSTANCE.getProducer());
final Resource resource = createResource("test.xmi");
resource.getContents().addAll(eObjects);
container.setResource(resource);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
final IEObjectLocation location = new TestEObjectLocation();
location.setContainer(container);
final TestEObjectContainerConnector testEObjectContainerConnector = new TestEObjectContainerConnector();
MappingUtils.getConnectorRegistry().register(testEObjectContainerConnector);
final EObjectConnector eObjectConnector = new EObjectConnector();
MappingUtils.getConnectorRegistry().register(eObjectConnector);
super.initLocation(container, location, ((InternalEObject)producerEClass).eSetting(
EcorePackage.eINSTANCE.getENamedElement_Name()));
final Object element = eObjectConnector.getElement(location);
assertTrue(element instanceof Setting);
assertEquals(producerEClass, ((Setting)element).getEObject());
assertEquals(EcorePackage.eINSTANCE.getENamedElement_Name(), ((Setting)element)
.getEStructuralFeature());
assertEquals("Producer", ((Setting)element).get(true));
assertEquals(EcorePackage.eINSTANCE.getENamedElement_Name().getName(), location.getFeatureName());
MappingUtils.getConnectorRegistry().unregister(testEObjectContainerConnector);
MappingUtils.getConnectorRegistry().unregister(eObjectConnector);
}
示例7: getLocationEObject
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Test
public void getLocationEObject() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
final List<EObject> eObjects = new ArrayList<EObject>(copier.copyAll(AnydslPackage.eINSTANCE
.eContents()));
copier.copyReferences();
final EClass producerEClass = (EClass)copier.get(AnydslPackage.eINSTANCE.getProducer());
final Resource resource = createResource("test.xmi");
resource.getContents().addAll(eObjects);
container.setResource(resource);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
final IEObjectLocation location = new TestEObjectLocation();
location.setContainer(container);
container.getContents().add(location);
final TestEObjectContainerConnector connector = new TestEObjectContainerConnector();
MappingUtils.getConnectorRegistry().register(connector);
super.initLocation(container, location, producerEClass);
assertEquals(location, super.getLocation(container, producerEClass));
assertEquals(null, super.getLocation(container, ((InternalEObject)producerEClass).eSetting(
EcorePackage.eINSTANCE.getENamedElement_Name())));
MappingUtils.getConnectorRegistry().unregister(connector);
}
示例8: getLocationSetting
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Test
public void getLocationSetting() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
final List<EObject> eObjects = new ArrayList<EObject>(copier.copyAll(AnydslPackage.eINSTANCE
.eContents()));
final EClass producerEClass = (EClass)copier.get(AnydslPackage.eINSTANCE.getProducer());
copier.copyReferences();
final Resource resource = createResource("test.xmi");
resource.getContents().addAll(eObjects);
container.setResource(resource);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, resource);
final IEObjectLocation location = new TestEObjectLocation();
location.setContainer(container);
container.getContents().add(location);
final TestEObjectContainerConnector connector = new TestEObjectContainerConnector();
MappingUtils.getConnectorRegistry().register(connector);
super.initLocation(container, location, ((InternalEObject)producerEClass).eSetting(
EcorePackage.eINSTANCE.getENamedElement_Name()));
assertEquals(null, super.getLocation(container, producerEClass));
assertEquals(location, super.getLocation(container, ((InternalEObject)producerEClass).eSetting(
EcorePackage.eINSTANCE.getENamedElement_Name())));
MappingUtils.getConnectorRegistry().unregister(connector);
}
示例9: updateEObjects
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Test
public void updateEObjects() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(IEObjectLocation.class,
new BaseElementFactory.FactoryDescriptor<TestEObjectLocation>(TestEObjectLocation.class));
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
EPackage copy = (EPackage)copier.copy(AnydslPackage.eINSTANCE);
copier.copyReferences();
final List<EObject> testEObjects = new ArrayList<EObject>(copy.getEClassifiers());
final Resource initialResource = createResource("initialResource");
container.setResource(initialResource);
initialResource.getContents().addAll(testEObjects);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, initialResource);
final IEObjectLocation location = createEObjectLocation(copier, container);
final EObject expectedEObject = copier.get(original[0]);
final EStructuralFeature expectedFeature = (EStructuralFeature)original[1];
final Object expectedValue;
if (original[2] instanceof EObject) {
expectedValue = copier.get(original[2]);
} else {
expectedValue = original[2];
}
List<EObject> newEObjects = testEObjects;
final Resource newResource = createResource("newResource");
newResource.getContents().addAll(newEObjects);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, newResource);
container.setResource(newResource);
assertEObjectLocation(location, expectedEObject, expectedFeature, expectedValue);
}
示例10: updateEObjectsPlusShift
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Test
public void updateEObjectsPlusShift() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(IEObjectLocation.class,
new BaseElementFactory.FactoryDescriptor<TestEObjectLocation>(TestEObjectLocation.class));
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
EPackage copy = (EPackage)copier.copy(AnydslPackage.eINSTANCE);
copier.copyReferences();
final List<EObject> testEObjects = new ArrayList<EObject>(copy.getEClassifiers());
final Resource initialResource = createResource("initialResource");
container.setResource(initialResource);
initialResource.getContents().addAll(testEObjects);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, initialResource);
final IEObjectLocation location = createEObjectLocation(copier, container);
final EObject expectedEObject = copier.get(original[0]);
final EStructuralFeature expectedFeature = (EStructuralFeature)original[1];
final Object expectedValue;
if (original[2] instanceof EObject) {
expectedValue = copier.get(original[2]);
} else {
expectedValue = original[2];
}
List<EObject> newEObjects = new ArrayList<EObject>(MappingPackage.eINSTANCE.getEClassifiers());
newEObjects.addAll(testEObjects);
final Resource newResource = createResource("newResource");
newResource.getContents().addAll(newEObjects);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, newResource);
container.setResource(newResource);
assertEObjectLocation(location, expectedEObject, expectedFeature, expectedValue);
}
示例11: updateEObjectsMinusShift
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Test
public void updateEObjectsMinusShift() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(IEObjectLocation.class,
new BaseElementFactory.FactoryDescriptor<TestEObjectLocation>(TestEObjectLocation.class));
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
EPackage copy = (EPackage)copier.copy(AnydslPackage.eINSTANCE);
copier.copyReferences();
final List<EObject> testEObjects = new ArrayList<EObject>(copy.getEClassifiers());
final Resource initialResource = createResource("initialResource");
container.setResource(initialResource);
initialResource.getContents().addAll(testEObjects);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, initialResource);
final IEObjectLocation location = createEObjectLocation(copier, container);
final EObject expectedEObject = copier.get(original[0]);
final EStructuralFeature expectedFeature = (EStructuralFeature)original[1];
final Object expectedValue;
if (original[2] instanceof EObject) {
expectedValue = copier.get(original[2]);
} else {
expectedValue = original[2];
}
List<EObject> newEObjects = new ArrayList<EObject>(testEObjects);
newEObjects.remove(0);
newEObjects.remove(0);
final Resource newResource = createResource("newResource");
newResource.getContents().addAll(newEObjects);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, newResource);
container.setResource(newResource);
assertEObjectLocation(location, expectedEObject, expectedFeature, expectedValue);
}
示例12: updateEObjectsRemoved
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Test
public void updateEObjectsRemoved() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(IEObjectLocation.class,
new BaseElementFactory.FactoryDescriptor<TestEObjectLocation>(TestEObjectLocation.class));
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
EPackage copy = (EPackage)copier.copy(AnydslPackage.eINSTANCE);
copier.copyReferences();
final List<EObject> testEObjects = new ArrayList<EObject>(copy.getEClassifiers());
final Resource initialResource = createResource("initialResource");
container.setResource(initialResource);
initialResource.getContents().addAll(testEObjects);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, initialResource);
final IEObjectLocation location = createEObjectLocation(copier, container);
final EObject expectedEObject = null;
final EStructuralFeature expectedFeature = null;
final Object expectedValue = null;
List<EObject> newEObjects = testEObjects;
if (testEObjects.contains(copier.get(original[0]))) {
testEObjects.remove(copier.get(original[0]));
} else {
EcoreUtil.delete(copier.get(original[0]));
}
final Resource newResource = createResource("newResource");
newResource.getContents().addAll(newEObjects);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, newResource);
container.setResource(newResource);
assertEObjectLocation(location, expectedEObject, expectedFeature, expectedValue);
}
示例13: updateEObjectsPlusShiftRemoved
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Test
public void updateEObjectsPlusShiftRemoved() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(IEObjectLocation.class,
new BaseElementFactory.FactoryDescriptor<TestEObjectLocation>(TestEObjectLocation.class));
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
EPackage copy = (EPackage)copier.copy(AnydslPackage.eINSTANCE);
copier.copyReferences();
final List<EObject> testEObjects = new ArrayList<EObject>(copy.getEClassifiers());
final Resource initialResource = createResource("initialResource");
container.setResource(initialResource);
initialResource.getContents().addAll(testEObjects);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, initialResource);
final IEObjectLocation location = createEObjectLocation(copier, container);
final EObject expectedEObject = null;
final EStructuralFeature expectedFeature = null;
final Object expectedValue = null;
List<EObject> newEObjects = testEObjects;
if (testEObjects.contains(copier.get(original[0]))) {
testEObjects.remove(copier.get(original[0]));
} else {
EcoreUtil.delete(copier.get(original[0]));
}
newEObjects.addAll(0, MappingPackage.eINSTANCE.getEClassifiers());
final Resource newResource = createResource("newResource");
newResource.getContents().addAll(newEObjects);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, newResource);
container.setResource(newResource);
assertEObjectLocation(location, expectedEObject, expectedFeature, expectedValue);
}
示例14: updateEObjectsMinusShiftRemoved
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Test
public void updateEObjectsMinusShiftRemoved() throws Exception {
final IBase base = new BaseRegistryTests.TestBase();
base.getFactory().addDescriptor(IEObjectLocation.class,
new BaseElementFactory.FactoryDescriptor<TestEObjectLocation>(TestEObjectLocation.class));
base.getFactory().addDescriptor(ICouple.class, new BaseElementFactory.FactoryDescriptor<TestCouple>(
TestCouple.class));
final TestEObjectContainerLocation container = new TestEObjectContainerLocation();
container.setContainer(base);
final Copier copier = new Copier();
EPackage copy = (EPackage)copier.copy(AnydslPackage.eINSTANCE);
copier.copyReferences();
final List<EObject> testEObjects = new ArrayList<EObject>(copy.getEClassifiers());
final Resource initialResource = createResource("initialResource");
container.setResource(initialResource);
initialResource.getContents().addAll(testEObjects);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, initialResource);
final IEObjectLocation location = createEObjectLocation(copier, container);
final EObject expectedEObject = null;
final EStructuralFeature expectedFeature = null;
final Object expectedValue = null;
List<EObject> newEObjects = testEObjects;
if (testEObjects.contains(copier.get(original[0]))) {
testEObjects.remove(copier.get(original[0]));
} else {
EcoreUtil.delete(copier.get(original[0]));
}
newEObjects.remove(0);
newEObjects.remove(0);
final Resource newResource = createResource("newResource");
newResource.getContents().addAll(newEObjects);
eObjectContainerHelper.updateEObjectContainer(container.getContainer(), container, newResource);
container.setResource(newResource);
assertEObjectLocation(location, expectedEObject, expectedFeature, expectedValue);
}
示例15: reload
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
@Override
public E reload(K key, String path)
{
URI uri = URI.createURI(getLocalDBURL() + "/" + path + "/" + key.toString());
// Resource resource = connectionProvider.getEmfResourceSet().getResource(uri, true);
// URI uri = URI.createURI(getLocalDBURL() + "/" + dbPath + "/" + objectId);
Map map = ((ResourceSetImpl) connectionProvider.getEmfResourceSet()).getURIResourceMap();
if (map.containsKey(uri))
{
Resource resource = (Resource) map.get(uri);
EObject eObject = resource.getContents().get(0);
Copier copier = new Copier();
EClass eClass = eObject.eClass();
if (resource.getContents().size() > 0) {
ResourceSet tempResourceSet = new ResourceSetImpl();
tempResourceSet.getURIConverter().getURIHandlers()
.add(0, new CouchDBHandler());
Resource tempResource = tempResourceSet.getResource(uri, true);
// if empty return old
if (tempResource.getContents().isEmpty()) return (E) eObject;
EObject copyEObject = tempResource.getContents().get(0);
if (copyEObject instanceof BTSDBBaseObject) {
eObject = EmfModelHelper.mergeChanges(eObject, copyEObject);
checkForConflicts( (E) eObject, path);
return (E) eObject;
}
}
}
else
{
return find(key, path);
}
return null;
}