Skip to content
Snippets Groups Projects
Commit a9bc3726 authored by cramakri's avatar cramakri
Browse files

LMS-1949 Fixed order of execution of translation to managed entity property.

SVN: 19462
parent f696f7cd
No related branches found
No related tags found
No related merge requests found
...@@ -42,24 +42,40 @@ public final class EntityPropertyTranslator ...@@ -42,24 +42,40 @@ public final class EntityPropertyTranslator
public final static IEntityProperty translate(final EntityPropertyPE propertyPE, public final static IEntityProperty translate(final EntityPropertyPE propertyPE,
Map<PropertyTypePE, PropertyType> cacheOrNull) Map<PropertyTypePE, PropertyType> cacheOrNull)
{ {
final IEntityProperty result = PropertyTranslatorUtils.createEntityProperty(propertyPE); final IEntityProperty basicProperty =
result.setPropertyType(PropertyTypeTranslator.translate(propertyPE PropertyTranslatorUtils.createEntityProperty(propertyPE);
.getEntityTypePropertyType().getPropertyType(), cacheOrNull)); final PropertyType propertyType =
result.setOrdinal(propertyPE.getEntityTypePropertyType().getOrdinal()); PropertyTypeTranslator.translate(propertyPE.getEntityTypePropertyType()
.getPropertyType(), cacheOrNull);
final Long ordinal = propertyPE.getEntityTypePropertyType().getOrdinal();
PropertyTranslatorUtils.initializeEntityProperty(basicProperty, propertyType, ordinal);
final DataTypeCode typeCode = PropertyTranslatorUtils.getDataTypeCode(propertyPE); final DataTypeCode typeCode = PropertyTranslatorUtils.getDataTypeCode(propertyPE);
switch (typeCode) switch (typeCode)
{ {
case CONTROLLEDVOCABULARY: case CONTROLLEDVOCABULARY:
result.setVocabularyTerm(VocabularyTermTranslator.translate(propertyPE basicProperty.setVocabularyTerm(VocabularyTermTranslator.translate(propertyPE
.getVocabularyTerm())); .getVocabularyTerm()));
break; break;
case MATERIAL: case MATERIAL:
result.setMaterial(MaterialTranslator.translate(propertyPE.getMaterialValue(), basicProperty.setMaterial(MaterialTranslator.translate(
false)); propertyPE.getMaterialValue(), false));
break; break;
default: default:
result.setValue(propertyPE.tryGetUntypedValue()); basicProperty.setValue(propertyPE.tryGetUntypedValue());
}
final IEntityProperty result;
if (propertyPE.getEntityTypePropertyType().isManaged())
{
result = PropertyTranslatorUtils.createManagedEntityProperty(propertyPE, basicProperty);
PropertyTranslatorUtils.initializeEntityProperty(result, propertyType, ordinal);
} else
{
result = basicProperty;
} }
return result; return result;
} }
......
...@@ -21,6 +21,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.GenericEntityProperty; ...@@ -21,6 +21,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.GenericEntityProperty;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ManagedEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ManagedEntityProperty;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialEntityProperty;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ScriptType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ScriptType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTermEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTermEntityProperty;
import ch.systemsx.cisd.openbis.generic.shared.dto.EntityPropertyPE; import ch.systemsx.cisd.openbis.generic.shared.dto.EntityPropertyPE;
...@@ -63,19 +64,13 @@ final class PropertyTranslatorUtils ...@@ -63,19 +64,13 @@ final class PropertyTranslatorUtils
{ {
final DataTypeCode typeCode = PropertyTranslatorUtils.getDataTypeCode(propertyPE); final DataTypeCode typeCode = PropertyTranslatorUtils.getDataTypeCode(propertyPE);
final IEntityProperty basicProperty = createEntityProperty(typeCode); final IEntityProperty basicProperty = createEntityProperty(typeCode);
if (propertyPE.getEntityTypePropertyType().isManaged()) return basicProperty;
{
return createManagedEntityProperty(propertyPE, basicProperty);
} else
{
return basicProperty;
}
} }
/** /**
* Creates a managed {@link IEntityProperty} wrapping given <var>basicProperty</var>. * Creates a managed {@link IEntityProperty} wrapping given <var>basicProperty</var>.
*/ */
private static IEntityProperty createManagedEntityProperty(EntityPropertyPE property, static IEntityProperty createManagedEntityProperty(EntityPropertyPE property,
IEntityProperty basicProperty) IEntityProperty basicProperty)
{ {
final ScriptPE script = property.getEntityTypePropertyType().getScript(); final ScriptPE script = property.getEntityTypePropertyType().getScript();
...@@ -87,6 +82,13 @@ final class PropertyTranslatorUtils ...@@ -87,6 +82,13 @@ final class PropertyTranslatorUtils
return result; return result;
} }
static void initializeEntityProperty(IEntityProperty property, PropertyType propertyType,
Long ordinal)
{
property.setPropertyType(propertyType);
property.setOrdinal(ordinal);
}
/** /**
* Creates an appropriate {@link IEntityProperty} for the given <var>dataTypeCode</var>. * Creates an appropriate {@link IEntityProperty} for the given <var>dataTypeCode</var>.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment