本文整理汇总了Java中org.eclipse.emf.ecore.util.EcoreUtil.Copier类的典型用法代码示例。如果您正苦于以下问题:Java Copier类的具体用法?Java Copier怎么用?Java Copier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Copier类属于org.eclipse.emf.ecore.util.EcoreUtil包,在下文中一共展示了Copier类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:ModelWriter,项目名称:Source,代码行数:32,代码来源:EObjectConnector.java
示例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;
}
开发者ID:cplutte,项目名称:bts,代码行数:20,代码来源:BTSConfigurationServiceImpl.java
示例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;
}
开发者ID:cplutte,项目名称:bts,代码行数:26,代码来源:RemoteCouchDBDao.java
示例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;
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:18,代码来源:SPIFePlanIntegrationOperation.java
示例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);
}
开发者ID:ModelWriter,项目名称:Source,代码行数:34,代码来源:EObjectConnectorTests.java
示例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);
}
开发者ID:ModelWriter,项目名称:Source,代码行数:38,代码来源:EObjectConnectorTests.java
示例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);
}
开发者ID:ModelWriter,项目名称:Source,代码行数:31,代码来源:EObjectConnectorTests.java
示例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);
}
开发者ID:ModelWriter,项目名称:Source,代码行数:32,代码来源:EObjectConnectorTests.java
示例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);
}
开发者ID:ModelWriter,项目名称:Source,代码行数:38,代码来源:EObjectConnectorParametrizedTests.java
示例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);
}
开发者ID:ModelWriter,项目名称:Source,代码行数:39,代码来源:EObjectConnectorParametrizedTests.java
示例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);
}
开发者ID:ModelWriter,项目名称:Source,代码行数:40,代码来源:EObjectConnectorParametrizedTests.java
示例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);
}
开发者ID:ModelWriter,项目名称:Source,代码行数:38,代码来源:EObjectConnectorParametrizedTests.java
示例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);
}
开发者ID:ModelWriter,项目名称:Source,代码行数:40,代码来源:EObjectConnectorParametrizedTests.java
示例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);
}
开发者ID:ModelWriter,项目名称:Source,代码行数:41,代码来源:EObjectConnectorParametrizedTests.java
示例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;
}
开发者ID:cplutte,项目名称:bts,代码行数:39,代码来源:CouchDBDao.java
示例16: mergeChanges
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
public static <T extends EObject> T mergeChanges(T target, T objectWithChanges)
{
Copier copier = new Copier();
for (int i = 0, size = target.eClass().getFeatureCount(); i < size; ++i)
{
EStructuralFeature eStructuralFeature = target.eClass().getEStructuralFeature(i);
if (eStructuralFeature.isChangeable() && !eStructuralFeature.isDerived())
{
if (eStructuralFeature instanceof EAttribute)
{
// if (eStructuralFeature.getName().equals("name"))
// {
// System.out.println("name");
// }
copyAttribute((EAttribute) eStructuralFeature, objectWithChanges, target, copier);
} else
{
EReference eReference = (EReference) eStructuralFeature;
if (eReference.isContainment())
{
copyContainment(eReference, objectWithChanges, target, copier);
}
}
}
}
return (T) target;
}
开发者ID:cplutte,项目名称:bts,代码行数:28,代码来源:EmfModelHelper.java
示例17: createModelResource
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
private static Copier createModelResource(Copier copier, ResourceSet currentResourceSet,
Resource historicResource) {
Resource newResource = currentResourceSet.getResource(historicResource.getURI(), true);
newResource.getContents().clear();
newResource.getContents().addAll(copier.copyAll(historicResource.getContents()));
return copier;
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:8,代码来源:ResetToPreviousStateCommand.java
示例18: makeCopyOfChainConstraintForNewPlan
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
private static TemporalChain makeCopyOfChainConstraintForNewPlan(TemporalChain constraint, Map<String, EPlanChild> idsInDestination) {
if (constraint == null) return null;
TemporalChain result = (TemporalChain) new Copier().copy(constraint);
List<EPlanElement> elements = constraint.getElements();
List<EPlanElement> newElements = new ArrayList<EPlanElement>();
for (EPlanElement element : elements){
EPlanChild newElement = idsInDestination.get(getDiffId(element));
newElements.add(newElement);
}
EStructuralFeature eStructuralFeature = ConstraintsPackage.Literals.TEMPORAL_CHAIN__ELEMENTS;
result.eSet(eStructuralFeature, newElements);
return result;
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:16,代码来源:SPIFePlanIntegrationOperation.java
示例19: addToCopier
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
private static void addToCopier(Copier copier, Resource r, String metamodelName,
MetamodelNamespace ns) {
copier.copyAll(ns.getResource().getContents());
copier.copyReferences();
EPackage newRoot = getRoot(metamodelName, ns.getResource(), copier);
r.getContents().add(newRoot);
}
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:9,代码来源:SourceMetamodelsData.java
示例20: extend
import org.eclipse.emf.ecore.util.EcoreUtil.Copier; //导入依赖的package包/类
/**
* Copies everything that is not already in the errorMM from the languageMM.
*/
public void extend(EPackage errorMM, MetaModel effectiveMM, MetaModel languageMM) {
System.out.println("Using 'Full Metamodel' strategy");
Copier copier = new Copier();
for (EClassifier lc : languageMM.getEClassifiers()) {
EClassifier errorClassifier = errorMM.getEClassifier(lc.getName());
if ( errorClassifier == null ) {
EClassifier newClass = (EClassifier) copier.copy(lc);
errorMM.getEClassifiers().add(newClass);
continue;
}
// Now map lc to errorClassifier in the copier in case they need to be resolved
copier.put(lc, errorClassifier);
if ( errorClassifier instanceof EClass ){
EClass errorClass = (EClass) errorClassifier;
EClass langClass = (EClass) lc;
for (EStructuralFeature f : langClass.getEStructuralFeatures()) {
if ( errorClass.getEStructuralFeature(f.getName()) == null ) {
EStructuralFeature newFeature = (EStructuralFeature) copier.copy(f);
errorClass.getEStructuralFeatures().add(newFeature);
} else {
copier.put(f, errorClass.getEStructuralFeature(f.getName()));
}
}
}
}
copier.copyReferences();
removeUnnecessaryElements(errorMM);
}
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:39,代码来源:FullMetamodelStrategy.java
注:本文中的org.eclipse.emf.ecore.util.EcoreUtil.Copier类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论