in core/src/main/java/com/jetbrains/youtrackdb/internal/core/record/impl/EntityImpl.java [3620:3725]
public void checkAllMultiValuesAreTrackedVersions() {
checkForBinding();
if (properties == null) {
return;
}
propertyConversionInProgress = true;
try {
for (var propertyEntry : properties.entrySet()) {
var entry = propertyEntry.getValue();
final var propertyValue = entry.value;
if (propertyValue instanceof LinkBag) {
if (isEmbedded()) {
throw new DatabaseException(session.getDatabaseName(),
"RidBag are supported only at entity root");
}
((LinkBag) propertyValue).checkAndConvert();
}
if (!(propertyValue instanceof Collection<?>)
&& !(propertyValue instanceof Map<?, ?>)
&& !(propertyValue instanceof EntityImpl)) {
continue;
}
if (propertyValue instanceof EntityImpl && ((EntityImpl) propertyValue).isEmbedded()) {
((EntityImpl) propertyValue).checkAllMultiValuesAreTrackedVersions();
continue;
}
var propertyType = entry.type;
if (propertyType == null) {
SchemaClass clazz = getImmutableSchemaClass(session);
if (clazz != null) {
final var prop = clazz.getProperty(propertyEntry.getKey());
propertyType =
prop != null ? PropertyTypeInternal.convertFromPublicType(prop.getType()) : null;
}
}
if (propertyType == null) {
propertyType = PropertyTypeInternal.getTypeByValue(propertyValue);
}
switch (propertyType) {
case EMBEDDEDLIST:
if (propertyValue instanceof List<?>
&& !(propertyValue instanceof EntityEmbeddedListImpl<?>)) {
throw new DatabaseException(session.getDatabaseName(),
"Property " + propertyEntry.getKey() + " is supposed to be TrackedList but is "
+ propertyValue.getClass());
}
break;
case EMBEDDEDSET:
if (propertyValue instanceof Set<?>
&& !(propertyValue instanceof EntityEmbeddedSetImpl<?>)) {
throw new DatabaseException(session.getDatabaseName(),
"Property " + propertyEntry.getKey() + " is supposed to be TrackedSet but is "
+ propertyValue.getClass());
}
break;
case EMBEDDEDMAP:
if (propertyValue instanceof Map<?, ?>
&& !(propertyValue instanceof EntityEmbeddedMapImpl)) {
throw new DatabaseException(session.getDatabaseName(),
"Property " + propertyEntry.getKey() + " is supposed to be TrackedMap but is "
+ propertyValue.getClass());
}
break;
case LINKLIST:
if (propertyValue instanceof List<?>
&& !(propertyValue instanceof EntityLinkListImpl)) {
throw new DatabaseException(session.getDatabaseName(),
"Property " + propertyEntry.getKey() + " is supposed to be LinkList but is "
+ propertyValue.getClass());
}
break;
case LINKSET:
if (propertyValue instanceof Set<?> && !(propertyValue instanceof EntityLinkSetImpl)) {
throw new DatabaseException(session.getDatabaseName(),
"Property " + propertyEntry.getKey() + " is supposed to be LinkSet but is "
+ propertyValue.getClass());
}
break;
case LINKMAP:
if (propertyValue instanceof Map<?, ?>
&& !(propertyValue instanceof EntityLinkMapIml)) {
throw new DatabaseException(session.getDatabaseName(),
"Property " + propertyEntry.getKey() + " is supposed to be LinkMap but is "
+ propertyValue.getClass());
}
break;
case LINKBAG:
if (!(propertyValue instanceof LinkBag)) {
throw new DatabaseException(session.getDatabaseName(),
"Property " + propertyEntry.getKey() + " is supposed to be RidBag but is "
+ propertyValue.getClass());
}
break;
default:
break;
}
}
} finally {
propertyConversionInProgress = false;
}
}