Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix PrimitiveTypes Issue #83

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.apache.log4j.Logger;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
Expand All @@ -25,6 +26,7 @@
import com.google.common.collect.HashBiMap;

import tools.vitruv.change.atomic.hid.HierarchicalId;
import tools.vitruv.change.atomic.hid.ObjectResolutionUtil;
import tools.vitruv.change.atomic.hid.internal.HierarchicalIdResolver;

class UuidResolverImpl implements UuidResolver {
Expand Down Expand Up @@ -79,12 +81,13 @@ public void registerEObject(Uuid uuid, EObject eObject) throws IllegalStateExcep
}
eObjectToUuid.put(eObject, uuid);
}

@Override
public void unregisterEObject(Uuid uuid, EObject eObject) throws IllegalStateException {
checkState(uuid != null, "uuid must not be null");
checkState(eObject != null, "object must not be null");
checkState(uuid.equals(eObjectToUuid.get(eObject)), "trying to unregister element %s but is not registered for uuid %s", eObject, uuid);
checkState(uuid.equals(eObjectToUuid.get(eObject)),
"trying to unregister element %s but is not registered for uuid %s", eObject, uuid);
eObjectToUuid.remove(eObject);
}

Expand All @@ -108,7 +111,8 @@ public void endTransaction() {
while (iterator.hasNext()) {
EObject object = iterator.next();
checkState(object.eResource() != null, "dangling object %s detected", object);
checkState(object.eResource().getResourceSet() == resourceSet, "object %s is contained in wrong resource set", object);
checkState(object.eResource().getResourceSet() == resourceSet,
"object %s is contained in wrong resource set", object);
}
}

Expand Down Expand Up @@ -177,6 +181,16 @@ private Uuid getUuidOrNull(EObject eObject) {
}

private Uuid getUuidForReadOnlyEObject(EObject eObject) {
URI proxyURI = ((InternalEObject) eObject).eProxyURI();
Resource resource = eObject.eResource();

if (proxyURI == null && resource != null) {
URI uri = resource.getURI();
String uriFragment = ObjectResolutionUtil.getHierarchicUriFragment(eObject);
uri = uri == null ? URI.createURI("#" + uriFragment) : uri.appendFragment(uriFragment);
return new Uuid(uri.toString());
}

return new Uuid(EcoreUtil.getURI(eObject).toString());
}

Expand Down