From 9196a5f903e3eba27e8cb428f0de0481b37f30cd Mon Sep 17 00:00:00 2001
From: alaskowski <alaskowski@ethz.ch>
Date: Tue, 25 Jul 2023 12:44:52 +0200
Subject: [PATCH] SSDM-55: changed back the name of method from setStringValue
 to setValue

---
 .../application/ManagedPropertySection.java   |  4 +-
 .../ManagedPropertyGridActionDialog.java      |  2 +-
 .../dataaccess/EntityPropertiesConverter.java | 42 +------------------
 .../basic/dto/ManagedEntityProperty.java      |  2 +-
 .../shared/basic/dto/ManagedProperty.java     | 21 +++++++---
 .../basic/dto/api/IManagedProperty.java       |  4 +-
 .../JsonStructuredPropertyConverter.java      |  4 +-
 .../XmlStructuredPropertyConverter.java       |  4 +-
 8 files changed, 27 insertions(+), 56 deletions(-)

diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ManagedPropertySection.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ManagedPropertySection.java
index 338bea86a6f..e46696ad718 100644
--- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ManagedPropertySection.java
+++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ManagedPropertySection.java
@@ -262,7 +262,7 @@ public class ManagedPropertySection extends DisposableTabContent
             return null; // make eclipse happy
         } else
         {
-            final String value = StringEscapeUtils.unescapeHtml(managedProperty.getValue());
+            final String value = StringEscapeUtils.unescapeHtml((String)managedProperty.getValue());
             // if there is a script error than value will contain error message
             if (value.startsWith(BasicConstant.ERROR_PROPERTY_PREFIX)
                     && (value.equals(BasicConstant.MANAGED_PROPERTY_PLACEHOLDER_VALUE) == false))
@@ -306,7 +306,7 @@ public class ManagedPropertySection extends DisposableTabContent
             return null; // make eclipse happy
         } else
         {
-            final String value = StringEscapeUtils.unescapeHtml(managedProperty.getValue());
+            final String value = StringEscapeUtils.unescapeHtml((String)managedProperty.getValue());
             // if there is a script error than value will contain error message
             if (value.startsWith(BasicConstant.ERROR_PROPERTY_PREFIX)
                     && (value.equals(BasicConstant.MANAGED_PROPERTY_PLACEHOLDER_VALUE) == false))
diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGridActionDialog.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGridActionDialog.java
index e2887e2d618..a5627340d91 100644
--- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGridActionDialog.java
+++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGridActionDialog.java
@@ -121,7 +121,7 @@ public final class ManagedPropertyGridActionDialog extends
             inputDescription.setValue(value);
         }
         // old value was escaped going to the client - unescape it before sending back to the server
-        managedProperty.setValue(StringEscapeUtils.unescapeHtml(managedProperty.getValue()));
+        managedProperty.setValue(StringEscapeUtils.unescapeHtml((String)managedProperty.getValue()));
         viewContext.getService().updateManagedProperty(TechId.create(entity),
                 entity.getEntityKind(), managedProperty, managedAction, callback);
     }
diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/EntityPropertiesConverter.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/EntityPropertiesConverter.java
index ad4af19015b..ec185b0ef49 100644
--- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/EntityPropertiesConverter.java
+++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/EntityPropertiesConverter.java
@@ -71,8 +71,6 @@ import ch.systemsx.cisd.openbis.generic.shared.translator.PersonTranslator;
 public final class EntityPropertiesConverter implements IEntityPropertiesConverter
 {
 
-    private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION,
-            EntityPropertiesConverter.class);
     private static final IKeyExtractor<PropertyTypePE, ExtendedEntityTypePropertyType>
             EXTENDED_ETPT_KEY_EXTRACTOR =
             new IKeyExtractor<PropertyTypePE, ExtendedEntityTypePropertyType>()
