From 16e7a394501e24bf5c7261811691229615734b31 Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Fri, 19 Feb 2021 15:37:07 +0100 Subject: [PATCH] Remove TUIDs --- .../domains/demo/VitruvDemoDomain.xtend | 9 +- .../generator/domain/ConceptDomain.xtend | 4 - .../domain/ConceptDomainGenerator.xtend | 10 +- .../RoutineClassGenerator.xtend | 6 - .../IntermediateVitruvDomain.xtend | 17 +- .../impl/IntermediateResourceBridgeI.xtend | 2 - .../META-INF/MANIFEST.MF | 3 + .../AbstractReactionRealization.xtend | 6 - .../AbstractRepairRoutineRealization.xtend | 4 - .../reactions/ReactionElementsHandler.xtend | 2 - .../effects/ReactionElementsHandlerImpl.xtend | 21 -- .../META-INF/MANIFEST.MF | 3 +- bundles/framework/pom.xml | 1 - .../META-INF/MANIFEST.MF | 3 +- .../META-INF/MANIFEST.MF | 4 +- .../impl/ConcreteApplicableChangeImpl.xtend | 25 -- .../META-INF/MANIFEST.MF | 6 +- .../metamodel/correspondence.ecore | 5 - .../metamodel/correspondence.genmodel | 3 - .../CorrespondenceModelFactory.xtend | 8 +- .../correspondence/CorrespondenceUtil.xtend | 20 -- .../InternalCorrespondenceModelImpl.xtend | 277 ++------------- .../META-INF/MANIFEST.MF | 1 + .../META-INF/MANIFEST.MF | 2 +- .../AbstractTuidAwareVitruvDomain.xtend | 91 ----- .../domains/AbstractVitruvDomain.xtend | 13 - .../domains/TuidAwareVitruvDomain.xtend | 18 - .../framework/domains/VitruvDomain.xtend | 9 - .../domains/repository/VitruvDomainPair.java | 54 --- .../repository/VitruvDomainRepository.java | 3 - .../VitruvDomainRepositoryImpl.java | 14 - .../tools.vitruv.framework.tuid/.classpath | 21 -- .../tools.vitruv.framework.tuid/.project | 34 -- .../.tests-without-platform | 0 .../META-INF/MANIFEST.MF | 14 - .../build.properties | 6 - .../tools/vitruv/framework/tuid/TuidTest.java | 334 ------------------ .../AttributeTuidCalculatorAndResolver.java | 65 ---- ...HierarchicalTuidCalculatorAndResolver.java | 211 ----------- .../tools/vitruv/framework/tuid/Tuid.xtend | 258 -------------- .../framework/tuid/Tuid4Serialization.java | 25 -- .../framework/tuid/TuidCalculator.xtend | 8 - .../tuid/TuidCalculatorAndResolver.java | 64 ---- .../tuid/TuidCalculatorAndResolverBase.xtend | 323 ----------------- .../tuid/TuidCalculatorUtilities.java | 38 -- .../vitruv/framework/tuid/TuidManager.xtend | 127 ------- .../vitruv/framework/tuid/TuidResolver.xtend | 7 - .../framework/tuid/TuidUpdateListener.xtend | 6 - .../framework/util/VitruviusConstants.java | 11 - .../vsum/ui/util/VitruvInstanceCreator.xtend | 2 - .../framework/vsum/VirtualModelBuilder.xtend | 4 - .../framework/vsum/VirtualModelImpl.xtend | 5 +- .../repositories/ResourceRepositoryImpl.xtend | 6 - .../vsum/repositories/TuidResolverImpl.xtend | 70 ---- .../META-INF/MANIFEST.MF | 1 + .../testutils/domains/VitruvTestDomain.xtend | 9 +- .../META-INF/MANIFEST.MF | 1 + .../tools/vitruv/testutils/TestLogging.xtend | 4 - .../testutils/VitruvApplicationTest.xtend | 2 - .../ConcreteTuidAwareVitruvDomain.xtend | 19 - .../feature.xml | 1 - .../feature.xml | 7 - .../META-INF/MANIFEST.MF | 1 + .../tests/vsum/CorrespondenceTest.xtend | 4 - .../tests/vsum/DefaultTuidCalculatorTest.java | 83 ----- .../framework/tests/vsum/TuidCacheTest.java | 212 ----------- .../vitruv/framework/tests/vsum/VsumTest.java | 11 +- 67 files changed, 71 insertions(+), 2567 deletions(-) delete mode 100644 bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/AbstractTuidAwareVitruvDomain.xtend delete mode 100644 bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/TuidAwareVitruvDomain.xtend delete mode 100644 bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/repository/VitruvDomainPair.java delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/.classpath delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/.project delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/.tests-without-platform delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/META-INF/MANIFEST.MF delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/build.properties delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/src-test/tools/vitruv/framework/tuid/TuidTest.java delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/AttributeTuidCalculatorAndResolver.java delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/HierarchicalTuidCalculatorAndResolver.java delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/Tuid.xtend delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/Tuid4Serialization.java delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculator.xtend delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculatorAndResolver.java delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculatorAndResolverBase.xtend delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculatorUtilities.java delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidManager.xtend delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidResolver.xtend delete mode 100644 bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidUpdateListener.xtend delete mode 100644 bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/repositories/TuidResolverImpl.xtend delete mode 100644 bundles/testutils/tools.vitruv.testutils/src/tools/vitruv/testutils/domains/ConcreteTuidAwareVitruvDomain.xtend delete mode 100644 tests/framework/tools.vitruv.framework.vsum.tests/src/tools/vitruv/framework/tests/vsum/DefaultTuidCalculatorTest.java delete mode 100644 tests/framework/tools.vitruv.framework.vsum.tests/src/tools/vitruv/framework/tests/vsum/TuidCacheTest.java diff --git a/bundles/domains/tools.vitruv.domains.demo/src/tools/vitruv/domains/demo/VitruvDemoDomain.xtend b/bundles/domains/tools.vitruv.domains.demo/src/tools/vitruv/domains/demo/VitruvDemoDomain.xtend index 38312c9d63..3682f3058b 100644 --- a/bundles/domains/tools.vitruv.domains.demo/src/tools/vitruv/domains/demo/VitruvDemoDomain.xtend +++ b/bundles/domains/tools.vitruv.domains.demo/src/tools/vitruv/domains/demo/VitruvDemoDomain.xtend @@ -1,16 +1,13 @@ package tools.vitruv.domains.demo -import tools.vitruv.framework.domains.AbstractTuidAwareVitruvDomain import org.eclipse.emf.ecore.EPackage import org.eclipse.emf.ecore.EAttribute -import tools.vitruv.framework.tuid.AttributeTuidCalculatorAndResolver +import tools.vitruv.framework.domains.AbstractVitruvDomain -abstract class VitruvDemoDomain extends AbstractTuidAwareVitruvDomain { +abstract class VitruvDemoDomain extends AbstractVitruvDomain { new(String name, EPackage metamodelRootPackage, Iterable identifyingAttributes, String... fileExtensions) { - super(name, metamodelRootPackage, - new AttributeTuidCalculatorAndResolver(metamodelRootPackage.nsURI, identifyingAttributes.map[it.name]), - fileExtensions) + super(name, metamodelRootPackage, fileExtensions) } override isUserVisible() { diff --git a/bundles/dsls/tools.vitruv.dsls.commonalities/src/tools/vitruv/dsls/commonalities/generator/domain/ConceptDomain.xtend b/bundles/dsls/tools.vitruv.dsls.commonalities/src/tools/vitruv/dsls/commonalities/generator/domain/ConceptDomain.xtend index 01da20a18b..0d6b5d4220 100644 --- a/bundles/dsls/tools.vitruv.dsls.commonalities/src/tools/vitruv/dsls/commonalities/generator/domain/ConceptDomain.xtend +++ b/bundles/dsls/tools.vitruv.dsls.commonalities/src/tools/vitruv/dsls/commonalities/generator/domain/ConceptDomain.xtend @@ -2,10 +2,8 @@ package tools.vitruv.dsls.commonalities.generator.domain import org.eclipse.emf.ecore.EPackage import tools.vitruv.extensions.dslruntime.commonalities.IntermediateVitruvDomain -import tools.vitruv.extensions.dslruntime.commonalities.intermediatemodelbase.IntermediateModelBasePackage import tools.vitruv.framework.domains.VitruvDomain import tools.vitruv.framework.domains.VitruvDomainProvider -import tools.vitruv.framework.tuid.AttributeTuidCalculatorAndResolver import static extension tools.vitruv.dsls.commonalities.generator.domain.ConceptDomainConstants.* import static extension tools.vitruv.dsls.commonalities.generator.intermediatemodel.IntermediateModelConstants.* @@ -25,8 +23,6 @@ class ConceptDomain extends IntermediateVitruvDomain { new(String conceptName, EPackage conceptPackage) { super(conceptName.conceptDomainName, conceptPackage, - new AttributeTuidCalculatorAndResolver(conceptPackage.nsURI, - IntermediateModelBasePackage.eINSTANCE.intermediate_IntermediateId.name), conceptName.intermediateModelFileExtension) provider = new Provider(this, conceptName.conceptDomainProviderClassName.qualifiedName) } diff --git a/bundles/dsls/tools.vitruv.dsls.commonalities/src/tools/vitruv/dsls/commonalities/generator/domain/ConceptDomainGenerator.xtend b/bundles/dsls/tools.vitruv.dsls.commonalities/src/tools/vitruv/dsls/commonalities/generator/domain/ConceptDomainGenerator.xtend index 8e98e815a0..a50593f6c8 100644 --- a/bundles/dsls/tools.vitruv.dsls.commonalities/src/tools/vitruv/dsls/commonalities/generator/domain/ConceptDomainGenerator.xtend +++ b/bundles/dsls/tools.vitruv.dsls.commonalities/src/tools/vitruv/dsls/commonalities/generator/domain/ConceptDomainGenerator.xtend @@ -16,9 +16,7 @@ import org.eclipse.xtext.xbase.compiler.JvmModelGenerator import org.eclipse.xtext.xbase.jvmmodel.JvmTypeReferenceBuilder import tools.vitruv.dsls.commonalities.generator.SubGenerator import tools.vitruv.extensions.dslruntime.commonalities.IntermediateVitruvDomain -import tools.vitruv.extensions.dslruntime.commonalities.intermediatemodelbase.IntermediateModelBasePackage import tools.vitruv.framework.domains.VitruvDomainProvider -import tools.vitruv.framework.tuid.AttributeTuidCalculatorAndResolver import static extension tools.vitruv.dsls.commonalities.generator.domain.ConceptDomainConstants.* import static extension tools.vitruv.dsls.commonalities.generator.intermediatemodel.IntermediateModelConstants.* @@ -66,13 +64,7 @@ class ConceptDomainGenerator implements SubGenerator { visibility = JvmVisibility.PUBLIC body = ''' super("«conceptName.conceptDomainName»", - «'''«conceptName.intermediateMetamodelPackageClassName.simpleName»'''».eINSTANCE,« - »« - // Tuid calculation: Uses the 'intermediateId' attribute - // This attribute delegates to 'fullPath' for intermediate resource bridges - // TODO remove once resource creation is handled by domains - » - new «AttributeTuidCalculatorAndResolver.typeRef»("«conceptName.intermediateMetamodelPackage.nsURI»", "«IntermediateModelBasePackage.eINSTANCE.intermediate_IntermediateId.name»"), + «'''«conceptName.intermediateMetamodelPackageClassName.simpleName»'''».eINSTANCE, "«conceptName.intermediateModelFileExtension»");''' ] ) diff --git a/bundles/dsls/tools.vitruv.dsls.reactions/src/tools/vitruv/dsls/reactions/codegen/classgenerators/RoutineClassGenerator.xtend b/bundles/dsls/tools.vitruv.dsls.reactions/src/tools/vitruv/dsls/reactions/codegen/classgenerators/RoutineClassGenerator.xtend index ee0d2c521d..a1cd0edf9c 100644 --- a/bundles/dsls/tools.vitruv.dsls.reactions/src/tools/vitruv/dsls/reactions/codegen/classgenerators/RoutineClassGenerator.xtend +++ b/bundles/dsls/tools.vitruv.dsls.reactions/src/tools/vitruv/dsls/reactions/codegen/classgenerators/RoutineClassGenerator.xtend @@ -179,9 +179,6 @@ class RoutineClassGenerator extends ClassGenerator { «IF !name.nullOrEmpty»«List»<«typeName»> «name» = «ENDIF»getCorrespondingElements( «generalArguments» ); - for (EObject _element : «name») { - registerObjectUnderModification(_element); - } ''' currentlyAccessibleElements += new AccessibleElement(name, List.name, typeName); return statement; @@ -212,7 +209,6 @@ class RoutineClassGenerator extends ClassGenerator { if («name» == null) { return false; }«ENDIF» - registerObjectUnderModification(«IF retrieveElement.optional»«name».isPresent() ? «name».get() : null«ELSE»«name»«ENDIF»); ''' if (retrieveElement.optional) { currentlyAccessibleElements += new AccessibleElement(name, Optional.name, typeName); @@ -330,8 +326,6 @@ class RoutineClassGenerator extends ClassGenerator { «effectStatementsMap.get(effectStatement)» «ENDFOR» - postprocessElements(); - return true; ''' ]; diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.commonalities/src/tools/vitruv/extensions/dslruntime/commonalities/IntermediateVitruvDomain.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.commonalities/src/tools/vitruv/extensions/dslruntime/commonalities/IntermediateVitruvDomain.xtend index 8580632812..820e0e507c 100644 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.commonalities/src/tools/vitruv/extensions/dslruntime/commonalities/IntermediateVitruvDomain.xtend +++ b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.commonalities/src/tools/vitruv/extensions/dslruntime/commonalities/IntermediateVitruvDomain.xtend @@ -4,21 +4,18 @@ import java.util.Set import org.eclipse.emf.ecore.EObject import org.eclipse.emf.ecore.EPackage import tools.vitruv.extensions.dslruntime.commonalities.resources.IntermediateResourceBridge -import tools.vitruv.framework.domains.AbstractTuidAwareVitruvDomain -import tools.vitruv.framework.tuid.TuidCalculatorAndResolver +import tools.vitruv.framework.domains.AbstractVitruvDomain -abstract class IntermediateVitruvDomain extends AbstractTuidAwareVitruvDomain { +abstract class IntermediateVitruvDomain extends AbstractVitruvDomain { - new(String name, EPackage metamodelRootPackage, Set furtherRootPackages, - TuidCalculatorAndResolver tuidCalculator, String... fileExtensions) { - super(name, metamodelRootPackage, furtherRootPackages, tuidCalculator, fileExtensions) + new(String name, EPackage metamodelRootPackage, Set furtherRootPackages, String... fileExtensions) { + super(name, metamodelRootPackage, furtherRootPackages, fileExtensions) } - new(String name, EPackage metamodelRootPackage, TuidCalculatorAndResolver tuidCalculator, - String... fileExtensions) { - super(name, metamodelRootPackage, tuidCalculator, fileExtensions) + new(String name, EPackage metamodelRootPackage, String... fileExtensions) { + super(name, metamodelRootPackage, fileExtensions) } - + override shouldTransitivelyPropagateChanges() { true } diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.commonalities/src/tools/vitruv/extensions/dslruntime/commonalities/resources/impl/IntermediateResourceBridgeI.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.commonalities/src/tools/vitruv/extensions/dslruntime/commonalities/resources/impl/IntermediateResourceBridgeI.xtend index 43fa76ad6b..5ce7df24e2 100644 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.commonalities/src/tools/vitruv/extensions/dslruntime/commonalities/resources/impl/IntermediateResourceBridgeI.xtend +++ b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.commonalities/src/tools/vitruv/extensions/dslruntime/commonalities/resources/impl/IntermediateResourceBridgeI.xtend @@ -9,7 +9,6 @@ import tools.vitruv.extensions.dslruntime.commonalities.resources.Resource import tools.vitruv.extensions.dslruntime.commonalities.resources.ResourcesPackage import tools.vitruv.extensions.dslsruntime.reactions.helper.PersistenceHelper import tools.vitruv.extensions.dslsruntime.reactions.helper.ReactionsCorrespondenceHelper -import tools.vitruv.framework.tuid.TuidManager import tools.vitruv.framework.util.datatypes.VURI import static com.google.common.base.Preconditions.* @@ -95,7 +94,6 @@ class IntermediateResourceBridgeI extends IntermediateResourceBridgeImpl { } private def persist() { - TuidManager.instance.updateTuidsOfRegisteredObjects() resourceAccess.persistAsRoot(content, VURI.getInstance(resourceUri)) this.isPersisted = true if (eContainer === null) { diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/META-INF/MANIFEST.MF b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/META-INF/MANIFEST.MF index fdb2e79025..464124c8d2 100644 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/META-INF/MANIFEST.MF +++ b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/META-INF/MANIFEST.MF @@ -12,6 +12,9 @@ Require-Bundle: org.apache.log4j;visibility:=reexport, org.eclipse.xtend.lib;visibility:=reexport, org.eclipse.core.resources, org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + tools.vitruv.framework.correspondence;visibility:=reexport, + tools.vitruv.framework.uuid;visibility:=reexport, tools.vitruv.framework.change;visibility:=reexport, tools.vitruv.framework.change.processing;visibility:=reexport, tools.vitruv.framework.domains, diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/AbstractReactionRealization.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/AbstractReactionRealization.xtend index eb97c39557..ef4018d3a1 100644 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/AbstractReactionRealization.xtend +++ b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/AbstractReactionRealization.xtend @@ -3,7 +3,6 @@ package tools.vitruv.extensions.dslsruntime.reactions import tools.vitruv.extensions.dslsruntime.reactions.IReactionRealization import tools.vitruv.extensions.dslsruntime.reactions.structure.CallHierarchyHaving import tools.vitruv.framework.change.echange.EChange -import tools.vitruv.framework.tuid.TuidManager import org.eclipse.xtend.lib.annotations.Accessors import tools.vitruv.framework.userinteraction.UserInteractor @@ -35,11 +34,6 @@ abstract class AbstractReactionRealization extends CallHierarchyHaving implement } finally { // reset the routines facade execution state: routinesFacade._getExecutionState().reset(); - - // The reactions was completely executed, so remove all objects registered for modification - // by the effects as they are no longer under modification - // even if there was an exception! - TuidManager.instance.flushRegisteredObjectsUnderModification(); } } diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/AbstractRepairRoutineRealization.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/AbstractRepairRoutineRealization.xtend index 70a3789fff..34a3f2d43c 100644 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/AbstractRepairRoutineRealization.xtend +++ b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/AbstractRepairRoutineRealization.xtend @@ -13,7 +13,6 @@ import tools.vitruv.extensions.dslsruntime.reactions.helper.ReactionsCorresponde import tools.vitruv.extensions.dslsruntime.reactions.structure.CallHierarchyHaving import tools.vitruv.extensions.dslsruntime.reactions.structure.Loggable import tools.vitruv.framework.correspondence.CorrespondenceModel -import tools.vitruv.framework.tuid.TuidManager import tools.vitruv.framework.userinteraction.UserInteractor import tools.vitruv.framework.util.command.ResourceAccess import tools.vitruv.framework.util.datatypes.VURI @@ -152,10 +151,7 @@ abstract class AbstractRepairRoutineRealization extends CallHierarchyHaving impl private def persistAsRoot(EObject rootObject, VURI vuri) { logger.trace("Registered to persist root " + rootObject + " in: " + vuri) if (rootObject.eResource?.URI !== vuri.EMFUri) { - // Update TUID after removal, as persistence will also change it and rely on an up-to-date value - TuidManager.getInstance().registerObjectUnderModification(rootObject) EcoreUtil.remove(rootObject) - TuidManager.getInstance().updateTuidsOfRegisteredObjects() resourceAccess.persistAsRoot(rootObject, vuri) } } diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/ReactionElementsHandler.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/ReactionElementsHandler.xtend index 83bc4d734f..21410f2019 100644 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/ReactionElementsHandler.xtend +++ b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/ReactionElementsHandler.xtend @@ -6,6 +6,4 @@ interface ReactionElementsHandler { def void addCorrespondenceBetween(EObject firstElement, EObject secondElement, String tag); def void removeCorrespondenceBetween(EObject firstElement, EObject secondElement, String tag); def void deleteObject(EObject element); - def void registerObjectUnderModification(EObject element); - def void postprocessElements(); } \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/effects/ReactionElementsHandlerImpl.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/effects/ReactionElementsHandlerImpl.xtend index ea83ae2d2d..9f09e954d5 100644 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/effects/ReactionElementsHandlerImpl.xtend +++ b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.reactions/src/tools/vitruv/extensions/dslsruntime/reactions/effects/ReactionElementsHandlerImpl.xtend @@ -2,7 +2,6 @@ package tools.vitruv.extensions.dslsruntime.reactions.effects import org.eclipse.emf.ecore.EObject import tools.vitruv.framework.correspondence.CorrespondenceModel -import tools.vitruv.framework.tuid.TuidManager import tools.vitruv.extensions.dslsruntime.reactions.helper.ReactionsCorrespondenceHelper import org.eclipse.emf.ecore.util.EcoreUtil import org.apache.log4j.Logger @@ -18,8 +17,6 @@ class ReactionElementsHandlerImpl implements ReactionElementsHandler { } override void addCorrespondenceBetween(EObject firstElement, EObject secondElement, String tag) { - registerObjectUnderModification(firstElement); - registerObjectUnderModification(secondElement); ReactionsCorrespondenceHelper.addCorrespondence(correspondenceModel, firstElement, secondElement, tag); } @@ -30,9 +27,6 @@ class ReactionElementsHandlerImpl implements ReactionElementsHandler { ReactionsCorrespondenceHelper.removeCorrespondencesOfObject(correspondenceModel, element); logger.debug("Removing object " + element + " from container " + element.eContainer()); EcoreUtil.remove(element); - // If we delete an object, we have to update Tuids because Tuids of child elements - // may have to be resolved for removing correspondences as well and must therefore be up-to-date - TuidManager.instance.updateTuidsOfRegisteredObjects(); } override void removeCorrespondenceBetween(EObject firstElement, EObject secondElement, String tag) { @@ -40,19 +34,4 @@ class ReactionElementsHandlerImpl implements ReactionElementsHandler { firstElement, secondElement, tag); } - override registerObjectUnderModification(EObject element) { - if (element !== null) { - TuidManager.instance.registerObjectUnderModification(element); - if (element.eContainer !== null) { - TuidManager.instance.registerObjectUnderModification(element.eContainer); - } - - } - } - - override postprocessElements() { - // Modifications are finished, so update the Tuids - TuidManager.instance.updateTuidsOfRegisteredObjects(); - } - } \ No newline at end of file diff --git a/bundles/extensions/integration/tools.vitruv.extensions.integration.correspondence/META-INF/MANIFEST.MF b/bundles/extensions/integration/tools.vitruv.extensions.integration.correspondence/META-INF/MANIFEST.MF index 676b4279a0..e3c6f1b067 100644 --- a/bundles/extensions/integration/tools.vitruv.extensions.integration.correspondence/META-INF/MANIFEST.MF +++ b/bundles/extensions/integration/tools.vitruv.extensions.integration.correspondence/META-INF/MANIFEST.MF @@ -9,8 +9,7 @@ Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-ActivationPolicy: lazy -Require-Bundle: tools.vitruv.extensions.dslsruntime.reactions;visibility:=reexport, - tools.vitruv.framework.tuid +Require-Bundle: tools.vitruv.extensions.dslsruntime.reactions;visibility:=reexport Export-Package: tools.vitruv.extensions.integration.correspondence.integration, tools.vitruv.extensions.integration.correspondence.integration.impl, tools.vitruv.extensions.integration.correspondence.integration.util, diff --git a/bundles/framework/pom.xml b/bundles/framework/pom.xml index 12cc0190ec..565ba0af83 100644 --- a/bundles/framework/pom.xml +++ b/bundles/framework/pom.xml @@ -22,7 +22,6 @@ tools.vitruv.framework.correspondence tools.vitruv.framework.domains tools.vitruv.framework.domains.ui - tools.vitruv.framework.tuid tools.vitruv.framework.userinteracting tools.vitruv.framework.util tools.vitruv.framework.uuid diff --git a/bundles/framework/tools.vitruv.framework.change.processing/META-INF/MANIFEST.MF b/bundles/framework/tools.vitruv.framework.change.processing/META-INF/MANIFEST.MF index 6d39dfa7d0..db23b02d46 100644 --- a/bundles/framework/tools.vitruv.framework.change.processing/META-INF/MANIFEST.MF +++ b/bundles/framework/tools.vitruv.framework.change.processing/META-INF/MANIFEST.MF @@ -10,7 +10,8 @@ Require-Bundle: org.apache.log4j, tools.vitruv.framework.correspondence;visibility:=reexport, tools.vitruv.framework.userinteraction;visibility:=reexport, tools.vitruv.framework.change;visibility:=reexport, - tools.vitruv.framework.domains + tools.vitruv.framework.domains, + tools.vitruv.framework.util Export-Package: tools.vitruv.framework.change.processing, tools.vitruv.framework.change.processing.impl Bundle-Vendor: vitruv.tools diff --git a/bundles/framework/tools.vitruv.framework.change/META-INF/MANIFEST.MF b/bundles/framework/tools.vitruv.framework.change/META-INF/MANIFEST.MF index e565899b13..39e42fab9a 100644 --- a/bundles/framework/tools.vitruv.framework.change/META-INF/MANIFEST.MF +++ b/bundles/framework/tools.vitruv.framework.change/META-INF/MANIFEST.MF @@ -8,9 +8,9 @@ Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: org.apache.log4j, org.eclipse.xtend.lib, org.eclipse.emf.ecore.change, - tools.vitruv.framework.tuid, tools.vitruv.framework.change.echange;visibility:=reexport, - tools.vitruv.framework.change.interaction + tools.vitruv.framework.change.interaction, + tools.vitruv.framework.util Export-Package: tools.vitruv.framework.change.description, tools.vitruv.framework.change.preparation, tools.vitruv.framework.change.recording, diff --git a/bundles/framework/tools.vitruv.framework.change/src/tools/vitruv/framework/change/description/impl/ConcreteApplicableChangeImpl.xtend b/bundles/framework/tools.vitruv.framework.change/src/tools/vitruv/framework/change/description/impl/ConcreteApplicableChangeImpl.xtend index e30a0d93db..eec43265fe 100644 --- a/bundles/framework/tools.vitruv.framework.change/src/tools/vitruv/framework/change/description/impl/ConcreteApplicableChangeImpl.xtend +++ b/bundles/framework/tools.vitruv.framework.change/src/tools/vitruv/framework/change/description/impl/ConcreteApplicableChangeImpl.xtend @@ -1,12 +1,10 @@ package tools.vitruv.framework.change.description.impl -import org.eclipse.emf.ecore.EObject import org.eclipse.emf.ecore.InternalEObject import org.eclipse.emf.ecore.util.EcoreUtil import tools.vitruv.framework.change.echange.EChange import tools.vitruv.framework.change.echange.resolve.EChangeUnresolver import tools.vitruv.framework.change.echange.root.RootEChange -import tools.vitruv.framework.tuid.TuidManager import tools.vitruv.framework.util.datatypes.VURI import tools.vitruv.framework.uuid.UuidResolver @@ -25,20 +23,16 @@ class ConcreteApplicableChangeImpl extends ConcreteChangeImpl { // TODO HK Make a copy of the complete change instead of replacing it internally this.EChange = this.EChange.resolveBefore(uuidResolver) tryToSetUri; - this.registerOldObjectTuidsForUpdate(getObjectsWithPotentiallyModifiedTuids) this.EChange.applyForward; tryToSetUri; - this.updateTuids } override resolveAfterAndApplyBackward(UuidResolver uuidResolver) { // TODO HK Make a copy of the complete change instead of replacing it internally this.EChange = this.EChange.resolveAfter(uuidResolver) tryToSetUri; - this.registerOldObjectTuidsForUpdate(getObjectsWithPotentiallyModifiedTuids) this.EChange.applyBackward; tryToSetUri; - this.updateTuids } private def void tryToSetUri() { @@ -62,25 +56,6 @@ class ConcreteApplicableChangeImpl extends ConcreteChangeImpl { return vuri; } - private def getObjectsWithPotentiallyModifiedTuids() { - // We currently support 3 hierarchy layers upwards update. This is necessary - // e.g. for Operations whose TUIDs depend on the values of their parameter type references. - // This number of layers may still be too few, this is just a random number. - this.affectedEObjects.map[#{it, it.eContainer, it.eContainer?.eContainer, it.eContainer?.eContainer?.eContainer}].flatten.filterNull.toSet - } - - private def void registerOldObjectTuidsForUpdate(Iterable objects) { - val tuidManager = TuidManager.instance - for (object : objects) { - tuidManager.registerObjectUnderModification(object) - } - } - - private def void updateTuids() { - TuidManager.instance.updateTuidsOfRegisteredObjects - TuidManager.instance.flushRegisteredObjectsUnderModification - } - override unresolveIfApplicable() { EChanges.forEach[EChangeUnresolver.unresolve(it)] } diff --git a/bundles/framework/tools.vitruv.framework.correspondence/META-INF/MANIFEST.MF b/bundles/framework/tools.vitruv.framework.correspondence/META-INF/MANIFEST.MF index 1caad0dfea..8f2d1c8f95 100644 --- a/bundles/framework/tools.vitruv.framework.correspondence/META-INF/MANIFEST.MF +++ b/bundles/framework/tools.vitruv.framework.correspondence/META-INF/MANIFEST.MF @@ -9,8 +9,10 @@ Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: org.apache.log4j, org.eclipse.xtend.lib, org.eclipse.emf.ecore.change, - tools.vitruv.framework.domains, - tools.vitruv.framework.uuid;visibility:=reexport + org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + tools.vitruv.framework.uuid;visibility:=reexport, + tools.vitruv.framework.util Bundle-ActivationPolicy: lazy Export-Package: tools.vitruv.framework.correspondence, tools.vitruv.framework.correspondence.impl, diff --git a/bundles/framework/tools.vitruv.framework.correspondence/metamodel/correspondence.ecore b/bundles/framework/tools.vitruv.framework.correspondence/metamodel/correspondence.ecore index 3600df7020..8c1c316daa 100644 --- a/bundles/framework/tools.vitruv.framework.correspondence/metamodel/correspondence.ecore +++ b/bundles/framework/tools.vitruv.framework.correspondence/metamodel/correspondence.ecore @@ -13,10 +13,6 @@ upperBound="-1" eType="#//Correspondence" eOpposite="#//Correspondence/dependedOnBy"/> - - - diff --git a/bundles/framework/tools.vitruv.framework.correspondence/metamodel/correspondence.genmodel b/bundles/framework/tools.vitruv.framework.correspondence/metamodel/correspondence.genmodel index 8da86f54a0..87712789af 100644 --- a/bundles/framework/tools.vitruv.framework.correspondence/metamodel/correspondence.genmodel +++ b/bundles/framework/tools.vitruv.framework.correspondence/metamodel/correspondence.genmodel @@ -8,7 +8,6 @@ correspondence.ecore - @@ -16,8 +15,6 @@ - - diff --git a/bundles/framework/tools.vitruv.framework.correspondence/src/tools/vitruv/framework/correspondence/CorrespondenceModelFactory.xtend b/bundles/framework/tools.vitruv.framework.correspondence/src/tools/vitruv/framework/correspondence/CorrespondenceModelFactory.xtend index d089d325a8..72794c977b 100644 --- a/bundles/framework/tools.vitruv.framework.correspondence/src/tools/vitruv/framework/correspondence/CorrespondenceModelFactory.xtend +++ b/bundles/framework/tools.vitruv.framework.correspondence/src/tools/vitruv/framework/correspondence/CorrespondenceModelFactory.xtend @@ -1,8 +1,6 @@ package tools.vitruv.framework.correspondence -import tools.vitruv.framework.tuid.TuidResolver import tools.vitruv.framework.uuid.UuidResolver -import tools.vitruv.framework.domains.repository.VitruvDomainRepository import tools.vitruv.framework.util.datatypes.VURI import org.eclipse.emf.ecore.resource.Resource import tools.vitruv.framework.correspondence.impl.InternalCorrespondenceModelImpl @@ -21,8 +19,8 @@ final class CorrespondenceModelFactory { return instance; } - def createCorrespondenceModel(TuidResolver tuidResolver, UuidResolver uuidResolver, CommandCreatorAndExecutor modelCommandExecutor, - VitruvDomainRepository domainRepository, VURI correspondencesVURI, Resource correspondencesResource) { - return new InternalCorrespondenceModelImpl(tuidResolver, uuidResolver, modelCommandExecutor, domainRepository, correspondencesVURI, correspondencesResource); + def createCorrespondenceModel(UuidResolver uuidResolver, CommandCreatorAndExecutor modelCommandExecutor, + VURI correspondencesVURI, Resource correspondencesResource) { + return new InternalCorrespondenceModelImpl(uuidResolver, modelCommandExecutor, correspondencesVURI, correspondencesResource); } } \ No newline at end of file diff --git a/bundles/framework/tools.vitruv.framework.correspondence/src/tools/vitruv/framework/correspondence/CorrespondenceUtil.xtend b/bundles/framework/tools.vitruv.framework.correspondence/src/tools/vitruv/framework/correspondence/CorrespondenceUtil.xtend index 689b241e32..8fd70c1e45 100644 --- a/bundles/framework/tools.vitruv.framework.correspondence/src/tools/vitruv/framework/correspondence/CorrespondenceUtil.xtend +++ b/bundles/framework/tools.vitruv.framework.correspondence/src/tools/vitruv/framework/correspondence/CorrespondenceUtil.xtend @@ -1,24 +1,8 @@ package tools.vitruv.framework.correspondence import java.util.List -import tools.vitruv.framework.tuid.Tuid class CorrespondenceUtil { - static def List getCorrespondingTuids(Correspondence correspondence, List tuids) { - var List aTuids = correspondence.getATuids() - var List bTuids = correspondence.getBTuids() - if (aTuids === null || bTuids === null || aTuids.size == 0 || bTuids.size == 0) { - throw new IllegalStateException( - '''The correspondence '«»«correspondence»' links to an empty Tuid '«»«aTuids»' or '«»«bTuids»'!'''. - toString) - } - if (aTuids.equals(tuids)) { - return bTuids - } else { - return aTuids - } - } - static def getCorrespondingUuids(Correspondence correspondence, List uuids) { var List aUuids = correspondence.getAUuids() var List bUuids = correspondence.getBUuids() @@ -33,8 +17,4 @@ class CorrespondenceUtil { return aUuids } } - - static def isUuidBased(Correspondence correspondence) { - return !correspondence.AUuids.empty && !correspondence.BUuids.empty - } } \ No newline at end of file diff --git a/bundles/framework/tools.vitruv.framework.correspondence/src/tools/vitruv/framework/correspondence/impl/InternalCorrespondenceModelImpl.xtend b/bundles/framework/tools.vitruv.framework.correspondence/src/tools/vitruv/framework/correspondence/impl/InternalCorrespondenceModelImpl.xtend index 3c63c1719f..ca6bdf9c43 100644 --- a/bundles/framework/tools.vitruv.framework.correspondence/src/tools/vitruv/framework/correspondence/impl/InternalCorrespondenceModelImpl.xtend +++ b/bundles/framework/tools.vitruv.framework.correspondence/src/tools/vitruv/framework/correspondence/impl/InternalCorrespondenceModelImpl.xtend @@ -1,8 +1,6 @@ package tools.vitruv.framework.correspondence.impl -import edu.kit.ipd.sdq.commons.util.java.Pair import java.io.IOException -import java.util.ArrayList import java.util.HashSet import java.util.List import java.util.Map @@ -16,17 +14,8 @@ import org.eclipse.emf.ecore.util.EcoreUtil import tools.vitruv.framework.correspondence.Correspondence import tools.vitruv.framework.correspondence.CorrespondenceFactory import tools.vitruv.framework.correspondence.Correspondences -import tools.vitruv.framework.domains.TuidAwareVitruvDomain -import tools.vitruv.framework.domains.VitruvDomain -import tools.vitruv.framework.domains.repository.VitruvDomainRepository -import tools.vitruv.framework.tuid.Tuid -import tools.vitruv.framework.tuid.TuidManager -import tools.vitruv.framework.tuid.TuidResolver -import tools.vitruv.framework.tuid.TuidUpdateListener import tools.vitruv.framework.util.VitruviusConstants import tools.vitruv.framework.util.bridges.EcoreResourceBridge -import tools.vitruv.framework.util.datatypes.ClaimableHashMap -import tools.vitruv.framework.util.datatypes.ClaimableMap import tools.vitruv.framework.util.datatypes.ModelInstance import tools.vitruv.framework.util.datatypes.VURI import tools.vitruv.framework.uuid.UuidResolver @@ -41,29 +30,19 @@ import java.util.function.Predicate import tools.vitruv.framework.util.command.CommandCreatorAndExecutor // TODO move all methods that don't need direct instance variable access to some kind of util class -class InternalCorrespondenceModelImpl extends ModelInstance implements InternalCorrespondenceModel, TuidUpdateListener { +class InternalCorrespondenceModelImpl extends ModelInstance implements InternalCorrespondenceModel { static val logger = Logger.getLogger(InternalCorrespondenceModelImpl) final CommandCreatorAndExecutor modelCommandExecutor - final VitruvDomainRepository domainRepository; final Correspondences correspondences - final ClaimableMap>> tuid2tuidListsMap - protected final ClaimableMap, Set> tuid2CorrespondencesMap boolean changedAfterLastSave = false - final TuidResolver tuidResolver; final UuidResolver uuidResolver; - new(TuidResolver tuidResolver, UuidResolver uuidResolver, CommandCreatorAndExecutor modelCommandExecutor, - VitruvDomainRepository domainRepository, VURI correspondencesVURI, Resource correspondencesResource) { + new(UuidResolver uuidResolver, CommandCreatorAndExecutor modelCommandExecutor, + VURI correspondencesVURI, Resource correspondencesResource) { super(correspondencesVURI, correspondencesResource) this.modelCommandExecutor = modelCommandExecutor - // TODO MK use MutatingListFixing... when necessary (for both maps!) - this.tuid2tuidListsMap = new ClaimableHashMap>>() - this.tuid2CorrespondencesMap = new ClaimableHashMap, Set>() this.correspondences = loadAndRegisterCorrespondences(correspondencesResource) - this.domainRepository = domainRepository; - this.tuidResolver = tuidResolver; this.uuidResolver = uuidResolver; - TuidManager.instance.addTuidUpdateListener(this); } def private getSaveAndLoadOptions() { @@ -75,41 +54,15 @@ class InternalCorrespondenceModelImpl extends ModelInstance implements InternalC private def void addCorrespondence(Correspondence correspondence) { this.modelCommandExecutor.executeAsCommand[ addCorrespondenceToModel(correspondence) - registerCorrespondence(correspondence) setChangedAfterLastSaveFlag() ] } - def private void registerCorrespondence(Correspondence correspondence) { - registerTuidLists(correspondence) - registerCorrespondenceForTuids(correspondence) - } - - def private registerTuidLists(Correspondence correspondence) { - registerTuidList(correspondence.getATuids) - registerTuidList(correspondence.getBTuids) - } - - def private registerTuidList(List tuidList) { - for (Tuid tuid : tuidList) { - var tuidLists = this.tuid2tuidListsMap.get(tuid) - if (tuidLists === null) { - tuidLists = new HashSet>() - this.tuid2tuidListsMap.put(tuid, tuidLists) - } - tuidLists.add(tuidList) - } - } - def private void addCorrespondenceToModel(Correspondence correspondence) { var EList correspondenceListForAddition = this.correspondences.getCorrespondences() correspondenceListForAddition.add(correspondence) } - def private getMetamodelForEObject(EObject eObject) { - return this.domainRepository.getDomain(eObject); - } - override C createAndAddCorrespondence(List eObjects1, List eObjects2, String tag, Supplier correspondenceCreator) { val correspondence = correspondenceCreator.get @@ -137,45 +90,22 @@ class InternalCorrespondenceModelImpl extends ModelInstance implements InternalC correspondences += getCorrespondencesForUuids(uuids); } - val List tuids = calculateTuidsFromEObjects(eObjects) - correspondences += getCorrespondencesForTuids(tuids); - return correspondences.filter(correspondenceType).filter(correspondencesFilter).filter [ tag === null || it.tag == tag ].toSet; } - /** - * Returns all correspondences for the object with the specified tuid and an empty set if the - * object has no correspondences. Should never return {@link null}. - * - * @param tuids - * @return all correspondences for the object with the specified tuid and an empty set if the - * object has no correspondences. - */ - private def Set getCorrespondencesForTuids(List tuids) { - var Set correspondences = this.tuid2CorrespondencesMap.get(tuids) - if (correspondences === null) { - correspondences = new HashSet() - this.tuid2CorrespondencesMap.put(tuids, correspondences) - registerTuidList(tuids) - } - return correspondences - } - private def Set getCorrespondencesForUuids(List uuids) { return this.correspondences.correspondences.filter[AUuids.containsAll(uuids) || BUuids.containsAll(uuids)].toSet } private def haveUuids(List eObjects) { - if (eObjects.forall[domainRepository.getDomain(it).supportsUuids]) { - if (eObjects.forall[uuidResolver.hasPotentiallyCachedUuid(it)]) { - return true; - } else { - logger.warn("UUID resolver has no UUID for one of the elements: " + eObjects); - } + if (eObjects.forall[uuidResolver.hasPotentiallyCachedUuid(it)]) { + return true; + } else { + logger.warn("UUID resolver has no UUID for one of the elements: " + eObjects); } - return false; + return false } override Set> getCorrespondingEObjects(Class correspondenceType, @@ -194,23 +124,9 @@ class InternalCorrespondenceModelImpl extends ModelInstance implements InternalC } private def List resolveCorrespondingObjects(Correspondence correspondence, List eObjects) { - if (correspondence.isUuidBased) { - val uuids = eObjects.map[uuidResolver.getPotentiallyCachedUuid(it)]; - val correspondingUuids = correspondence.getCorrespondingUuids(uuids); - return correspondingUuids.map[resolveEObjectFromUuid]; - } else { - val tuids = eObjects.map[calculateTuidFromEObject]; - val correspondingTuids = correspondence.getCorrespondingTuids(tuids); - try { - return correspondingTuids.map[resolveEObjectFromTuid] - } catch (IllegalStateException e) { - throw new IllegalStateException('''Corresponding objects for eObjects - «FOR object : eObjects BEFORE "\n" SEPARATOR "\n"» «object»«ENDFOR» - cannot be resolved, because one of the TUIDs - «FOR tuid : correspondingTuids BEFORE "\n" SEPARATOR "\n"» «tuid»«ENDFOR» - cannot be resolved.''') - } - } + val uuids = eObjects.map[uuidResolver.getPotentiallyCachedUuid(it)]; + val correspondingUuids = correspondence.getCorrespondingUuids(uuids); + return correspondingUuids.map[resolveEObjectFromUuid]; } override void saveModel() { @@ -228,20 +144,14 @@ class InternalCorrespondenceModelImpl extends ModelInstance implements InternalC } override boolean hasCorrespondences() { - for (Set correspondences : this.tuid2CorrespondencesMap.values()) { - if (!correspondences.isEmpty()) { - return true - } - }; - return false + return !this.correspondences.correspondences.empty } - override boolean hasCorrespondences(List eObjects) { - var List tuids = calculateTuidsFromEObjects(eObjects) - var Set correspondences = this.tuid2CorrespondencesMap.get(tuids) + override hasCorrespondences(List eObjects) { + val correspondences = this.getCorrespondences(Correspondence, [true], eObjects, null); return correspondences !== null && correspondences.size() > 0 } - + def private Correspondences loadAndRegisterCorrespondences(Resource correspondencesResource) { try { correspondencesResource.load(saveAndLoadOptions) @@ -258,49 +168,10 @@ class InternalCorrespondenceModelImpl extends ModelInstance implements InternalC if (correspondences === null) { correspondences = CorrespondenceFactory::eINSTANCE.createCorrespondences() correspondencesResource.getContents().add(correspondences) - } else { - registerLoadedCorrespondences(correspondences) } return correspondences } - def private void registerCorrespondenceForTuids(Correspondence correspondence) { - val correspondencesForAs = getCorrespondencesForTuids(correspondence.getATuids) - correspondencesForAs.add(correspondence) - val correspondencesForBs = getCorrespondencesForTuids(correspondence.getBTuids) - correspondencesForBs.add(correspondence) - } - - def private void registerLoadedCorrespondences(Correspondences correspondences) { - for (Correspondence correspondence : correspondences.getCorrespondences()) { - registerCorrespondence(correspondence) - } - } - - def private void removeCorrespondenceFromMaps(Correspondence markedCorrespondence) { - if (!markedCorrespondence.ATuids.nullOrEmpty && !markedCorrespondence.BTuids.nullOrEmpty) { - var List aTuids = markedCorrespondence.getATuids - var List bTuids = markedCorrespondence.getBTuids - removeTuid2TuidListsEntries(aTuids) - removeTuid2TuidListsEntries(bTuids) - this.tuid2CorrespondencesMap.get(aTuids).remove(markedCorrespondence); - if (tuid2CorrespondencesMap.get(aTuids).empty) { - tuid2CorrespondencesMap.remove(aTuids); - } - this.tuid2CorrespondencesMap.get(bTuids).remove(markedCorrespondence); - if (tuid2CorrespondencesMap.get(bTuids).empty) { - tuid2CorrespondencesMap.remove(bTuids); - } - } - } - - def private void removeTuid2TuidListsEntries(List tuids) { - for (Tuid tuid : tuids) { - val tuidLists = this.tuid2tuidListsMap.get(tuid) - tuidLists.remove(tuids) - } - } - private def void setChangedAfterLastSaveFlag() { this.changedAfterLastSave = true } @@ -313,27 +184,20 @@ class InternalCorrespondenceModelImpl extends ModelInstance implements InternalC List eObjects2, String tag) { var aEObjects = eObjects1 var bEObjects = eObjects2 - if ((aEObjects + bEObjects).forall[domainRepository.getDomain(it).supportsUuids]) { - correspondence.getAUuids().addAll(aEObjects.map [ - if (uuidResolver.hasPotentiallyCachedUuid(it)) { - uuidResolver.getPotentiallyCachedUuid(it) - } else { - uuidResolver.registerCachedEObject(it); - } - ]) - correspondence.getBUuids().addAll(bEObjects.map [ - if (uuidResolver.hasPotentiallyCachedUuid(it)) { - uuidResolver.getPotentiallyCachedUuid(it) - } else { - uuidResolver.registerCachedEObject(it); - } - ]) - } else { - var List aTuids = calculateTuidsFromEObjects(aEObjects) - correspondence.getATuids().addAll(aTuids) - var List bTuids = calculateTuidsFromEObjects(bEObjects) - correspondence.getBTuids().addAll(bTuids) - } + correspondence.getAUuids().addAll(aEObjects.map [ + if (uuidResolver.hasPotentiallyCachedUuid(it)) { + uuidResolver.getPotentiallyCachedUuid(it) + } else { + uuidResolver.registerCachedEObject(it); + } + ]) + correspondence.getBUuids().addAll(bEObjects.map [ + if (uuidResolver.hasPotentiallyCachedUuid(it)) { + uuidResolver.getPotentiallyCachedUuid(it) + } else { + uuidResolver.registerCachedEObject(it); + } + ]) correspondence.tag = tag; } @@ -341,82 +205,6 @@ class InternalCorrespondenceModelImpl extends ModelInstance implements InternalC return correspondences.correspondences } - Iterable, Set>> tuidUpdateData; - - /** - * Removes the current entries in the - * {@link CorrespondenceModelImpl#tuid2CorrespondencesMap} map for the given oldTuid - * before the hash code of it is updated and returns a pair containing the oldTuid and - * the removed correspondence model elements of the map. - * - * @param oldCurrentTuid - * @return oldCurrentTuidAndStringAndMapEntriesTriple - */ - override performPreAction(Tuid oldCurrentTuid) { - if (tuidUpdateData !== null) { - throw new IllegalStateException("Two update calls were running at the same time"); - } - // The Tuid is used as key in this map. Therefore the entry has to be removed before - // the hashCode of the Tuid changes. - // remove the old map entries for the tuid before its hashcode changes - val oldTuidLists = tuid2tuidListsMap.remove(oldCurrentTuid) ?: new HashSet>() - val oldTuidList2Correspondences = new ArrayList, Set>>(oldTuidLists.size); - for (oldTuidList : oldTuidLists) { - val correspondencesForOldTuidList = tuid2CorrespondencesMap.remove(oldTuidList) ?: - new HashSet() - oldTuidList2Correspondences.add( - new Pair, Set>(oldTuidList, correspondencesForOldTuidList)) - } - tuidUpdateData = oldTuidList2Correspondences - } - - /** - * Re-adds all map entries after the hash code of tuids was updated. - * - * @param removedMapEntries - */ - override void performPostAction(Tuid tuid) { - // The correspondence model is an EMF-based model, so modifications have to be - // performed within a transaction. - this.modelCommandExecutor.executeAsCommand([| - if (tuidUpdateData === null) { - throw new IllegalStateException("Update was not started before performing post action"); - } - val oldTuidList2Correspondences = tuidUpdateData; - val newSetOfoldTuidLists = new HashSet>() - for (oldTuidList2CorrespondencesEntry : oldTuidList2Correspondences) { - val oldTuidList = new ArrayList(oldTuidList2CorrespondencesEntry.first); - val correspondences = oldTuidList2CorrespondencesEntry.second - // re-add the tuid list with the new hashcode to the set for the for the tuid2tuidListsMap entry - newSetOfoldTuidLists.add(oldTuidList) - // re-add the correspondences entry for the current list of tuids with the new hashcode - tuid2CorrespondencesMap.put(oldTuidList, correspondences) - } - // re-add the entry that maps the tuid to the set if tuid lists that contain it - tuid2tuidListsMap.put(tuid, newSetOfoldTuidLists) - tuidUpdateData = null; - setChangedAfterLastSaveFlag(); - return null; - ]); - } - - private def List calculateTuidsFromEObjects(List eObjects) { - return eObjects.mapFixed[calculateTuidFromEObject(it)].toList - } - - private def calculateTuidFromEObject(EObject eObject) { - val VitruvDomain metamodel = eObject.getMetamodelForEObject() - if (null === metamodel || !(metamodel instanceof TuidAwareVitruvDomain)) { - return null - } - val typedDomain = metamodel as TuidAwareVitruvDomain; - return typedDomain.calculateTuid(eObject) - } - - private def EObject resolveEObjectFromTuid(Tuid tuid) { - tuidResolver.resolveEObjectFromTuid(tuid); - } - private def resolveEObjectFromUuid(String uuid) { return uuidResolver.getPotentiallyCachedEObject(uuid) } @@ -458,7 +246,6 @@ class InternalCorrespondenceModelImpl extends ModelInstance implements InternalC private def removeMarkedCorrespondences(Iterable markedCorrespondences) { for (Correspondence markedCorrespondence : markedCorrespondences) { - removeCorrespondenceFromMaps(markedCorrespondence) EcoreUtil::remove(markedCorrespondence) setChangedAfterLastSaveFlag() } @@ -467,11 +254,7 @@ class InternalCorrespondenceModelImpl extends ModelInstance implements InternalC override getAllEObjectsOfTypeInCorrespondences(Class correspondenceType, Predicate correspondencesFilter, Class type) { allCorrespondences.filter(correspondenceType).filter(correspondencesFilter).map [ - if (it.isUuidBased) { - (it.AUuids + it.BUuids).toList.map[resolveEObjectFromUuid] - } else { - (it.ATuids + it.BTuids).toList.map[resolveEObjectFromTuid] - } + (it.AUuids + it.BUuids).toList.map[resolveEObjectFromUuid] ].flatten.filter(type).toSet } diff --git a/bundles/framework/tools.vitruv.framework.domains.ui/META-INF/MANIFEST.MF b/bundles/framework/tools.vitruv.framework.domains.ui/META-INF/MANIFEST.MF index e2262e3b70..1b6e92addb 100644 --- a/bundles/framework/tools.vitruv.framework.domains.ui/META-INF/MANIFEST.MF +++ b/bundles/framework/tools.vitruv.framework.domains.ui/META-INF/MANIFEST.MF @@ -13,6 +13,7 @@ Require-Bundle: org.apache.log4j, org.eclipse.xtend.lib, org.eclipse.core.expressions;visibility:=reexport, tools.vitruv.framework.vsum, + tools.vitruv.framework.util, edu.kit.ipd.sdq.activextendannotations Export-Package: tools.vitruv.framework.domains.ui.monitorededitor, tools.vitruv.framework.domains.ui.builder diff --git a/bundles/framework/tools.vitruv.framework.domains/META-INF/MANIFEST.MF b/bundles/framework/tools.vitruv.framework.domains/META-INF/MANIFEST.MF index 1b3a715542..76bd85b82a 100644 --- a/bundles/framework/tools.vitruv.framework.domains/META-INF/MANIFEST.MF +++ b/bundles/framework/tools.vitruv.framework.domains/META-INF/MANIFEST.MF @@ -9,8 +9,8 @@ Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: org.apache.log4j, org.eclipse.xtend.lib, org.eclipse.emf.transaction, - tools.vitruv.framework.tuid;visibility:=reexport, tools.vitruv.framework.change, + tools.vitruv.framework.util;visibility:=reexport, org.eclipse.emf.compare, edu.kit.ipd.sdq.activextendannotations Bundle-ActivationPolicy: lazy diff --git a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/AbstractTuidAwareVitruvDomain.xtend b/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/AbstractTuidAwareVitruvDomain.xtend deleted file mode 100644 index a20c0e8924..0000000000 --- a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/AbstractTuidAwareVitruvDomain.xtend +++ /dev/null @@ -1,91 +0,0 @@ -package tools.vitruv.framework.domains - -import java.util.List -import java.util.Set -import org.eclipse.emf.ecore.EObject -import org.eclipse.emf.ecore.EPackage -import tools.vitruv.framework.tuid.Tuid -import tools.vitruv.framework.tuid.TuidCalculatorAndResolver -import tools.vitruv.framework.tuid.TuidManager -import tools.vitruv.framework.tuid.TuidUpdateListener -import tools.vitruv.framework.util.datatypes.VURI - -abstract class AbstractTuidAwareVitruvDomain extends AbstractVitruvDomain implements TuidAwareVitruvDomain, TuidUpdateListener { - val TuidCalculatorAndResolver tuidCalculatorAndResolver - - new(String name, EPackage metamodelRootPackage, Set furtherRootPackages, TuidCalculatorAndResolver tuidCalculator, - String... fileExtensions) { - super(name, metamodelRootPackage, furtherRootPackages, fileExtensions) - this.tuidCalculatorAndResolver = tuidCalculator; - } - - new(String name, EPackage metamodelRootPackage, TuidCalculatorAndResolver tuidCalculator, String... fileExtensions) { - super(name, metamodelRootPackage, fileExtensions) - this.tuidCalculatorAndResolver = tuidCalculator; - } - override String calculateTuidFromEObject(EObject eObject, EObject virtualRootObject, String prefix) { - - return this.tuidCalculatorAndResolver.calculateTuidFromEObject(eObject, virtualRootObject, prefix) - } - - override VURI getModelVURIContainingIdentifiedEObject(Tuid tuid) { - val modelVURI = this.tuidCalculatorAndResolver.getModelVURIContainingIdentifiedEObject(tuid.toString) - if (null === modelVURI) { - return null; - } - return VURI::getInstance(modelVURI) - } - - override EObject resolveEObjectFromRootAndFullTuid(EObject root, Tuid tuid) { - return this.tuidCalculatorAndResolver.resolveEObjectFromRootAndFullTuid(root, tuid.toString) - } - - override boolean hasTuid(String tuid) { - return this.tuidCalculatorAndResolver.isValidTuid(tuid) - } - - override performPreAction(Tuid oldTuid) { - if (this.hasTuid(oldTuid.toString)) { - removeIfRootAndCached(oldTuid.toString); - } - } - - override performPostAction(Tuid newTuid) { - // Do nothing - } - - override registerAtTuidManagement() { - TuidManager.instance.addTuidCalculator(this); - TuidManager.instance.addTuidUpdateListener(this); - } - - def String calculateTuidFromEObject(EObject eObject) { - return this.tuidCalculatorAndResolver.calculateTuidFromEObject(eObject) - } - - /** - * syntactic sugar for map[{@link #calculateTuidFromEObject(EObject)}] - * @param eObjects - * @return - */ - def List calculateTuidsFromEObjects(List eObjects) { - return eObjects.map[calculateTuidFromEObject(it)].toList - } - - def void removeRootFromTuidCache(EObject root) { - this.tuidCalculatorAndResolver.removeRootFromCache(root) - } - - def void removeIfRootAndCached(String tuid) { - this.tuidCalculatorAndResolver.removeIfRootAndCached(tuid) - } - - override canCalculateTuid(EObject object) { - return isInstanceOfDomainMetamodel(object); - } - - override calculateTuid(EObject object) { - return Tuid.getInstance(calculateTuidFromEObject(object)); - } - -} diff --git a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/AbstractVitruvDomain.xtend b/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/AbstractVitruvDomain.xtend index 2e18ec91f9..2458c75cd5 100644 --- a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/AbstractVitruvDomain.xtend +++ b/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/AbstractVitruvDomain.xtend @@ -29,15 +29,6 @@ abstract class AbstractVitruvDomain extends AbstractURIHaving implements VitruvD return (#[rootPackage.nsURI] + rootPackage.ESubpackages.map[it.nsURIsRecursive].flatten).toSet; } - def protected static String getTuidPrefix(Iterable nsURIs) { - if (nsURIs !== null && nsURIs.size() > 0) { - return nsURIs.iterator().next() - } else { - throw new RuntimeException( - '''Cannot get a Tuid prefix from the set of namespace URIs '«»«nsURIs»'!'''.toString) - } - } - /** * Convenience method if the metamodel consists of only a single namespace */ @@ -127,8 +118,4 @@ abstract class AbstractVitruvDomain extends AbstractURIHaving implements VitruvD false } - override supportsUuids() { - true - } - } diff --git a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/TuidAwareVitruvDomain.xtend b/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/TuidAwareVitruvDomain.xtend deleted file mode 100644 index 65596ab88e..0000000000 --- a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/TuidAwareVitruvDomain.xtend +++ /dev/null @@ -1,18 +0,0 @@ -package tools.vitruv.framework.domains - -import tools.vitruv.framework.tuid.TuidCalculator -import org.eclipse.emf.ecore.EObject -import tools.vitruv.framework.util.datatypes.VURI -import tools.vitruv.framework.tuid.Tuid - -interface TuidAwareVitruvDomain extends VitruvDomain, TuidCalculator { - def String calculateTuidFromEObject(EObject eObject, EObject virtualRootObject, String prefix); - def boolean hasTuid(String tuid); - def EObject resolveEObjectFromRootAndFullTuid(EObject root, Tuid tuid); - def VURI getModelVURIContainingIdentifiedEObject(Tuid tuid); - - /** - * Must be called to register the domain at the TUID calculation and resolution system - */ - def void registerAtTuidManagement(); -} \ No newline at end of file diff --git a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/VitruvDomain.xtend b/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/VitruvDomain.xtend index 1dd52b9b02..83ea0dee03 100644 --- a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/VitruvDomain.xtend +++ b/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/VitruvDomain.xtend @@ -44,13 +44,4 @@ interface VitruvDomain extends URIHaving, Comparable { */ def boolean shouldTransitivelyPropagateChanges() - /** - * Returns whether this domain supports the usage of UUIDs for object - * identification. This especially depends on whether EMF changes are - * recorded and applied or if only a subset of changes is recorded and - * the resource is reloaded instead, which does not provide UUIDs - * for all elements. - */ - def boolean supportsUuids() - } diff --git a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/repository/VitruvDomainPair.java b/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/repository/VitruvDomainPair.java deleted file mode 100644 index 318b89558c..0000000000 --- a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/repository/VitruvDomainPair.java +++ /dev/null @@ -1,54 +0,0 @@ -package tools.vitruv.framework.domains.repository; - -import tools.vitruv.framework.domains.TuidAwareVitruvDomain; - -public class VitruvDomainPair { - private TuidAwareVitruvDomain metamodelA; - private TuidAwareVitruvDomain metamodelB; - - /** - * Orders the given metamodels in ascending lexicographic order to avoid double put, get and - * update in all maps etc.: returns Mapping(A,B) if A < B and Mapping(B,A) if B < A. - * - * @param metamodelA - * @param metamodelB - */ - public VitruvDomainPair(TuidAwareVitruvDomain metamodelA, TuidAwareVitruvDomain metamodelB) { - if (metamodelA == null || metamodelB == null) { - throw new IllegalArgumentException("Metamodels must not be null"); - } - if (metamodelA.compareTo(metamodelB) > 0) { - // swap - TuidAwareVitruvDomain tmp = metamodelA; - metamodelA = metamodelB; - metamodelB = tmp; - } - this.metamodelA = metamodelA; - this.metamodelB = metamodelB; - } - - public TuidAwareVitruvDomain getMetamodelA() { - return this.metamodelA; - } - - public TuidAwareVitruvDomain getMetamodelB() { - return this.metamodelB; - } - - @Override - public boolean equals(Object otherObj) { - if (null == otherObj || !(otherObj instanceof VitruvDomainPair)) { - return false; - } - final VitruvDomainPair otherPair = (VitruvDomainPair) otherObj; - return this.getMetamodelA().equals(otherPair.getMetamodelA()) && this.getMetamodelB().equals(this.getMetamodelB()); - - - } - -// public boolean isPairOf(VURI metamodel1vuri, VURI metamodel2vuri) { -// return (metamodelA.isMetamodelFor(metamodel1vuri) && metamodelB.isMetamodelFor(metamodel2vuri) || -// metamodelB.isMetamodelFor(metamodel1vuri) && metamodelA.isMetamodelFor(metamodel2vuri)); -// } - -} diff --git a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/repository/VitruvDomainRepository.java b/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/repository/VitruvDomainRepository.java index bbc8597089..28dc19d3df 100644 --- a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/repository/VitruvDomainRepository.java +++ b/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/repository/VitruvDomainRepository.java @@ -2,15 +2,12 @@ import org.eclipse.emf.ecore.EObject; -import tools.vitruv.framework.domains.TuidAwareVitruvDomain; import tools.vitruv.framework.domains.VitruvDomain; -import tools.vitruv.framework.tuid.Tuid; import tools.vitruv.framework.util.datatypes.VURI; public interface VitruvDomainRepository extends Iterable { VitruvDomain getDomain(EObject object); boolean hasDomain(EObject object); - TuidAwareVitruvDomain getDomain(Tuid tuid); VitruvDomain getDomain(VURI mmURI); VitruvDomain getDomain(String fileExtension); } diff --git a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/repository/VitruvDomainRepositoryImpl.java b/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/repository/VitruvDomainRepositoryImpl.java index 001f3fbd89..c1b3884348 100644 --- a/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/repository/VitruvDomainRepositoryImpl.java +++ b/bundles/framework/tools.vitruv.framework.domains/src/tools/vitruv/framework/domains/repository/VitruvDomainRepositoryImpl.java @@ -6,9 +6,7 @@ import org.eclipse.emf.ecore.EObject; -import tools.vitruv.framework.domains.TuidAwareVitruvDomain; import tools.vitruv.framework.domains.VitruvDomain; -import tools.vitruv.framework.tuid.Tuid; import tools.vitruv.framework.util.datatypes.ClaimableHashMap; import tools.vitruv.framework.util.datatypes.ClaimableMap; import tools.vitruv.framework.util.datatypes.VURI; @@ -76,16 +74,4 @@ public boolean hasDomain(EObject object) { return false; } - @Override - public TuidAwareVitruvDomain getDomain(Tuid tuid) { - for (VitruvDomain domain : nsUri2Domain.values()) { - if (domain instanceof TuidAwareVitruvDomain) { - TuidAwareVitruvDomain typedDomain = (TuidAwareVitruvDomain)domain; - if (typedDomain.hasTuid(tuid.toString())) { - return typedDomain; - } - } - } - throw new IllegalStateException("No domain for given tuid <" + tuid+ "> registered"); - } } diff --git a/bundles/framework/tools.vitruv.framework.tuid/.classpath b/bundles/framework/tools.vitruv.framework.tuid/.classpath deleted file mode 100644 index 1fefbd6f31..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/.classpath +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/framework/tools.vitruv.framework.tuid/.project b/bundles/framework/tools.vitruv.framework.tuid/.project deleted file mode 100644 index 9c1bcfea5b..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - tools.vitruv.framework.tuid - - - - - - org.eclipse.xtext.ui.shared.xtextBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - org.eclipse.xtext.ui.shared.xtextNature - - diff --git a/bundles/framework/tools.vitruv.framework.tuid/.tests-without-platform b/bundles/framework/tools.vitruv.framework.tuid/.tests-without-platform deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/bundles/framework/tools.vitruv.framework.tuid/META-INF/MANIFEST.MF b/bundles/framework/tools.vitruv.framework.tuid/META-INF/MANIFEST.MF deleted file mode 100644 index 9608124e76..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/META-INF/MANIFEST.MF +++ /dev/null @@ -1,14 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Vitruv Framework Temporary Unique Identifier Specification -Bundle-SymbolicName: tools.vitruv.framework.tuid -Automatic-Module-Name: tools.vitruv.framework.tuid -Bundle-Version: 2.1.0.qualifier -Bundle-RequiredExecutionEnvironment: JavaSE-11 -Require-Bundle: org.apache.log4j, - org.eclipse.xtend.lib, - org.eclipse.emf.ecore.change, - tools.vitruv.framework.util;visibility:=reexport, - org.junit.jupiter.api -Export-Package: tools.vitruv.framework.tuid -Bundle-Vendor: vitruv.tools diff --git a/bundles/framework/tools.vitruv.framework.tuid/build.properties b/bundles/framework/tools.vitruv.framework.tuid/build.properties deleted file mode 100644 index b33c598603..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/build.properties +++ /dev/null @@ -1,6 +0,0 @@ -source.. = src/,\ - xtend-gen/,\ - src-test/ -output.. = target/classes/ -bin.includes = META-INF/,\ - . diff --git a/bundles/framework/tools.vitruv.framework.tuid/src-test/tools/vitruv/framework/tuid/TuidTest.java b/bundles/framework/tools.vitruv.framework.tuid/src-test/tools/vitruv/framework/tuid/TuidTest.java deleted file mode 100644 index e1d23d5e7b..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/src-test/tools/vitruv/framework/tuid/TuidTest.java +++ /dev/null @@ -1,334 +0,0 @@ -package tools.vitruv.framework.tuid; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.jupiter.api.Test; - -import tools.vitruv.framework.util.VitruviusConstants; - -public class TuidTest { - - @Test - public void test() { - String sep = VitruviusConstants.getTuidSegmentSeperator(); - // 1: p#s ..... -> p2#s ..... 2-> p2#s2 .............................. 5-> q#s2 - // 2: p#s#c.i . -> p2#s#c.i . 2-> p2#s2#c.i ........... 4-> p2#s2#ci.. 5-> q#s2#ci - // 3: p#t#d ... -> p2#t#d ............................................ 5-> q#t#d - // 4: q#t#e#a ............................. 3-> q#u#e#a ....................... 6-> r#u#e#a - // 5: q#u#f ................................................................... 6-> r#u#f - // 6: q#u#e ................................................................... 6-> r#u#e - // 7: p#s#c.i#a -> p2#s#c.i#a 2-> p2#s2#c.i#a ......... 4-> p2#s2#ci#a 5-> q#s2#ci#a - // 8: p#t ..... -> p2#t .............................................. 5-> q#t - // 9: r - // legend: - // -> = after first operation (rename folder p to p2) - // 2-> = after second operation (rename folder s to s2) - // 3-> after third operation (move folder, package, or file t to existing folder, - // package, or file u = merge) - // 4-> after fourth operation (rename package c.i to ci) - // 5-> after fifth operation (rename folder p2 to q) - // 6-> after sixth operation (move folder u in q to u in r = no merge) - - /**************************/ - /** BEGIN INITIALIZATION **/ - /**************************/ - String s1prefix = "p"; - String s1 = s1prefix + sep + "s"; - Tuid tuid1 = Tuid.getInstance(s1); - assertEquals(s1, tuid1.toString()); - String s2 = s1 + sep + "c.i"; - Tuid tuid2 = Tuid.getInstance(s2); - assertEquals(s2, tuid2.toString()); - String s3 = s1prefix + sep + "t" + sep + "d"; - Tuid tuid3 = Tuid.getInstance(s3); - assertEquals(s3, tuid3.toString()); - String s4prefix = "q" + sep + "t"; - String s4 = s4prefix + sep + "e" + sep + "a"; - Tuid tuid4 = Tuid.getInstance(s4); - assertEquals(s4, tuid4.toString()); - String s5prefix = "q" + sep + "u"; - String s5 = s5prefix + sep + "f"; - Tuid tuid5 = Tuid.getInstance(s5); - assertEquals(s5, tuid5.toString()); - String s6 = s5prefix + sep + "e"; - Tuid tuid6 = Tuid.getInstance(s6); - assertEquals(s6, tuid6.toString()); - String s7 = s1 + sep + "c.i" + sep + "a"; - Tuid tuid7 = Tuid.getInstance(s7); - assertEquals(s7, tuid7.toString()); - String s8 = s1prefix + sep + "t"; - Tuid tuid8 = Tuid.getInstance(s8); - assertEquals(s8, tuid8.toString()); - String s9 = "r"; - Tuid tuid9 = Tuid.getInstance(s9); - assertEquals(s9, tuid9.toString()); - System.out - .println("**** BEGIN INITIALIZATION ****\n" + Tuid.toStrings() + "\n**** END INITIALIZATION ****\n\n"); - assertTrue(Tuid.validate()); - /************************/ - /** END INITIALIZATION **/ - /************************/ - - /*********************************************/ - /** first operation (rename folder p to p2) **/ - /*********************************************/ - Tuid tuid1prefix = Tuid.getInstance(s1prefix); - assertEquals(s1prefix, tuid1prefix.toString()); - String s1prefixr = "p2"; - Tuid tuid1prefixr = Tuid.getInstance(s1prefixr); - tuid1prefix.updateTuid(tuid1prefixr); - System.out.println("**** BEGIN FIRST OPERATION ****\n" + Tuid.toStrings() - + "\n**** END FIRST OPERATION ****\n\n"); - assertEquals(s1prefixr, tuid1prefix.toString()); - String s1r = s1prefixr + sep + "s"; - assertEquals(s1r, tuid1.toString()); - String s2r = s1r + sep + "c.i"; - assertEquals(s2r, tuid2.toString()); - String s3r = s1prefixr + sep + "t" + sep + "d"; - assertEquals(s3r, tuid3.toString()); - String s7r = s1r + sep + "c.i" + sep + "a"; - assertEquals(s7r, tuid7.toString()); - String s8r = s1prefixr + sep + "t"; - assertEquals(s8r, tuid8.toString()); - assertTrue(Tuid.validate()); - - /**********************************************/ - /** second operation (rename folder s to s2) **/ - /**********************************************/ - tuid1.updateTuid(Tuid.getInstance(s1prefixr + sep + "s2")); - System.out.println("**** BEGIN SECOND OPERATION ****\n" + Tuid.toStrings() - + "\n**** END SECOND OPERATION ****\n\n"); - String s1rr = "p2" + sep + "s2"; - assertEquals(s1rr, tuid1.toString()); - String s2rr = s1rr + sep + "c.i"; - assertEquals(s2rr, tuid2.toString()); - String s7rr = s2rr + sep + "a"; - assertEquals(s7rr, tuid7.toString()); - assertTrue(Tuid.validate()); - - /***********************************************************/ - /** third operation (move t to existing folder u = merge) **/ - /***********************************************************/ - Tuid tuid4prefix = Tuid.getInstance(s4prefix); - Tuid tuid5prefix = Tuid.getInstance(s5prefix); - tuid4prefix.updateTuid(tuid5prefix); - System.out.println("**** BEGIN THIRD OPERATION ****\n" + Tuid.toStrings() - + "\n**** END THIRD OPERATION ****\n\n\n"); - assertEquals(s5prefix, tuid4prefix.toString()); - String s4rrr = s5prefix + sep + "e" + sep + "a"; - assertEquals(s4rrr, tuid4.toString()); - assertEquals(s5, tuid5.toString()); - assertTrue(Tuid.validate()); - - /*************************************************/ - /** fourth operation (rename package c.i to ci) **/ - /*************************************************/ - String s2rrrr = s1rr + sep + "ci"; - tuid2.updateTuid(Tuid.getInstance(tuid1.toString() + sep + "ci")); - System.out.println("**** BEGIN FOURTH OPERATION ****\n" + Tuid.toStrings() - + "\n**** END FOURTH OPERATION ****\n\n"); - assertEquals(s2rrrr, tuid2.toString()); - String s7rrrr = s2rrrr + sep + "a"; - assertEquals(s7rrrr, tuid7.toString()); - assertTrue(Tuid.validate()); - - /*********************************************/ - /** fifth operation (rename folder p2 to q) **/ - /*********************************************/ - String s1prefixrrrrr = "q"; - tuid1prefix.updateTuid(Tuid.getInstance(s1prefixrrrrr)); - System.out.println("**** BEGIN FIFTH OPERATION ****\n" + Tuid.toStrings() - + "\n**** END FIFTH OPERATION ****\n\n"); - String s1rrrrr = s1prefixrrrrr + sep + "s2"; - assertEquals(s1rrrrr, tuid1.toString()); - String s2rrrrr = s1rrrrr + sep + "ci"; - assertEquals(s2rrrrr, tuid2.toString()); - String s3rrrrr = s1prefixrrrrr + sep + "t" + sep + "d"; - assertEquals(s3rrrrr, tuid3.toString()); - String s4rrrrr = s1prefixrrrrr + sep + "u" + sep + "e" + sep + "a"; - assertEquals(s4rrrrr, tuid4.toString()); - String s7rrrrr = s2rrrrr + sep + "a"; - assertEquals(s7rrrrr, tuid7.toString()); - String s8rrrrr = s1prefixrrrrr + sep + "t"; - assertEquals(s8rrrrr, tuid8.toString()); - - // unchanged Tuids - assertEquals(s5, tuid5.toString()); - assertEquals(s6, tuid6.toString()); - assertTrue(Tuid.validate()); - - /***************************************************************/ - /** sixth operation (move folder u in q to u in r = no merge) **/ - /***************************************************************/ - String s5prefixrrrrrr = s9 + sep + "u"; - Tuid tuid5prefixrrrrrr = Tuid.getInstance(s5prefixrrrrrr); - tuid5prefix.updateTuid(tuid5prefixrrrrrr); - System.out.println("**** BEGIN SIXTH OPERATION ****\n" + Tuid.toStrings() - + "\n**** END SIXTH OPERATION ****\n\n"); - assertEquals(s5prefixrrrrrr, tuid5prefix.toString()); - String s4rrrrrr = s5prefixrrrrrr + sep + "e" + sep + "a"; - assertEquals(s4rrrrrr, tuid4.toString()); - String s5rrrrrr = s5prefixrrrrrr + sep + "f"; - assertEquals(s5rrrrrr, tuid5.toString()); - String s6rrrrrr = s5prefixrrrrrr + sep + "e"; - assertEquals(s6rrrrrr, tuid6.toString()); - - // unchanged Tuid - assertEquals(s9, tuid9.toString()); - assertTrue(Tuid.validate()); - } - - @Test - public void testUpdateSingleSegmentTargetContainsChildren() { - boolean useUpdateMultipleSegmentsMethod = false; - testUpdateSingleSegment(useUpdateMultipleSegmentsMethod); - } - - @Test - public void testUpdateSingleSegmentUsingMultipleSegmentChange() { - boolean useUpdateMultipleSegmentsMethod = true; - testUpdateSingleSegment(useUpdateMultipleSegmentsMethod); - } - - public void testUpdateSingleSegment(final boolean useUpdateMultipleSegmentsMethod) { - String[] input = new String[] { "prefix#b", "prefix#b#c", "prefix#b#c#d", "prefix#b#c2#d" }; - String[] expected = new String[] { "prefix#b", "prefix#b#c2", "prefix#b#c2#d", "prefix#b#c2#d" }; - testUpdateSegment(input, expected, "prefix#b#c", "prefix#b#c2", useUpdateMultipleSegmentsMethod); - } - - private void testUpdateSegment(final String[] input, final String[] expected, final String oldTuidString, - final String newTuidString, final boolean updateMultipleSegments) { - // construct Tuids - List tuids = new ArrayList(); - for (String tuidString : input) { - tuids.add(Tuid.getInstance(tuidString)); - } - - Tuid oldTuid = Tuid.getInstance(oldTuidString); - Tuid newTuid = Tuid.getInstance(newTuidString); - - oldTuid.updateTuid(newTuid); - - // validate Tuid - assertTrue(Tuid.validate()); - - // check renaming - String[] actual = new String[tuids.size()]; - for (int i = 0; i < tuids.size(); ++i) { - actual[i] = tuids.get(i).toString(); - } - assertArrayEquals(expected, actual); - - } - - @Test - public void testUpdateSingleSegmentTargetContainsNoChildren() { - String[] input = new String[] { "prefix2#a", "prefix2#a#b", "prefix2#a#c" }; - String[] expected = new String[] { "prefix2#a", "prefix2#a#c", "prefix2#a#c" }; - - // construct Tuids - List tuids = new ArrayList(); - for (String tuidString : input) { - tuids.add(Tuid.getInstance(tuidString)); - } - - // rename Tuids - Tuid oldTuid = Tuid.getInstance("prefix2#a#b"); - Tuid newTuid = Tuid.getInstance("prefix2#a#c"); - oldTuid.updateTuid(newTuid); - - // validate Tuid - assertTrue(Tuid.validate()); - - // check renaming - String[] actual = new String[tuids.size()]; - for (int i = 0; i < tuids.size(); ++i) { - actual[i] = tuids.get(i).toString(); - } - assertArrayEquals(expected, actual); - } - - - @Test - public void testRenameHierarchical() { - String sep = VitruviusConstants.getTuidSegmentSeperator(); - String prefix = "prefix" + sep; - String s1 = prefix + "a"; - Tuid t1 = Tuid.getInstance(s1); - String s1new = prefix + "d"; - Tuid t1new = Tuid.getInstance(s1new); - String s1new2 = prefix + "e"; - Tuid t1new2 = Tuid.getInstance(s1new2); - String s2 = prefix + "a" + sep + "b"; - Tuid t2 = Tuid.getInstance(s2); - String s2new = prefix + "d" + sep + "b"; - Tuid t2new = Tuid.getInstance(s2new); - String s3 = prefix + "a" + sep + "b" + sep + "c"; - Tuid t3 = Tuid.getInstance(s3); - t2.updateTuid(t2new); - assertEquals(t2, t2new); - assertEquals(s2new + sep + "c", t3.toString()); - t1.updateTuid(t1new); - assertEquals(t1, t1new); - String s4 = prefix + "f" + sep + "b"; - Tuid t4 = Tuid.getInstance(s4); - String s4new = prefix + "e" + sep + "b"; - Tuid t4new = Tuid.getInstance(s4new); - t4.updateTuid(t4new); - assertEquals(t4, t4new); - t1.updateTuid(t1new2); - assertEquals(t1new2, t1new); - assertEquals(t1new2, t1); - assertEquals(prefix + "e" + sep + "b", t2.toString()); - assertEquals(prefix + "e" + sep + "b" + sep + "c", t3.toString()); - assertEquals(t2, t4); - assertEquals(t2new, t4); - } - - @Test - public void testRenameDuplicateTuidInstance() { - String sep = VitruviusConstants.getTuidSegmentSeperator(); - String prefix = "prefix" + sep; - String s1 = prefix + "a"; - Tuid t1 = Tuid.getInstance(s1); - String s1new = prefix + "d"; - Tuid t1new = Tuid.getInstance(s1new); - String s1new2 = prefix + "e"; - Tuid t1new2 = Tuid.getInstance(s1new2); - t1.updateTuid(t1new); - assertEquals(t1, t1new); - t1.updateTuid(t1new2); - assertEquals(t1new2, t1new); - assertEquals(t1new2, t1); - } - - - @Test - public void testRenameChildMerge() { - String sep = VitruviusConstants.getTuidSegmentSeperator(); - String prefix = "prefix" + sep; - String s1 = prefix + "a"; - Tuid t1 = Tuid.getInstance(s1); - String s1new = prefix + "b"; - Tuid t1new = Tuid.getInstance(s1new); - String s2 = prefix + "a" + sep + "c"; - Tuid t2 = Tuid.getInstance(s2); - String s2new = prefix + "b" + sep + "c"; - Tuid t2new = Tuid.getInstance(s2new); - String s2new2 = prefix + "b" + sep + "d"; - Tuid t2new2 = Tuid.getInstance(s2new2); - t1.updateTuid(t1new); - assertEquals(t1, t1new); - assertEquals(t2, t2new); - t2new.updateTuid(t2new2); - assertEquals(t2, t2new2); - assertEquals(t2, t2new); - assertEquals(prefix + "b" + sep + "d", t2.toString()); - assertEquals(prefix + "b" + sep + "d", t2new.toString()); - } -} diff --git a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/AttributeTuidCalculatorAndResolver.java b/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/AttributeTuidCalculatorAndResolver.java deleted file mode 100644 index 1c4b2fa545..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/AttributeTuidCalculatorAndResolver.java +++ /dev/null @@ -1,65 +0,0 @@ -package tools.vitruv.framework.tuid; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.change.impl.ChangeDescriptionImpl; - -import tools.vitruv.framework.util.bridges.EcoreBridge; - -/** - * A {@link HierarchicalTuidCalculatorAndResolver} that creates the Tuid for - * each {@link EObject} by finding the first attribute from the list that the - * EObject possesses and returning "{attribute name}={attribute value}". - * - * @see DefaultTuidCalculatorAndResolver - * @author Dominik Werle - */ -public class AttributeTuidCalculatorAndResolver extends HierarchicalTuidCalculatorAndResolver { - private final List attributeNames; - - public AttributeTuidCalculatorAndResolver(final String tuidPrefix, final String... attributeNames) { - super(tuidPrefix); - this.attributeNames = Arrays.asList(attributeNames); - } - - public AttributeTuidCalculatorAndResolver(final String tuidPrefix, final List attributeNames) { - super(tuidPrefix); - this.attributeNames = new ArrayList(attributeNames); - } - - @Override - protected boolean hasId(final EObject obj, final String indidivualId) throws IllegalArgumentException { - return indidivualId.equals(calculateIndividualTuidDelegator(obj)); - } - - @Override - protected String calculateIndividualTuidDelegator(final EObject obj) throws IllegalArgumentException { - for (String attributeName : this.attributeNames) { - final String attributeValue = EcoreBridge.getStringValueOfAttribute(obj, attributeName); - if (null != attributeValue) { - String subTuid = (obj.eContainingFeature() == null || obj.eContainer() instanceof ChangeDescriptionImpl ? "" - : obj.eContainingFeature().getName()) + SUBDIVIDER + obj.eClass().getName() + SUBDIVIDER - + attributeName + "=" + attributeValue; - return subTuid; - } else { - EStructuralFeature idFeature = obj.eClass().getEStructuralFeature(attributeName); - if (idFeature != null && !obj.eIsSet(idFeature)) { - return attributeName; - } - } - } - - throw new RuntimeException( - "None of '" + String.join("', '", this.attributeNames) + "' found for eObject '" + obj + "'"); - } - - protected List getAttributeNames() { - return Collections.unmodifiableList(attributeNames); - } - -} diff --git a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/HierarchicalTuidCalculatorAndResolver.java b/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/HierarchicalTuidCalculatorAndResolver.java deleted file mode 100644 index b6f8bb6dfe..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/HierarchicalTuidCalculatorAndResolver.java +++ /dev/null @@ -1,211 +0,0 @@ -package tools.vitruv.framework.tuid; - -import java.util.Arrays; -import java.util.LinkedList; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; - -import tools.vitruv.framework.util.VitruviusConstants; - -/** - * Base class for hierarchical Tuid calculators. Hierarchical means that the Tuid reflects the - * containment hierarchy and for each element in this hierarchy a segment is added. The subclasses - * only have to provide the strings for the individual segments. The string does not have to be - * unique but has to become unique in combination with the segments from higher hierarchical levels. - * - * @author Stephan Seifermann - * - */ -public abstract class HierarchicalTuidCalculatorAndResolver extends TuidCalculatorAndResolverBase { - - public static final String SUBDIVIDER = "-_-"; - - public HierarchicalTuidCalculatorAndResolver(final String tuidPrefix) { - super(tuidPrefix); - } - - // ============================================================================ - // Tuid resolution - // ============================================================================ - @Override - protected EObject getIdentifiedEObjectWithinRootEObjectInternal(final EObject root, final String[] ids) { - return findById(root, ids); - } - - /** - * Finds the wanted EObject in a given root object. - * - * @param rootObject - * The root object from which the search shall be started. - * @param ids - * An array of the Tuid segments. The segments of the root object have to be removed - * before calling this method. - * @return The found EObject or null if there is no matching EObject. - */ - private EObject findById(final EObject rootObject, final String[] ids) { - // finds EObjects using brute force approach - EObject obj = rootObject; - for (String[] runningIds = ids; obj != null - && runningIds.length > 0; runningIds = removeFirstElement(runningIds)) { - obj = findById(obj, runningIds[0]); - } - return obj; - } - - /** - * Finds a single EObject, which is contained by the given root object. The root object does NOT - * have to be the root object of the whole model but the parent of the searched EObject. - * - * @param rootObject - * The object, which's containment have to checked. - * @param individualId - * The identifier of the wanted EObject. This has to be exactly one segment of a - * Tuid. - * @return The found EObject or null if there is no matching EObject. - */ - private EObject findById(final EObject rootObject, final String individualId) { - for (EReference containment : rootObject.eClass().getEAllContainments()) { - EObject match = findMatchingEObject(rootObject.eGet(containment), individualId); - if (match != null) { - return match; - } - } - return null; - } - - /** - * Looks for the wanted EObject by checking the candidate object. There are two options: - *
    - *
  1. The candidate is an EObject, so we compare it's ID.
  2. - *
  3. The candidate is an EList, so we compare the IDs of all of its elements.
  4. - *
- * - * @param candidate - * The candidate object (EObject or EList). - * @param individualId - * The ID of the wanted EObject. - * @return The matched EObject or null if there was no match. - */ - @SuppressWarnings("unchecked") - private EObject findMatchingEObject(final Object candidate, final String individualId) { - if (candidate instanceof Iterable) { - for (EObject obj : (Iterable) candidate) { - if (matchesIndividualId(obj, individualId)) { - return obj; - } - } - } else if (candidate instanceof EObject) { - if (matchesIndividualId((EObject) candidate, individualId)) { - return (EObject) candidate; - } - } - - return null; - } - - /** - * Compares the individual ID of the given object with the given individual ID. - * - * @param obj - * The object for the comparison. - * @param individualId - * The individual ID for the comparison. - * @return True if the object has the individual ID. - */ - private boolean matchesIndividualId(final EObject obj, final String individualId) { - try { - return hasId(obj, individualId); - } catch (IllegalArgumentException e) { - return false; - } - } - - /** - * Checks if the given EObject has the same individual ID as the one passed to this method. - * - * @param obj - * The object to check. - * @param indidivualId - * The individual ID to check. - * @return True if the object has the same individual ID. - * @throws IllegalArgumentException - * If there is no Tuid calculation mechanism for this particular type of EObject. - */ - protected abstract boolean hasId(EObject obj, String indidivualId) throws IllegalArgumentException; - - // ============================================================================ - // Tuid generation - // ============================================================================ - @Override - public String calculateTuidFromEObject(final EObject eObject, final EObject virtualRootObject, - final String prefix) { - if (!isValidTuid(prefix) || prefix.endsWith(VitruviusConstants.getTuidSegmentSeperator())) { - throw new IllegalArgumentException( - "The given prefix is invalid (must contain URI and default segment and must NOT end with a separator."); - } - - LinkedList segments = new LinkedList(); - EObject parent = eObject; - for (; parent != null && parent != virtualRootObject; parent = parent.eContainer()) { - String currentSegment = calculateIndividualTuidDelegator(parent); - if (0 < currentSegment.length()) { - segments.push(currentSegment); - } - } - // at this position parent is null || parent == virtualRootObject - segments.push(prefix); - - String finalString = ""; - for (String segment : segments) { - finalString = finalString + segment + VitruviusConstants.getTuidSegmentSeperator(); - } - if (finalString.endsWith(VitruviusConstants.getTuidSegmentSeperator())) { - finalString = finalString.substring(0, finalString.length() - VitruviusConstants.getTuidSegmentSeperator().length()); - } - return finalString; - } - - /** - * Calculates the individual ID for the given object. - * - * @param obj - * The object for the ID calculation. - * @return The individual ID. - * @throws IllegalArgumentException - * If there is no Tuid calculation mechanism for this particular type of EObject. - */ - protected abstract String calculateIndividualTuidDelegator(EObject obj) throws IllegalArgumentException; - - // ============================================================================ - // Helper stuff - // ============================================================================ - /** - * Creates a new array with the first element removed. - * - * @param ids - * The array for removal. - * @param - * The type of the array. - * @return The sliced array. - */ - private static T[] removeFirstElement(final T[] ids) { - return removeFirstElements(ids, 1); - } - - /** - * Creates a new array with the first n elements removed. - * - * @param ids - * The array for removal. - * @param numberOfIdsToRemove - * The number of elements to remove. - * @param - * The type of the array. - * @return The sliced array. - */ - private static T[] removeFirstElements(final T[] ids, final int numberOfIdsToRemove) { - return Arrays.copyOfRange(ids, numberOfIdsToRemove, ids.length); - } - -} diff --git a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/Tuid.xtend b/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/Tuid.xtend deleted file mode 100644 index 3ebc4b733d..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/Tuid.xtend +++ /dev/null @@ -1,258 +0,0 @@ -package tools.vitruv.framework.tuid - -import java.io.Serializable -import java.util.Arrays -import java.util.Collection -import java.util.HashMap -import java.util.HashSet -import java.util.List -import java.util.Set -import tools.vitruv.framework.util.VitruviusConstants -import tools.vitruv.framework.util.datatypes.ForwardHashedBackwardLinkedTree - -import java.util.ArrayList -import tools.vitruv.framework.util.datatypes.ForwardHashedBackwardLinkedTree.Segment -import org.eclipse.emf.ecore.EObject - -/** - * A class for Temporarily Unique IDentifiers (Tuids) that internally uses a{@link ForwardHashedBackwardLinkedTree} to ensure that depending Tuids are indirectly changed, - * i.e. a call to toString() always returns the current Tuid based on the links to its predecessors. - * Implements the multiton design pattern to ensure that there exists only one Tuid instance per - * String key.
- *
- * Helpful thoughts for Tuid modifications in file systems and Java projects:
- *
- * If a package is renamed in Java, then only the paths of all contained classifiers are affected. - * The paths of subpackages are not affected but they are no longer subpackages. If a package is - * renamed in Java, then the depth of its path may change arbitrarily. In such cases{@link #renameLastSegment(String)} should be called.
- *
- * If a folder is renamed, then the paths of all contained elements are affected but the depth may - * not change. In such cases {@link #renameLastSegment(String)} should be called.
- *
- * If a package is moved in Java, then it may only be completely moved to another folder and - * subpackages are not affected. It is not possible to move subpackages to another package. It is - * however possible to move a package to a folder in which the package or a subpackage is already - * existing, then the packages are merged. In such cases {@link #moveLastSegment(String)} should be - * called.
- *
- * If a folder is moved, then the paths of all contained elements are affected and the depth may - * change. If the destination folder already exists the containing elements of both folders are - * merged. In such cases {@link #moveLastSegment(String)} should be called.
- *
- * @author kramerm - */ -final class Tuid implements Serializable { - public static final String META_ELEMENT_PREFIX = "MetaElement" - - protected static final long serialVersionUID = 5018494116382201707L - - static var SEGMENTS = generateForwardHashedBackwardLinkedTree() - static val LAST_SEGMENT_2_Tuid_INSTANCES_MAP = new HashMap.Segment, List>() - - package static def reinitialize() { - SEGMENTS = generateForwardHashedBackwardLinkedTree(); - } - - def updateTuid(EObject newObject) { - TuidManager.instance.updateTuid(this, newObject); - } - - def private static generateForwardHashedBackwardLinkedTree() { - return new ForwardHashedBackwardLinkedTree() - } - - var ForwardHashedBackwardLinkedTree.Segment lastSegment - - /** - * Multiton classes should not have a public or default constructor. - */ - private new(List splitTuidString) { - this.lastSegment = SEGMENTS.addNewSegmentsWhereNecessary(splitTuidString); - mapSegmentToTuid(lastSegment, this); - } - - /** - * Returns the unique Tuid (instance) for the specified tuidString (key). - * @param tuidString - * @return the unique Tuid for the specified tuidString - */ - def static synchronized Tuid getInstance(String tuidString) { - return getInstance(tuidString, false) - } - - def private static synchronized Tuid getInstance(String tuidString, boolean recursively) { - if (tuidString === null) { - throw new IllegalArgumentException("The null string is no Tuid!") - } else { - val splitTuidString = split(tuidString) - var lastSegmentOrPrefix = SEGMENTS.getMaximalPrefix(splitTuidString) - var Tuid instance - val lastSegmentOrPrefixString = if (lastSegmentOrPrefix !== null) { - lastSegmentOrPrefix.toString(VitruviusConstants.getTuidSegmentSeperator()); - } - if (lastSegmentOrPrefixString !== null && lastSegmentOrPrefixString.equals(tuidString)) { - // the complete specified tuidString was already mapped - val instances = LAST_SEGMENT_2_Tuid_INSTANCES_MAP.get(lastSegmentOrPrefix); - if (instances. - nullOrEmpty) { - if (!recursively) { - throw new IllegalStateException('''A Tuid instance for the last segment '«»«lastSegmentOrPrefix»' should already have been mapped for the tuidString '«»«tuidString»'!''') - } - } else { - return instances.get(0) - } - } - // a real prefix of the specified tuidString or nothing was already mapped (but not - // the complete tuidString) - instance = new Tuid(splitTuidString) - var lastSegment = instance.getLastSegment() - // also create Tuids for all prefixes of the specified tuidString and register them - val segmentIterator = lastSegment.iterator() - var ForwardHashedBackwardLinkedTree.Segment pivot - while (segmentIterator.hasNext()) { - pivot = segmentIterator.next() - getInstance(pivot.toString(VitruviusConstants.getTuidSegmentSeperator()), true) - } - return instance - } - } - - private static def void mapSegmentToTuid(Segment segment, Tuid tuid) { - val segmentToTuidsListImmutable = LAST_SEGMENT_2_Tuid_INSTANCES_MAP.get(segment); - val segmentToTuidsList = if (segmentToTuidsListImmutable !== null) { - new ArrayList(segmentToTuidsListImmutable); - } else { - new ArrayList(); - } - segmentToTuidsList.add(tuid); - LAST_SEGMENT_2_Tuid_INSTANCES_MAP.put(segment, segmentToTuidsList); - } - - /** - * Changes the given tuid so that it points to the given newLastSegment.
- * ATTENTION: This changes the hashcode of the given tuid! - * @param tuid - * @param newLastSegment - */ - def private static synchronized void updateInstance(Tuid tuid, - ForwardHashedBackwardLinkedTree.Segment newLastSegment) { - TuidManager.instance.notifyListenerBeforeTuidUpdate(tuid) - val oldSegment = tuid.lastSegment - val tuidsForOldSegment = new ArrayList(LAST_SEGMENT_2_Tuid_INSTANCES_MAP.remove(oldSegment)); - for (representant : tuidsForOldSegment) { - representant.lastSegment = newLastSegment; - mapSegmentToTuid(newLastSegment, representant); - } - TuidManager.instance.notifyListenerAfterTuidUpdate(tuid) - } - - def private static List split(String tuidString) { - val seperator = VitruviusConstants.getTuidSegmentSeperator() - // TODO replace this possibly ArrayList with a LinkList if performance is not sufficient - return Arrays.asList(tuidString.split(seperator)) - } - - def private ForwardHashedBackwardLinkedTree.Segment getLastSegment() { - return this.lastSegment - } - - /** - * Either a) renames the last segment of this Tuid to the last segment of the given {@link newTuid} - * if they differ and all previous segments are the same or b) moves the last segment of this Tuid to the second but last - * segment of the given {@link newTuid}. - */ - def void updateTuid(Tuid newTuid) { - if (this.equals(newTuid)) { - return; - } - moveLastSegment(newTuid) - } - - /** - * Moves the last segment of this Tuid instance to the specified destination. If the destination - * already exists, then all depending Tuids of this instance and the destination instance are - * merged. - * @param fullDestinationTuidthe full Tuid of the move destination - * @return - */ - def private void moveLastSegment(Tuid fullDestinationTuid) { - val segmentPairs = SEGMENTS.mergeSegmentIntoAnother(this.lastSegment, fullDestinationTuid.lastSegment) - for (segmentPair : segmentPairs) { - val oldSegment = segmentPair.getFirst() - val oldTuid = LAST_SEGMENT_2_Tuid_INSTANCES_MAP.get(oldSegment).get(0) - val newSegment = segmentPair.getSecond() - // this update changes the hashcode of the given tuid - Tuid.updateInstance(oldTuid, newSegment) - } - } - - override String toString() { - return this.lastSegment.toString(VitruviusConstants.getTuidSegmentSeperator()) - } - - /** - * Returns a String representation of all registered Tuid instances. - * @return a String representation of all registered Tuid instances - */ - def static String toStrings() { - return '''Tuid segments: -«SEGMENTS.toString()» -lastSegment2TuidMap: -«LAST_SEGMENT_2_Tuid_INSTANCES_MAP.toString()»''' - } - - override int hashCode() { - return 31 + (if(this.lastSegment === null) 0 else this.lastSegment.hashCode()) - } - - override boolean equals(Object obj) { - if(this === obj) return true - if(obj === null) return false - if (getClass() !== obj.getClass()) { - return false - } - var Tuid other = obj as Tuid - if (this.lastSegment === null) { - if (other.lastSegment !== null) { - return false - } - } else if (!this.lastSegment.equals(other.lastSegment)) { - return false - } - return true - } - - /** - * Returns whether the Tuid instance is valid in the sense that all Tuid instances that are - * contained in the forward (tree) registry are also contained in the backward (link) registry - * and vice-versa. - * @return whether the Tuid instance is valid - * @throws a {@link IllegalStateException} if the Tuid instance is not valid - */ - def static boolean validate() { - val Set treedTuidStrings = new HashSet() - val Collection.Segment> segments = SEGMENTS.values() - for (ForwardHashedBackwardLinkedTree.Segment segment : segments) { - val String tuidString = segment.toString(VitruviusConstants.getTuidSegmentSeperator()) - treedTuidStrings.add(tuidString) - } - val Collection tuids = LAST_SEGMENT_2_Tuid_INSTANCES_MAP.values().map[it.get(0)].toList; - if (treedTuidStrings.size() !== - tuids. - size()) { - throw new IllegalStateException('''«treedTuidStrings.size()» Tuids are in the segment tree («treedTuidStrings») but «tuids.size()» are mapped by their last segments («tuids»)!''') - } - for (Tuid tuid : tuids) { - val String tuidString = tuid.toString() - if (!treedTuidStrings.contains( - tuidString)) { - throw new IllegalStateException('''The Tuid '«»«tuidString»' is mapped by its last segment but not in the tree!''') - } - } - return true - } - - def boolean isMetaElementTuid() { - return this.toString().startsWith(META_ELEMENT_PREFIX); - } -} diff --git a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/Tuid4Serialization.java b/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/Tuid4Serialization.java deleted file mode 100644 index 2bda4e498d..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/Tuid4Serialization.java +++ /dev/null @@ -1,25 +0,0 @@ -package tools.vitruv.framework.tuid; - -import java.io.ObjectStreamException; -import java.io.Serializable; - -/** - * Class that is only used to serialize and deserialize Tuids. - * @author kramerm - * - */ -public class Tuid4Serialization implements Serializable { - /** - * - */ - private static final long serialVersionUID = -4128645104543074428L; - private String tuidString; - - protected void setTuidString(String tuidString) { - this.tuidString = tuidString; - } - - private Object readResolve() throws ObjectStreamException { - return Tuid.getInstance(this.tuidString); - } -} diff --git a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculator.xtend b/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculator.xtend deleted file mode 100644 index c0e4197365..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculator.xtend +++ /dev/null @@ -1,8 +0,0 @@ -package tools.vitruv.framework.tuid - -import org.eclipse.emf.ecore.EObject - -interface TuidCalculator { - def boolean canCalculateTuid(EObject object); - def Tuid calculateTuid(EObject object); -} \ No newline at end of file diff --git a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculatorAndResolver.java b/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculatorAndResolver.java deleted file mode 100644 index 7d9834eb36..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculatorAndResolver.java +++ /dev/null @@ -1,64 +0,0 @@ -package tools.vitruv.framework.tuid; - -import java.util.List; - -import org.eclipse.emf.ecore.EObject; - -public interface TuidCalculatorAndResolver { - - String calculateTuidFromEObject(EObject eObject); - - /** - * syntactic sugar for map[{@link #calculateTuidFromEObject(EObject)}] - * - * @param eObjects - * @return - */ - List calculateTuidsFromEObjects(List eObjects); - - /** - * Calculates the Tuid for an EObject. The given prefix is the Tuid part, which should be used - * instead of the part, which would be inferred from the virtualRootObject. Please note: This - * method is only available for Tuid calculators, which utilize some way of hierarchy. - * - * @param eObject - * The EObject for the Tuid calculation. - * @param virtualRootObject - * The virtual root object, whichs Tuid part is described by the prefix parameter. If - * the parameter is null the real root object of the given EObject is assumed. - * @param prefix - * The prefix, which describes the Tuid part for the virtual root object. It has to - * contain the Tuid calculator identifier and the model URI at least. - * @return The calculated Tuid string. - */ - String calculateTuidFromEObject(EObject eObject, EObject virtualRootObject, String prefix); - - /** - * Returns the VURI for the model that contains the EObject with the given Tuid if it exists and - * otherwise null. - * - * @param tuid - * @return the VURI if it exists, otherwise null - */ - String getModelVURIContainingIdentifiedEObject(String tuid); - - EObject resolveEObjectFromRootAndFullTuid(EObject root, String tuid); - - boolean isValidTuid(String tuid); - - /** - * Notifies the calculator and resolver that the given root EObject should be removed from the - * cache. - * - * @param root - * the root EObject that shall be removed - */ - void removeRootFromCache(EObject root); - - /** - * Removes the root for the given tuid from the cache if it is cached. - * - * @param tuid - */ - void removeIfRootAndCached(String tuid); -} diff --git a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculatorAndResolverBase.xtend b/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculatorAndResolverBase.xtend deleted file mode 100644 index 46a23009fb..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculatorAndResolverBase.xtend +++ /dev/null @@ -1,323 +0,0 @@ -package tools.vitruv.framework.tuid - -import java.util.HashMap -import java.util.Map -import org.apache.log4j.Logger -import org.eclipse.emf.ecore.EObject -import org.eclipse.emf.ecore.change.ChangeDescription -import tools.vitruv.framework.util.VitruviusConstants -import tools.vitruv.framework.util.bridges.EcoreBridge -import tools.vitruv.framework.util.datatypes.ClaimableHashMap -import tools.vitruv.framework.util.datatypes.ClaimableMap -import java.util.List -import tools.vitruv.framework.util.datatypes.VURI -import org.eclipse.emf.common.util.URI -import org.eclipse.emf.ecore.resource.URIConverter -import org.eclipse.emf.ecore.EClass - -/** - * Base class for Tuid calculators and resolvers. It handles the default parts of the Tuid like - * generator identifier and URI inclusion for Tuid calculation and resolution. - * @author Stephan Seifermann - */ -abstract class TuidCalculatorAndResolverBase implements TuidCalculatorAndResolver { - static final Logger LOGGER = Logger.getLogger(TuidCalculatorAndResolverBase) - final String tuidPrefix - // TODO MK check whether cachedResourcelessRoots and cachedRoot2KeyMap can be replaced with a - // BiMap - final ClaimableMap cachedResourcelessRoots - int nextCacheKey = 0 - // TODO MK (cache): if necessary remove objects that were created and cached but never stored, - // as this is the only way to have something in the cache that should no longer be there - final Map cachedRoot2KeyMap - - new(String tuidPrefix) { - this.tuidPrefix = tuidPrefix - this.cachedResourcelessRoots = new ClaimableHashMap() - this.cachedRoot2KeyMap = new HashMap() - } - - override boolean isValidTuid(String tuid) { - return tuid.startsWith(getTuidPrefixAndSeparator()) - } - - /** - * Return the most distant parent eObject of the tree that contains the given eObject if this - * tree exists and otherwise the given eObject itself (beeing the root of a containment tree of - * depth 0). - * @param eObject - * @return the root - */ - def static EObject getMostDistantParentOfSameMetamodel(EObject eObject) { - var EObject root = EcoreBridge.getRootEObject(eObject) - if (!(root instanceof ChangeDescription)) { - return root - } else { - return getMostDistantParentOfSameMetamodelRecirsivly(eObject) - } - } - - def private static EObject getMostDistantParentOfSameMetamodelRecirsivly(EObject eObject) { - var EObject parent = eObject.eContainer() - if (null === parent || (parent instanceof ChangeDescription)) { - return eObject - } - return getMostDistantParentOfSameMetamodelRecirsivly(parent) - } - - - override List calculateTuidsFromEObjects(List eObjects) { - return eObjects.map[calculateTuidFromEObject(it)] - } - - override String calculateTuidFromEObject(EObject eObject) { - if (eObject instanceof EClass) { - return calculateMetaElementTuid(eObject) - } - var EObject root = getMostDistantParentOfSameMetamodel(eObject) - var String tuidPrefix = null - if (root.eResource() === null) { - tuidPrefix = getTuidPrefixAndSeparator() + getVURIReplacementForCachedRoot(root) - if (!isCached(root)) { - // the root has no resource and therefore it has to be cached for correct Tuid - // resolution and calculation - addRootToCache(root) - LOGGER. - trace('''The given EObject «eObject» has no resource attached. Added it to the Tuid cache using the prefix '«»«tuidPrefix»'.''') - } - - } else { - if (isCached(root)) { - // the root has a resource but was cached before, so it should be removed from the - // cache - removeRootFromCache(root) - } - tuidPrefix = getTuidPrefixAndSeparator() + VURI.getInstance(eObject.eResource()) - } - var EObject virtualRootEObject = root.eContainer() - return calculateTuidFromEObject(eObject, virtualRootEObject, tuidPrefix) - } - - def private String calculateMetaElementTuid(EClass eClass) { - val packages = newArrayList() - var currentPackage = eClass.EPackage; - while (currentPackage !== null) { - packages.add(0, currentPackage); - currentPackage = currentPackage.ESuperPackage - } - // Fold with strings may be rather inefficient, better use StringBuilder or the like - val packagePath = packages.fold("", [accumulatedString, element | accumulatedString + element.name + "." ]) - return Tuid.META_ELEMENT_PREFIX + VitruviusConstants.getTuidSegmentSeperator() + tuidPrefixAndSeparator + packagePath + eClass.name - } - - def private void addRootToCache(EObject root) { - var int key = getCacheKey(root) - this.cachedResourcelessRoots.putClaimingNullOrSameMapped(key, root) - } - - def private boolean isCached(EObject root) { - var int key = getCacheKey(root) - var boolean cached = this.cachedResourcelessRoots.containsKey(key) - LOGGER.debug('''The key '«»«key»' is currently «(if (cached) "" else "not")» in the tuid cache.''') - return cached - } - - override void removeRootFromCache(EObject root) { - var int key = getCacheKey(root) - removeCacheEntryForKey(key) - } - - def private void removeCacheEntryForKey(int key) { - var EObject value = this.cachedResourcelessRoots.remove(key) - this.cachedRoot2KeyMap.remove(value) - LOGGER.debug('''Removed the value '«»«value»'for the key '«»«key»' from the tuid cache.''') - } - - override void removeIfRootAndCached(String tuid) { - var String[] segmentsAfterMarker = getSegmentsAfterCachedTuidMarker(tuid) - var boolean isTuidOfRoot = segmentsAfterMarker !== null && segmentsAfterMarker.length === 1 - if (isTuidOfRoot) { - var Integer key = getCacheKeyForTuidString(tuid) - if (key !== null) { - removeCacheEntryForKey(key) - } - - } - - } - - def private String getVURIReplacementForCachedRoot(EObject root) { - return VitruviusConstants.getCachedTuidMarker() + getCacheKey(root) - } - - def private Integer claimCacheKey(String tuid) { - var Integer key = getCacheKeyForTuidString(tuid) - if (key === null) { - LOGGER.warn(''' TUID «tuid» is not in the cache'''); - return null; - } else { - return key - } - } - - def private Integer getCacheKeyForTuidString(String tuid) { - var String[] segmentsAfterMarker = getSegmentsAfterCachedTuidMarker(tuid) - if (segmentsAfterMarker !== null && segmentsAfterMarker.length > 0) { - var String keyString = segmentsAfterMarker.get(0) - return getCacheKeyForKeySegment(keyString) - } else { - return null - } - } - - def private int getCacheKeyForKeySegment(String keySegment) { - return Integer.parseInt(keySegment) - } - - def private Integer getCacheKey(EObject root) { - var Integer key = this.cachedRoot2KeyMap.get(root) - if (key === null) { - key = getNextCacheKey() - this.cachedResourcelessRoots.putClaimingNullOrSameMapped(key, root) - this.cachedRoot2KeyMap.put(root, key) - } - return key - } - - def private int getNextCacheKey() { - return this.nextCacheKey++ - } - - def private String[] getSegmentsAfterCachedTuidMarker(String tuid) { - var String cachedTuidMarker = VitruviusConstants.getCachedTuidMarker() - var String tuidSuffix = getTuidWithoutDefaultPrefix(tuid) - if (tuidSuffix.startsWith(cachedTuidMarker)) { - var int markerEndIndex = cachedTuidMarker.length() - var String suffixAfterMarker = tuidSuffix.substring(markerEndIndex) - return getSegments(suffixAfterMarker) - } else { - return null - } - } - - def String getTuidPrefixAndSeparator() { - return getTuidPrefix() + VitruviusConstants.getTuidSegmentSeperator() - } - - override String getModelVURIContainingIdentifiedEObject(String extTuid) { - var String tuidSuffix = getTuidWithoutDefaultPrefix(extTuid) - var String[] segments = getSegments(tuidSuffix) - var String firstSegmentOfSuffix = segments.get(0) - if (isCached(firstSegmentOfSuffix)) { - return null - } else { - return firstSegmentOfSuffix - } - } - - def private String[] getSegments(String tuid) { - return tuid.split(VitruviusConstants.getTuidSegmentSeperator()) - } - - def private boolean isCached(String firstSegmentOfSuffix) { - return firstSegmentOfSuffix.startsWith(VitruviusConstants.getCachedTuidMarker()) - } - - override EObject resolveEObjectFromRootAndFullTuid(EObject root_finalParam_, String tuid) { - var root = root_finalParam_ - if (root === null) { - root = claimRootFromCache(tuid) - if (root === null) { - LOGGER.warn('''No EObject found for Tuid: «tuid» in the cache''') - return null; - } - } - var String identifier = getTuidWithoutRootObjectPrefix(root, tuid) - if (identifier === null) { - return null - } - var String[] segments = getSegments(identifier) - if (identifier.length() === 0) { - segments = newArrayOfSize(0) - } - var EObject foundElement = getIdentifiedEObjectWithinRootEObjectInternal(root, segments) - if (foundElement !== null) { - return foundElement - } - LOGGER.warn('''No EObject found for Tuid: «tuid» in root object: «root»''') - return null - } - - def private EObject claimRootFromCache(String tuid) { - var key = claimCacheKey(tuid) - if (key === null) return null; - return this.cachedResourcelessRoots.claimValueForKey(key) - } - - /** - * Removes the root object prefix from the given Tuid and returns the result. - * @param rootThe root object. - * @param extTuidThe Tuid to process. - * @return The Tuid without the root object prefix. - */ - def private String getTuidWithoutRootObjectPrefix(EObject root, String extTuid) { - var String rootTuid = calculateTuidFromEObject(root) - var String normalizedExtTuid = extTuid; - if (root.eResource !== null) { - val uriConverter = root.eResource.resourceSet.URIConverter - rootTuid = rootTuid.getUriNormalizedTuid(uriConverter); - normalizedExtTuid = extTuid.getUriNormalizedTuid(uriConverter); - } - if (!normalizedExtTuid.startsWith(rootTuid)) { - LOGGER.error('''Tuid «normalizedExtTuid» is not in EObject «root»''') - return null - } - var String identifyingTuidPart = normalizedExtTuid.substring(rootTuid.length()) - if (identifyingTuidPart.startsWith(VitruviusConstants.getTuidSegmentSeperator())) { - identifyingTuidPart = identifyingTuidPart.substring(VitruviusConstants.getTuidSegmentSeperator().length()) - } - return identifyingTuidPart - } - - /** - * Normalizes the URI segment of the given {@link Tuid}. It converts pathmap URIs into ordinary platform URIs. - * It also converts the sometimes occurring plugin references via a resource reference (platform:/resource/platform:/resource) - * into an ordinary plugin reference. - * @param tuid the original {@link Tuid} - * @param uriConverter the {@link URIConverter} to normalize the {@link URI} with. - * @return The normalized and simplified {@link URI}. - */ - private static def String getUriNormalizedTuid(String tuid, URIConverter uriConverter) { - val String[] tuidSegments = tuid.split(VitruviusConstants.tuidSegmentSeperator); - if (tuidSegments.length < 2) { - throw new IllegalStateException("Tuid too short"); - } - val uri = uriConverter.normalize(URI.createURI(tuidSegments.get(1).replace("platform:/resource/platform:/plugin", "platform:/plugin"))); - val newTuid = tuid.replace(tuidSegments.get(1), uri.toString); - return newTuid - } - - /** - * Finds the object described by the given IDs in the given root object. - * @param rootThe root object. - * @param idsThe IDs of the object to find. - * @return The found object or null if no such object exists. - */ - def protected abstract EObject getIdentifiedEObjectWithinRootEObjectInternal(EObject root, String[] ids) - - /** - * @param tuidThe Tuid. - * @return The given Tuid without the default part. - */ - def private String getTuidWithoutDefaultPrefix(String tuid) { - if (!isValidTuid(tuid)) { - throw new IllegalArgumentException('''Tuid: «tuid» not generated by class «getTuidPrefix()»''') - } - return tuid.substring(getTuidPrefixAndSeparator().length()) - } - - def private String getTuidPrefix() { - return this.tuidPrefix - } - -} diff --git a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculatorUtilities.java b/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculatorUtilities.java deleted file mode 100644 index 96a4f43102..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidCalculatorUtilities.java +++ /dev/null @@ -1,38 +0,0 @@ -package tools.vitruv.framework.tuid; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; - -/** - * Utility class for Tuid generators. - * - * @author Stephan Seifermann - * - */ -public class TuidCalculatorUtilities { - - /** - * Takes an EObject and a prefix and calculates a generic individual identifier from it. It uses - * the containing feature and the index to make it unique at the parent object. - * - * Attention: This method must NOT be used since during correspondence adding or updating there - * might be issues with overlapping identifiers! - * - * @param obj The object for which the ID shall be calculated. - * @param prefix A prefix, which is prepended. - * @return The individual Tuid. - */ - @SuppressWarnings("unchecked") - @Deprecated - public static String getGenericIndividualIdentifier(EObject obj, String prefix) { - EObject container = obj.eContainer(); - EReference containingFeature = obj.eContainmentFeature(); - String tuidPart = prefix + containingFeature.getName(); - if (containingFeature.getUpperBound() == -1 || containingFeature.getUpperBound() > 1) { - tuidPart += ((EList) container.eGet(containingFeature)).indexOf(obj); - } - return tuidPart; - } - -} diff --git a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidManager.xtend b/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidManager.xtend deleted file mode 100644 index 47f244abe2..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidManager.xtend +++ /dev/null @@ -1,127 +0,0 @@ -package tools.vitruv.framework.tuid - -import java.util.Map -import org.eclipse.emf.ecore.EObject -import java.util.HashMap -import tools.vitruv.framework.util.XtendAssertHelper -import org.apache.log4j.Logger -import java.util.Set - -final class TuidManager { - static val logger = Logger.getLogger(TuidManager); - static val instance = new TuidManager(); - val Set tuidCalculator; - val Set tuidUpdateListener; - val Map tuidUpdateCache = new HashMap(); - - private new() { - this.tuidCalculator = newHashSet(); - this.tuidUpdateListener = newHashSet(); - } - - static def TuidManager getInstance() { - // This class is a singleton for now. We will probably change that decision later - return instance; - } - - def void addTuidUpdateListener(TuidUpdateListener updateListener) { - if (updateListener !== null) { - tuidUpdateListener += updateListener; - } - } - - def removeTuidUpdateListener(TuidUpdateListener updateListener) { - tuidUpdateListener.remove(updateListener); - } - - def void addTuidCalculator(TuidCalculator calculator) { - if (calculator !== null) { - tuidCalculator += calculator; - } - } - - def removeTuidCalculator(TuidCalculator calculator) { - tuidCalculator.remove(calculator); - } - - def reinitialize() { - tuidCalculator.clear() - flushRegisteredObjectsUnderModification() - Tuid.reinitialize() - } - - def private TuidCalculator getTuidCalculator(EObject object) { - var TuidCalculator resultCalculator = null; - for (potentialCalculator : tuidCalculator) { - if (potentialCalculator.canCalculateTuid(object)) { - if (resultCalculator !== null) { - throw new IllegalStateException("There are two Tuid calculators registered that can handle the EObject: " + object + ", which are " + resultCalculator + " and " + potentialCalculator); - } - resultCalculator = potentialCalculator; - } - } - return resultCalculator; - } - - def private boolean hasTuidCalculator(EObject object) { - return object.tuidCalculator !== null; - } - - def private Tuid calculateTuid(EObject object) { - val tuidCalculator = object.tuidCalculator; - if (tuidCalculator !== null) { - return tuidCalculator.calculateTuid(object); - } else { - throw new IllegalArgumentException("No Tuid calculator registered for EObject: " + object); - } - } - - def registerObjectUnderModification(EObject objectUnderModification) { - if (objectUnderModification.hasTuidCalculator && !tuidUpdateCache.containsKey(objectUnderModification)) { - tuidUpdateCache.put(objectUnderModification, objectUnderModification.calculateTuid); - } - } - - def flushRegisteredObjectsUnderModification() { - tuidUpdateCache.clear(); - } - - def updateTuidsOfRegisteredObjects() { - for (object : tuidUpdateCache.keySet) { - val oldTuid = tuidUpdateCache.get(object); - if (hasTuidCalculator(object)) { - val newTuid = object.calculateTuid - val oldTuidString = oldTuid.toString - oldTuid.updateTuid(newTuid); - logger.debug("Changed Tuid from " + oldTuidString + " to " + newTuid); - XtendAssertHelper.assertTrue(oldTuid.equals(newTuid)); - } - } - } - - def updateTuid(EObject oldObject, EObject newObject) { - if (oldObject.hasTuidCalculator && newObject.hasTuidCalculator) { - val oldTuid = oldObject.calculateTuid; - val newTuid = newObject.calculateTuid; - oldTuid.updateTuid(newTuid); - } - } - - def updateTuid(Tuid oldTuid, EObject newObject) { - if (newObject.hasTuidCalculator) { - oldTuid.updateTuid(newObject.calculateTuid); - } - } - - package def notifyListenerBeforeTuidUpdate(Tuid oldTuid) { - for (listener : tuidUpdateListener) { - listener.performPreAction(oldTuid); - } - } - - package def notifyListenerAfterTuidUpdate(Tuid newTuid) { - for (listener : tuidUpdateListener) { - listener.performPostAction(newTuid); - } - } -} \ No newline at end of file diff --git a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidResolver.xtend b/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidResolver.xtend deleted file mode 100644 index 4b052c44c7..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidResolver.xtend +++ /dev/null @@ -1,7 +0,0 @@ -package tools.vitruv.framework.tuid - -import org.eclipse.emf.ecore.EObject - -interface TuidResolver { - def EObject resolveEObjectFromTuid(Tuid tuid); -} \ No newline at end of file diff --git a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidUpdateListener.xtend b/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidUpdateListener.xtend deleted file mode 100644 index 0b3e8a6e34..0000000000 --- a/bundles/framework/tools.vitruv.framework.tuid/src/tools/vitruv/framework/tuid/TuidUpdateListener.xtend +++ /dev/null @@ -1,6 +0,0 @@ -package tools.vitruv.framework.tuid - -interface TuidUpdateListener { - def void performPreAction(Tuid oldTuid) - def void performPostAction(Tuid newTuid) -} \ No newline at end of file diff --git a/bundles/framework/tools.vitruv.framework.util/src/tools/vitruv/framework/util/VitruviusConstants.java b/bundles/framework/tools.vitruv.framework.util/src/tools/vitruv/framework/util/VitruviusConstants.java index fd63ee5a3a..1c2dd873b6 100644 --- a/bundles/framework/tools.vitruv.framework.util/src/tools/vitruv/framework/util/VitruviusConstants.java +++ b/bundles/framework/tools.vitruv.framework.util/src/tools/vitruv/framework/util/VitruviusConstants.java @@ -9,7 +9,6 @@ public class VitruviusConstants { private static final String CORRESPONDENCES_FILE_EXT = "correspondence"; private static final String UUID_FILE_EXT = "uuid"; private static final String DEFAULT_NAME_OF_IDENTIFIER_FEATURE = "id"; - private static final String Tuid_SEGMENT_SEPERATOR = "#"; private static final String DEFAULT_NAME_OF_NAME_FEAUTRE = "entityName"; private static final String FILE_EXT_SEPARATOR = "."; /** @@ -19,8 +18,6 @@ public class VitruviusConstants { private static final String OPTION_PROCESS_DANGLING_HREF = "PROCESS_DANGLING_HREF"; private static final String OPTION_PROCESS_DANGLING_HREF_DISCARD = "DISCARD"; - private static final String CACHED_Tuid_MARKER = "45gBeLT4L9BWQtesOVNdXzAZP4RBPBRdxL8wGJV+jyo="; - /** * @return the name of the executable property of extension points */ @@ -52,10 +49,6 @@ public static String getDefaultNameOfIdentifierFeature() { return DEFAULT_NAME_OF_IDENTIFIER_FEATURE; } - public static String getTuidSegmentSeperator() { - return Tuid_SEGMENT_SEPERATOR; - } - public static String getDefaultNameOfNameFeature() { return DEFAULT_NAME_OF_NAME_FEAUTRE; } @@ -72,10 +65,6 @@ public static String getOptionProcessDanglingHrefDiscard() { return OPTION_PROCESS_DANGLING_HREF_DISCARD; } - public static String getCachedTuidMarker() { - return CACHED_Tuid_MARKER; - } - /** * Returns the name of a file that is placed in every test project as a marker * for the test project. This enables tests to be run independent from Eclipse diff --git a/bundles/framework/tools.vitruv.framework.vsum.ui/src/tools/vitruv/framework/vsum/ui/util/VitruvInstanceCreator.xtend b/bundles/framework/tools.vitruv.framework.vsum.ui/src/tools/vitruv/framework/vsum/ui/util/VitruvInstanceCreator.xtend index c5db0299fd..20a5fb0b63 100644 --- a/bundles/framework/tools.vitruv.framework.vsum.ui/src/tools/vitruv/framework/vsum/ui/util/VitruvInstanceCreator.xtend +++ b/bundles/framework/tools.vitruv.framework.vsum.ui/src/tools/vitruv/framework/vsum/ui/util/VitruvInstanceCreator.xtend @@ -1,6 +1,5 @@ package tools.vitruv.framework.vsum.ui.util -import tools.vitruv.framework.tuid.TuidManager import tools.vitruv.framework.vsum.InternalVirtualModel import tools.vitruv.framework.domains.VitruvDomain import tools.vitruv.framework.applications.VitruvApplication @@ -28,7 +27,6 @@ class VitruvInstanceCreator { } def boolean createVsumProject() { - TuidManager.instance.reinitialize(); val virtualModel = createVirtualModel(name); for (project : projectToDomains.keySet) { for (domain : projectToDomains.get(project)) { diff --git a/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/VirtualModelBuilder.xtend b/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/VirtualModelBuilder.xtend index bdb7098996..7cb9210817 100644 --- a/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/VirtualModelBuilder.xtend +++ b/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/VirtualModelBuilder.xtend @@ -10,7 +10,6 @@ import java.io.File import tools.vitruv.framework.userinteraction.InternalUserInteractor import java.nio.file.Path import tools.vitruv.framework.domains.repository.VitruvDomainRepositoryImpl -import tools.vitruv.framework.domains.TuidAwareVitruvDomain import tools.vitruv.framework.change.processing.ChangePropagationSpecificationRepository import tools.vitruv.framework.userinteraction.InteractionResultProvider import tools.vitruv.framework.userinteraction.UserInteractionFactory @@ -125,9 +124,6 @@ class VirtualModelBuilder { checkState(!domains.isEmpty, "No domains were configured!") domainRepository = new VitruvDomainRepositoryImpl(domains) } - for (tuidDomain : domainRepository.filter(TuidAwareVitruvDomain)) { - tuidDomain.registerAtTuidManagement() - } val changeSpecificationRepository = new ChangePropagationSpecificationRepository(changePropagationSpecifications) for (changePropagationSpecification : changePropagationSpecifications) { checkState(domainRepository.contains(changePropagationSpecification.sourceDomain), diff --git a/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/VirtualModelImpl.xtend b/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/VirtualModelImpl.xtend index 7f50ade98f..3dc66840c3 100644 --- a/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/VirtualModelImpl.xtend +++ b/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/VirtualModelImpl.xtend @@ -22,7 +22,6 @@ import tools.vitruv.framework.vsum.helper.VsumFileSystemLayout import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl import static extension tools.vitruv.framework.util.ResourceSetUtil.withGlobalFactories import static extension tools.vitruv.framework.util.bridges.EcoreResourceBridge.loadOrCreateResource -import tools.vitruv.framework.vsum.repositories.TuidResolverImpl import tools.vitruv.framework.correspondence.CorrespondenceModelFactory import tools.vitruv.framework.correspondence.InternalCorrespondenceModel import java.nio.file.Path @@ -240,7 +239,7 @@ class VirtualModelImpl implements InternalVirtualModel { val correspondencesResource = new ResourceSetImpl().withGlobalFactories().loadOrCreateResource( correspondencesVURI.EMFUri) CorrespondenceModelFactory.instance.createCorrespondenceModel( - new TuidResolverImpl(domainRepository, resourceRepository), uuidGeneratorAndResolver, resourceRepository, - domainRepository, correspondencesVURI, correspondencesResource) + uuidGeneratorAndResolver, resourceRepository, + correspondencesVURI, correspondencesResource) } } diff --git a/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/repositories/ResourceRepositoryImpl.xtend b/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/repositories/ResourceRepositoryImpl.xtend index b6a02350d8..f3311d3bf4 100644 --- a/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/repositories/ResourceRepositoryImpl.xtend +++ b/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/repositories/ResourceRepositoryImpl.xtend @@ -15,7 +15,6 @@ import tools.vitruv.framework.change.description.TransactionalChange import tools.vitruv.framework.change.description.VitruviusChangeFactory import tools.vitruv.framework.domains.VitruvDomain import tools.vitruv.framework.domains.repository.VitruvDomainRepository -import tools.vitruv.framework.tuid.TuidManager import tools.vitruv.framework.util.bridges.EcoreResourceBridge import tools.vitruv.framework.util.datatypes.ModelInstance import tools.vitruv.framework.util.datatypes.VURI @@ -150,15 +149,10 @@ class ResourceRepositoryImpl implements ModelRepository { override void persistAsRoot(EObject rootEObject, VURI vuri) { val ModelInstance modelInstance = getModelInstanceOriginal(vuri) executeAsCommand [ - TuidManager.instance.registerObjectUnderModification(rootEObject) val resource = modelInstance.resource resource.contents += rootEObject resource.modified = true logger.debug('''Create model with resource: «resource»'''.toString) - TuidManager.instance.updateTuidsOfRegisteredObjects() - // Usually we should deregister the object, but since we do not know if it was - // registered before and if the other objects should still be registered - // we cannot remove it or flush the registry ] } diff --git a/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/repositories/TuidResolverImpl.xtend b/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/repositories/TuidResolverImpl.xtend deleted file mode 100644 index 0ad8832901..0000000000 --- a/bundles/framework/tools.vitruv.framework.vsum/src/tools/vitruv/framework/vsum/repositories/TuidResolverImpl.xtend +++ /dev/null @@ -1,70 +0,0 @@ -package tools.vitruv.framework.vsum.repositories - -import org.eclipse.emf.ecore.EObject -import tools.vitruv.framework.tuid.Tuid -import tools.vitruv.framework.domains.repository.VitruvDomainRepository -import tools.vitruv.framework.domains.TuidAwareVitruvDomain -import tools.vitruv.framework.util.datatypes.VURI -import tools.vitruv.framework.util.datatypes.ModelInstance -import org.eclipse.emf.ecore.util.EcoreUtil -import tools.vitruv.framework.vsum.ModelRepository - -class TuidResolverImpl implements tools.vitruv.framework.tuid.TuidResolver{ - val VitruvDomainRepository domainRepository; - val ModelRepository modelRepository; - - new(VitruvDomainRepository domainRepository, ModelRepository modelRepository) { - this.domainRepository = domainRepository; - this.modelRepository = modelRepository; - } - - def private TuidAwareVitruvDomain getMetamodelHavingTuid(Tuid tuid) { - return this.domainRepository.getDomain(tuid) - } - - override EObject resolveEObjectFromTuid(Tuid tuid) { - if (tuid.isMetaElementTuid) { - // Meta element Tuids cannot be resolved - return null; - } - val TuidAwareVitruvDomain domain = getMetamodelHavingTuid(tuid) - var VURI vuri = domain.getModelVURIContainingIdentifiedEObject(tuid) - var ModelInstance modelInstance = null - if (vuri !== null) { - modelInstance = this.modelRepository.getModel(vuri) - } - var EObject resolvedEobject = null - try { - resolvedEobject = resolveEObjectInModelInstance(modelInstance, tuid); - } catch (IllegalArgumentException iae) { - // do nothing - just try the solving again - } - if (null === resolvedEobject && modelInstance !== null) { - // reload the model and try to solve it again - try { - modelInstance.load(true) - } catch (IllegalStateException e) { - throw new IllegalStateException("TUID " + tuid + " cannot be resolved, because the resource " + modelInstance.resource.URI + " cannot be loaded.") - } - resolvedEobject = resolveEObjectInModelInstance(modelInstance, tuid); - if (null === resolvedEobject) { - // if resolved EObject is still null throw an exception - // TODO think about something more lightweight than throwing an exception - throw new RuntimeException('''Could not resolve Tuid «tuid» in eObjects « - »«modelInstance.rootElements» with VURI «vuri»'''.toString) - } - - } - if (null !== resolvedEobject && resolvedEobject.eIsProxy()) { - EcoreUtil::resolve(resolvedEobject, modelInstance.resource) - } - return resolvedEobject - } - - private def EObject resolveEObjectInModelInstance(ModelInstance modelInstance, Tuid tuid) { - val TuidAwareVitruvDomain domain = getMetamodelHavingTuid(tuid) - // if the tuid is cached because it has no resource the rootEObject is null - var rootEObjects = if(modelInstance !== null) modelInstance.rootElements + #[null] else #[null]; - return rootEObjects.map[domain.resolveEObjectFromRootAndFullTuid(it, tuid)].findFirst[it !== null]; - } -} diff --git a/bundles/testutils/tools.vitruv.testutils.domains/META-INF/MANIFEST.MF b/bundles/testutils/tools.vitruv.testutils.domains/META-INF/MANIFEST.MF index 401da07a32..ca8587fa6c 100644 --- a/bundles/testutils/tools.vitruv.testutils.domains/META-INF/MANIFEST.MF +++ b/bundles/testutils/tools.vitruv.testutils.domains/META-INF/MANIFEST.MF @@ -6,6 +6,7 @@ Automatic-Module-Name: tools.vitruv.testutils Bundle-Version: 2.1.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: tools.vitruv.testutils.metamodels;visibility:=reexport, + tools.vitruv.testutils.domains;visibility:=reexport, edu.kit.ipd.sdq.activextendannotations, tools.vitruv.testutils, org.eclipse.xtext.xbase.lib diff --git a/bundles/testutils/tools.vitruv.testutils.domains/src/tools/vitruv/testutils/domains/VitruvTestDomain.xtend b/bundles/testutils/tools.vitruv.testutils.domains/src/tools/vitruv/testutils/domains/VitruvTestDomain.xtend index 4829ef3641..83a42456d6 100644 --- a/bundles/testutils/tools.vitruv.testutils.domains/src/tools/vitruv/testutils/domains/VitruvTestDomain.xtend +++ b/bundles/testutils/tools.vitruv.testutils.domains/src/tools/vitruv/testutils/domains/VitruvTestDomain.xtend @@ -2,16 +2,13 @@ package tools.vitruv.testutils.domains import org.eclipse.emf.ecore.EPackage import org.eclipse.emf.ecore.EAttribute -import tools.vitruv.framework.tuid.AttributeTuidCalculatorAndResolver -import tools.vitruv.framework.domains.AbstractTuidAwareVitruvDomain +import tools.vitruv.framework.domains.AbstractVitruvDomain -package abstract class VitruvTestDomain extends AbstractTuidAwareVitruvDomain { +package abstract class VitruvTestDomain extends AbstractVitruvDomain { new(String name, EPackage metamodelRootPackage, Iterable identifyingAttributes, String... fileExtensions) { - super(name, metamodelRootPackage, - new AttributeTuidCalculatorAndResolver(metamodelRootPackage.nsURI, identifyingAttributes.map[it.name]), - fileExtensions) + super(name, metamodelRootPackage, fileExtensions) } override isUserVisible() { diff --git a/bundles/testutils/tools.vitruv.testutils/META-INF/MANIFEST.MF b/bundles/testutils/tools.vitruv.testutils/META-INF/MANIFEST.MF index 19f63ef383..d86a23f6a0 100644 --- a/bundles/testutils/tools.vitruv.testutils/META-INF/MANIFEST.MF +++ b/bundles/testutils/tools.vitruv.testutils/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: tools.vitruv.framework.vsum;visibility:=reexport, org.apache.log4j, tools.vitruv.framework.change.processing;visibility:=reexport, + tools.vitruv.framework.util, org.eclipse.emf.transaction, org.eclipse.xtend.lib, edu.kit.ipd.sdq.activextendannotations, diff --git a/bundles/testutils/tools.vitruv.testutils/src/tools/vitruv/testutils/TestLogging.xtend b/bundles/testutils/tools.vitruv.testutils/src/tools/vitruv/testutils/TestLogging.xtend index fcf0286278..86b142851a 100644 --- a/bundles/testutils/tools.vitruv.testutils/src/tools/vitruv/testutils/TestLogging.xtend +++ b/bundles/testutils/tools.vitruv.testutils/src/tools/vitruv/testutils/TestLogging.xtend @@ -14,8 +14,6 @@ import static org.apache.log4j.Logger.getRootLogger import static org.slf4j.Logger.ROOT_LOGGER_NAME import static extension org.apache.log4j.Logger.getLogger -import tools.vitruv.framework.tuid.TuidManager -import tools.vitruv.framework.tuid.TuidCalculatorAndResolverBase import tools.vitruv.framework.uuid.UuidGeneratorAndResolverImpl import java.util.List @@ -56,8 +54,6 @@ class TestLogging implements BeforeAllCallback { rootLogger.level = ERROR VITRUV_LOG_ROOTS.forEach [logger.level = toLevel(desiredLogLevel, WARN)] if (System.getProperty(VM_ARGUMENT_ENABLE_ID_LOGGERS) != "true") { - TuidManager.logger.level = ERROR - TuidCalculatorAndResolverBase.logger.level = OFF UuidGeneratorAndResolverImpl.logger.level = ERROR } TestProjectManager.logger.level = INFO diff --git a/bundles/testutils/tools.vitruv.testutils/src/tools/vitruv/testutils/VitruvApplicationTest.xtend b/bundles/testutils/tools.vitruv.testutils/src/tools/vitruv/testutils/VitruvApplicationTest.xtend index c6ca1c944e..064df50524 100644 --- a/bundles/testutils/tools.vitruv.testutils/src/tools/vitruv/testutils/VitruvApplicationTest.xtend +++ b/bundles/testutils/tools.vitruv.testutils/src/tools/vitruv/testutils/VitruvApplicationTest.xtend @@ -7,7 +7,6 @@ import org.junit.jupiter.api.TestInfo import org.junit.jupiter.api.^extension.ExtendWith import tools.vitruv.framework.change.processing.ChangePropagationSpecification import tools.vitruv.framework.correspondence.CorrespondenceModel -import tools.vitruv.framework.tuid.TuidManager import tools.vitruv.framework.vsum.InternalVirtualModel import tools.vitruv.testutils.matchers.CorrespondenceModelContainer @@ -37,7 +36,6 @@ abstract class VitruvApplicationTest implements CorrespondenceModelContainer, Te @BeforeEach def final package void prepareVirtualModelAndView(TestInfo testInfo, @TestProject Path testProjectPath, @TestProject(variant="vsum") Path vsumPath) { - TuidManager.instance.reinitialize() val changePropagationSpecifications = this.changePropagationSpecifications val userInteraction = new TestUserInteraction val targetDomains = new VitruvDomainRepositoryImpl( diff --git a/bundles/testutils/tools.vitruv.testutils/src/tools/vitruv/testutils/domains/ConcreteTuidAwareVitruvDomain.xtend b/bundles/testutils/tools.vitruv.testutils/src/tools/vitruv/testutils/domains/ConcreteTuidAwareVitruvDomain.xtend deleted file mode 100644 index 6defd1f0fd..0000000000 --- a/bundles/testutils/tools.vitruv.testutils/src/tools/vitruv/testutils/domains/ConcreteTuidAwareVitruvDomain.xtend +++ /dev/null @@ -1,19 +0,0 @@ -package tools.vitruv.testutils.domains - -import tools.vitruv.framework.domains.AbstractTuidAwareVitruvDomain -import org.eclipse.emf.ecore.EPackage -import java.util.Set -import tools.vitruv.framework.tuid.TuidCalculatorAndResolver - -class ConcreteTuidAwareVitruvDomain extends AbstractTuidAwareVitruvDomain { - new(String name, EPackage metamodelRootPackage, TuidCalculatorAndResolver tuidCalculator, - String... fileExtensions) { - super(name, metamodelRootPackage, tuidCalculator, fileExtensions) - } - - new(String name, EPackage metamodelRootPackage, Set furtherRootPackages, - TuidCalculatorAndResolver tuidCalculator, String... fileExtensions) { - super(name, metamodelRootPackage, furtherRootPackages, tuidCalculator, fileExtensions) - } - -} diff --git a/features/tools.vitruv.extensions.integration.feature/feature.xml b/features/tools.vitruv.extensions.integration.feature/feature.xml index a54b566759..b9a409ee1c 100644 --- a/features/tools.vitruv.extensions.integration.feature/feature.xml +++ b/features/tools.vitruv.extensions.integration.feature/feature.xml @@ -21,7 +21,6 @@ - - - filesToDelete = new ArrayList<>(); - - @AfterEach - public void cleanupFiles() { - for (File file : this.filesToDelete) { - file.delete(); - } - this.filesToDelete.clear(); - } - - @Test - public void testCreateChildSaveCalcRemoveCalcSaveCalc() throws IOException { - TuidCalculatorAndResolver tuidCAR = prepareTuidCAR(); - - // create - Repository repository = create(); - // child - Component component = Pcm_mockupFactory.eINSTANCE.createComponent(); - repository.getComponents().add(component); - // save - // calc - String uncachedTuidAfterSave = saveAndCalc("", tuidCAR, component, "newtestresource"); - - // remove - remove(component); - // calc - String cachedTuidAfterRemove = calc(tuidCAR, component, uncachedTuidAfterSave, "cachedTuidAfterRemove"); - - // save - // calc - saveAndCalc(cachedTuidAfterRemove, tuidCAR, component, "newtestresource"); - } - - @Test - public void testCreateSaveCalcRemoveCalcSaveCalc() throws IOException { - TuidCalculatorAndResolver tuidCAR = prepareTuidCAR(); - - // create - Repository repository = create(); - // save - // calc - String uncachedTuidAfterSave = saveAndCalc("", tuidCAR, repository, "newtestresource"); - - // remove - remove(repository); - // calc - String cachedTuidAfterRemove = calc(tuidCAR, repository, uncachedTuidAfterSave, "cachedTuidAfterRemove"); - - // save - // calc - saveAndCalc(cachedTuidAfterRemove, tuidCAR, repository, "newtestresource"); - } - - @Test - public void testCreateCalcSaveCalcRemoveCalcSaveCalc() throws IOException { - TuidCalculatorAndResolver tuidCAR = prepareTuidCAR(); - - // create - Repository repository = create(); - // calc - String cachedTuidBeforeSave = calc(tuidCAR, repository, "", "cachedTuidAfterRemove"); - // save - // calc - String uncachedTuidAfterSave = saveAndCalc(cachedTuidBeforeSave, tuidCAR, repository, "newtestresource"); - - // remove - remove(repository); - // calc - String cachedTuidAfterRemove = calc(tuidCAR, repository, uncachedTuidAfterSave, "cachedTuidAfterRemove"); - - // save - // calc - saveAndCalc(cachedTuidAfterRemove, tuidCAR, repository, "newtestresource"); - } - - @Test - public void testCreateSaveRemoveCalcSaveCalc() throws IOException { - TuidCalculatorAndResolver tuidCAR = prepareTuidCAR(); - - // create - Repository repository = create(); - // save - save(repository, "newtestresource"); - - // remove - remove(repository); - // calc - String cachedTuidAfterRemove = calc(tuidCAR, repository, "", "cachedTuidAfterRemove"); - - // save - // calc - saveAndCalc(cachedTuidAfterRemove, tuidCAR, repository, "newtestresource"); - } - - @Test - public void testCreateCalcSaveRemoveCalcSaveCalc() throws IOException { - TuidCalculatorAndResolver tuidCAR = prepareTuidCAR(); - - // create - Repository repository = create(); - // calc - String cachedTuidBeforeSave = calc(tuidCAR, repository, "", "cachedTuidAfterRemove"); - // save - save(repository, "newtestresource"); - - // remove - remove(repository); - // calc - String cachedTuidAfterRemove = calc(tuidCAR, repository, cachedTuidBeforeSave, "cachedTuidAfterRemove", true); - - // save - // calc - saveAndCalc(cachedTuidAfterRemove, tuidCAR, repository, "newtestresource"); - } - - private String calc(final TuidCalculatorAndResolver tuidCAR, final EObject eObject, final String oldTuid, - final String msg) { - return calc(tuidCAR, eObject, oldTuid, msg, false); - } - - private String calc(final TuidCalculatorAndResolver tuidCAR, final EObject eObject, final String oldTuid, - final String msg, final boolean equalTuid) { - String newTuid = tuidCAR.calculateTuidFromEObject(eObject); - traceAndAssert(oldTuid, newTuid, msg, equalTuid); - return newTuid; - } - - private void remove(final EObject eObject) { - EcoreUtil.remove(eObject); - } - - private String saveAndCalc(final String oldTuid, final TuidCalculatorAndResolver tuidCAR, final EObject eObject, - final String fileName) throws IOException { - String uncachedTuidAfterSave = saveAndCalculateTuid(eObject, tuidCAR, fileName); - traceAndAssert(oldTuid, uncachedTuidAfterSave, "uncachedTuidAfterSave", false); - return uncachedTuidAfterSave; - } - - private Repository create() { - Repository repository = Pcm_mockupFactory.eINSTANCE.createRepository(); - return repository; - } - - private TuidCalculatorAndResolver prepareTuidCAR() { - EcoreResourceBridge.registerGlobalMetamodelPackage(Pcm_mockupPackage.eNS_URI, Pcm_mockupPackage.eINSTANCE); - EcoreResourceBridge.registerDefaultXMIExtensionFactory("pcm_mockup"); - TuidCalculatorAndResolver tuidCAR = new AttributeTuidCalculatorAndResolver(Pcm_mockupPackage.eNS_URI, "id"); - return tuidCAR; - } - - private void traceAndAssert(final String oldTuid, final String newTuid, final String msg, final boolean equalTuid) { - LOGGER.trace(msg + ": '" + newTuid + "'"); - if (equalTuid) { - assertEquals(oldTuid, newTuid); - } else { - assertNotEquals(oldTuid, newTuid); - } - } - - private String saveAndCalculateTuid(final EObject eObject, final TuidCalculatorAndResolver tuidCAR, - final String fileName) throws IOException { - save(eObject, fileName); - return tuidCAR.calculateTuidFromEObject(eObject); - } - - private void save(final EObject eObject, final String fileName) throws IOException { - URI uri = URI.createFileURI(SystemUtils.getJavaIoTmpDir().getAbsolutePath() + "/" + fileName + ".pcm_mockup"); - ResourceSetImpl resourceSet = new ResourceSetImpl(); - Resource resource = URIUtil.loadResourceAtURI(uri, resourceSet); - EObject root = EcoreUtil.getRootContainer(eObject); - EcoreResourceBridge.saveEObjectAsOnlyContent(root, resource); - } -} diff --git a/tests/framework/tools.vitruv.framework.vsum.tests/src/tools/vitruv/framework/tests/vsum/VsumTest.java b/tests/framework/tools.vitruv.framework.vsum.tests/src/tools/vitruv/framework/tests/vsum/VsumTest.java index 6e4a37e406..ea7399c30b 100644 --- a/tests/framework/tools.vitruv.framework.vsum.tests/src/tools/vitruv/framework/tests/vsum/VsumTest.java +++ b/tests/framework/tools.vitruv.framework.vsum.tests/src/tools/vitruv/framework/tests/vsum/VsumTest.java @@ -14,8 +14,8 @@ import pcm_mockup.Pcm_mockupFactory; import pcm_mockup.Pcm_mockupPackage; import pcm_mockup.Repository; +import tools.vitruv.framework.domains.AbstractVitruvDomain; import tools.vitruv.framework.domains.VitruvDomain; -import tools.vitruv.framework.tuid.AttributeTuidCalculatorAndResolver; import tools.vitruv.framework.userinteraction.UserInteractionFactory; import tools.vitruv.framework.util.bridges.EMFBridge; import tools.vitruv.framework.util.datatypes.ModelInstance; @@ -26,7 +26,6 @@ import tools.vitruv.testutils.TestLogging; import tools.vitruv.testutils.TestProject; import tools.vitruv.testutils.TestProjectManager; -import tools.vitruv.testutils.domains.ConcreteTuidAwareVitruvDomain; import uml_mockup.UClass; import uml_mockup.UPackage; import uml_mockup.Uml_mockupFactory; @@ -49,11 +48,11 @@ void acquireTestProjectFolder(@TestProject final Path testProjectFolder) { this.testProjectFolder = testProjectFolder; } - private static final VitruvDomain UmlDomain = new ConcreteTuidAwareVitruvDomain("UML", Uml_mockupPackage.eINSTANCE, - new AttributeTuidCalculatorAndResolver(Uml_mockupPackage.eINSTANCE.getNsURI(), "id"), UML_FILE_EXT); + private static final VitruvDomain UmlDomain = new AbstractVitruvDomain("UML", Uml_mockupPackage.eINSTANCE, + UML_FILE_EXT) {}; - private static final VitruvDomain PcmDomain = new ConcreteTuidAwareVitruvDomain("PCM", Pcm_mockupPackage.eINSTANCE, - new AttributeTuidCalculatorAndResolver(Pcm_mockupPackage.eINSTANCE.getNsURI(), "id"), PCM_FILE_EXT); + private static final VitruvDomain PcmDomain = new AbstractVitruvDomain("PCM", Pcm_mockupPackage.eINSTANCE, + PCM_FILE_EXT) {}; protected Path getCurrentProjectFolder() { return this.testProjectFolder;