@@ -268,7 +266,6 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
             final PersonPE registrator,
             final EntityTypePE entityTypePE, final IEntityProperty property)
     {
-        operationLog.info("||> tryConvertProperty START");
         final String propertyCode = property.getPropertyType().getCode();
         final PropertyTypePE propertyType = getPropertyType(propertyCode);
         final String valueOrNull = property.tryGetAsString();
@@ -281,8 +278,6 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
         {
             throw UserFailureException.fromTemplate(NO_ENTITY_PROPERTY_VALUE_FOR_S, propertyCode);
         }
-        operationLog.info("||> tryConvertProperty " + propertyCode + " " +
-                propertyType + " val:|" + valueOrNull + "| isBlank:" + isNullOrBlank(valueOrNull));
         if (isNullOrBlank(valueOrNull) == false)
         {
             List<T> results = new ArrayList<>();
@@ -290,12 +285,8 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
 
             final String validatedValue =
                     propertyValueValidator.validatePropertyValue(propertyType, translatedValue);
-            operationLog.info("||> tryConvertProperty translated:" + translatedValue + " validated:"+validatedValue);
             results.addAll(createEntityProperty(registrator, propertyType, entityTypePropertyTypePE,
                     validatedValue));
-            operationLog.info("||> tryConvertProperty POST1");
-            results.forEach(operationLog::info);
-            operationLog.info("||> tryConvertProperty POST2");
             return results;
         }
         return null;
@@ -308,18 +299,15 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
     {
         List<T> entityProperties = new ArrayList<>();
         String val = value;
-        operationLog.info("||> createEntityProperty=" + val + " " + propertyType.isMultiValue() + " " + propertyType);
         if (propertyType.isMultiValue())
         {
             if (val.startsWith("["))
             {
-                operationLog.info("||> createEntityProperty array:" + val);
                 val = val.substring(1, val.length() - 1);
             }
             for (String v : val.split(","))
             {
                 String singleValue = v.trim();
-                operationLog.info("||> createEntityProperty single=" + singleValue);
                 final T entityProperty = getEntityPropertyBase(registrator, entityTypePropertyType);
                 setPropertyValue(entityProperty, propertyType, singleValue);
                 entityProperties.add(entityProperty);
@@ -328,12 +316,8 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
         {
             final T entityProperty = getEntityPropertyBase(registrator, entityTypePropertyType);
             setPropertyValue(entityProperty, propertyType, val);
-            operationLog.info("||> createEntityProperty single:" + entityProperty);
             entityProperties.add(entityProperty);
         }
-        operationLog.info("||> createEntityProperty POST1");
-        entityProperties.forEach(operationLog::info);
-        operationLog.info("||> createEntityProperty POST2");
         return entityProperties;
     }
 
@@ -356,8 +340,6 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
             final IEntityProperty[] properties, final String entityTypeCode,
             final PersonPE registrator)
     {
-        operationLog.info("||> convertProperties" + Arrays.toString(properties));
-        System.out.println("|||> convertProperties" + Arrays.toString(properties));
         return convertProperties(properties, entityTypeCode, registrator, true, true);
     }
 
@@ -372,30 +354,19 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
         final EntityTypePE entityTypePE = getEntityType(entityTypeCode);
         Set<String> dynamicProperties = getDynamicProperties(entityTypePE);
         Set<String> managedProperties = getManagedProperties(entityTypePE);
-        operationLog.info("||> convertProperties dynamicProperties");
-        dynamicProperties.forEach(operationLog::info);
-        operationLog.info("||> convertProperties managedProperties");
-        managedProperties.forEach(operationLog::info);
         Set<IEntityProperty> definedProperties =
                 new LinkedHashSet<IEntityProperty>(Arrays.asList(properties));
-        operationLog.info("||> convertProperties definedProps1");
-        definedProperties.forEach(operationLog::info);
         if (createDynamicPropertiesPlaceholders)
         {
             placeholderCreator.addDynamicPropertiesPlaceholders(definedProperties,
                     dynamicProperties);
-            operationLog.info("||> convertProperties definedProps2");
-            definedProperties.forEach(operationLog::info);
         }
         if (createManagedPropertiesPlaceholders)
         {
             placeholderCreator.addManagedPropertiesPlaceholders(definedProperties,
                     managedProperties);
-            operationLog.info("||> convertProperties definedProps3");
-            definedProperties.forEach(operationLog::info);
         }
         final List<T> list = new ArrayList<T>();
-        operationLog.info("||> convertProperties PRE");
         for (final IEntityProperty property : definedProperties)
         {
             final List<T> convertedPropertyOrNull =
@@ -405,9 +376,6 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
                 list.addAll(convertedPropertyOrNull);
             }
         }
-        operationLog.info("||> convertProperties POST");
-        list.forEach(l -> operationLog.info("||> "+l));
-        list.forEach(l -> System.out.println("|||> "+l));
         return list;
     }
 
@@ -666,7 +634,7 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
         T existingProperty = tryFind(oldProperties, managedProperty.getPropertyTypeCode());
         if (existingProperty != null)
         {
-            existingProperty.setUntypedValue(managedProperty.getValue(), null, null, null,
+            existingProperty.setUntypedValue((String) managedProperty.getValue(), null, null, null,
                     null,
                     null, null, null, null);
             existingProperty.setAuthor(author);
@@ -687,12 +655,6 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
             EntityTypePE entityType, List<IEntityProperty> newProperties, PersonPE author,
             Set<String> propertiesToUpdate)
     {
-        operationLog.info("||> updateProperties " + entityType + " " + entityType + " ");
-        propertiesToUpdate.forEach(l -> operationLog.info("||> "+l));
-        newProperties.forEach(l -> operationLog.info("||> "+l));
-
-        propertiesToUpdate.forEach(l -> System.out.println("|||> "+l));
-        newProperties.forEach(l -> System.out.println("|||> "+l));
         // all new properties should be among propertiesToUpdate (no need to check it)
         final Set<T> set = updateProperties(oldProperties, entityType, newProperties, author);
         // add old properties that are not among propertiesToUpdate (preserve those properties)
@@ -816,7 +778,7 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
                 }
 
                 evaluator.updateFromRegistrationForm(managedProperty, person, bindingsList);
-                return managedProperty.getValue();
+                return (String) managedProperty.getValue();
             } catch (Exception ex)
             {
                 throw CheckedExceptionTunnel.wrapIfNecessary(ex);
diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedEntityProperty.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedEntityProperty.java
index 3cb749fa1f3..3c5278c2da4 100644
--- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedEntityProperty.java
+++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedEntityProperty.java
@@ -150,7 +150,7 @@ public class ManagedEntityProperty implements IEntityProperty, IManagedProperty
     }
 
     @Override
-    public String getValue()
+    public String getStringValue()
     {
         return (String) entityProperty.getValue();
     }
diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedProperty.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedProperty.java
index 817292dacf2..8888e008694 100644
--- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedProperty.java
+++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedProperty.java
@@ -19,6 +19,8 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedProperty;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedUiDescription;
 
+import java.io.Serializable;
+
 /**
  * A holder of information specific to a managed property value.
  * 
@@ -29,16 +31,23 @@ public class ManagedProperty implements IManagedProperty
 
     private static final long serialVersionUID = ServiceVersionHolder.VERSION;
 
-    public static boolean isSpecialValue(String valueOrNull)
+    public static boolean isSpecialValue(Serializable valueOrNull)
     {
-        return valueOrNull != null
-                && (valueOrNull.startsWith(BasicConstant.ERROR_PROPERTY_PREFIX) || valueOrNull
+        if(valueOrNull != null) {
+            if(valueOrNull.getClass().isArray()) {
+                return false;
+            } else {
+                String value = valueOrNull.toString();
+                return (value.startsWith(BasicConstant.ERROR_PROPERTY_PREFIX) || value
                         .equals(BasicConstant.MANAGED_PROPERTY_PLACEHOLDER_VALUE));
+            }
+        }
+        return false;
     }
 
     // NOTE: defaults are set for testing - scripts should override them
 
-    private String value = BasicConstant.MANAGED_PROPERTY_PLACEHOLDER_VALUE;
+    private Serializable value = BasicConstant.MANAGED_PROPERTY_PLACEHOLDER_VALUE;
 
     private String propertyTypeCode = null;
 
@@ -80,7 +89,7 @@ public class ManagedProperty implements IManagedProperty
     }
 
     @Override
-    public String getValue()
+    public Serializable getValue()
     {
         return value;
     }
@@ -92,7 +101,7 @@ public class ManagedProperty implements IManagedProperty
     }
 
     @Override
-    public void setValue(String value)
+    public void setValue(Serializable value)
     {
         this.value = value;
     }
diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedProperty.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedProperty.java
index 4eb1471340b..f4867dfd529 100644
--- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedProperty.java
+++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedProperty.java
@@ -43,10 +43,10 @@ public interface IManagedProperty extends Serializable
     boolean isSpecialValue();
 
     /** Returns the current value of the property. */
-    String getValue();
+    Serializable getValue();
 
     /** Set the value of the property. */
-    void setValue(String value);
+    void setValue(Serializable value);
 
     /**
      * Return an object which allows to manage data for the user interface (input as well as output).
diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/JsonStructuredPropertyConverter.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/JsonStructuredPropertyConverter.java
index 2b15d8acf04..41813afd8c5 100644
--- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/JsonStructuredPropertyConverter.java
+++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/JsonStructuredPropertyConverter.java
@@ -127,7 +127,7 @@ public class JsonStructuredPropertyConverter implements IStructuredPropertyConve
 
     public boolean canHandle(IManagedProperty property)
     {
-        return canHandle(property.getValue());
+        return canHandle((String)property.getValue());
     }
 
     public boolean canHandle(String string)
@@ -138,7 +138,7 @@ public class JsonStructuredPropertyConverter implements IStructuredPropertyConve
     @Override
     public List<IElement> convertToElements(IManagedProperty property)
     {
-        return convertStringToElements(property.getValue());
+        return convertStringToElements((String)property.getValue());
     }
 
     @Override
diff --git a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/XmlStructuredPropertyConverter.java b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/XmlStructuredPropertyConverter.java
index c8e8e17d01f..3b38341de66 100644
--- a/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/XmlStructuredPropertyConverter.java
+++ b/server-application-server/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/XmlStructuredPropertyConverter.java
@@ -61,7 +61,7 @@ public class XmlStructuredPropertyConverter implements IStructuredPropertyConver
 
     public boolean canHandle(IManagedProperty property)
     {
-        return canHandle(property.getValue());
+        return canHandle((String)property.getValue());
     }
 
     public boolean canHandle(String string)
@@ -73,7 +73,7 @@ public class XmlStructuredPropertyConverter implements IStructuredPropertyConver
     @Override
     public List<IElement> convertToElements(IManagedProperty property)
     {
-        return convertStringToElements(property.getValue());
+        return convertStringToElements((String)property.getValue());
     }
 
     @Override
-- 
GitLab