From 927880746b8a8bec1ca966b1dd265591f7437029 Mon Sep 17 00:00:00 2001 From: cramakri <cramakri> Date: Mon, 22 Aug 2011 12:48:22 +0000 Subject: [PATCH] LMS-2474 Work on adding varchar managed properties in their own page. SVN: 22580 --- ...ManagedMultilineTextWidgetDescription.java | 56 +++++++++++++++++++ .../basic/dto/ManagedUiDescription.java | 8 +++ .../basic/dto/api/IManagedUiDescription.java | 5 ++ .../dto/api/ManagedOutputWidgetType.java | 2 +- .../ManagedPropertyEvaluator.java | 6 +- .../translator/PropertyTranslatorUtils.java | 2 +- openbis/source/java/service.properties | 4 ++ .../ManagedPropertyEvaluatorTest.java | 5 +- ...StructuredPropertyConverterPythonTest.java | 4 +- 9 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedMultilineTextWidgetDescription.java diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedMultilineTextWidgetDescription.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedMultilineTextWidgetDescription.java new file mode 100644 index 00000000000..ce1d7631649 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedMultilineTextWidgetDescription.java @@ -0,0 +1,56 @@ +/* + * Copyright 2011 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedOutputWidgetDescription; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.ManagedOutputWidgetType; + +/** + * {@link IManagedOutputWidgetDescription} implementation for multiline text fields. + * + * @author Piotr Buczek + */ +public class ManagedMultilineTextWidgetDescription implements IManagedOutputWidgetDescription +{ + private static final long serialVersionUID = ServiceVersionHolder.VERSION; + + private String text; + + public ManagedMultilineTextWidgetDescription() + { + } + + // + // IManagedWidgetDescription + // + + public String getText() + { + return text; + } + + public void setText(String text) + { + this.text = text; + } + + public ManagedOutputWidgetType getManagedOutputWidgetType() + { + return ManagedOutputWidgetType.MULTILINE_TEXT; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedUiDescription.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedUiDescription.java index f298ac9b2ac..5dd0dba0144 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedUiDescription.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedUiDescription.java @@ -83,4 +83,12 @@ public class ManagedUiDescription implements IManagedUiDescription, ISerializabl } setOutputWidgetDescription(tableWidget); } + + public void useMultilineTextOutput(String text) + { + ManagedMultilineTextWidgetDescription textWidget = + new ManagedMultilineTextWidgetDescription(); + textWidget.setText(text); + setOutputWidgetDescription(textWidget); + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedUiDescription.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedUiDescription.java index 1e189d3c475..32a8ffe6a27 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedUiDescription.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedUiDescription.java @@ -34,6 +34,11 @@ public interface IManagedUiDescription extends ISerializable */ void useTableOutput(ITableModel tableModel); + /** + * Sets the output to be shown as a multi-line text view. + */ + void useMultilineTextOutput(String text); + /** * Adds a table action with given name to actions that can be performed in the user interface * for modification of the managed property. diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/ManagedOutputWidgetType.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/ManagedOutputWidgetType.java index 60187549004..0cbff6dfb80 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/ManagedOutputWidgetType.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/ManagedOutputWidgetType.java @@ -24,5 +24,5 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.ISerializable; // NOTE: This enumeration is part of the Managed Properties API. public enum ManagedOutputWidgetType implements ISerializable { - TABLE, LABEL; + TABLE, MULTILINE_TEXT; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/ManagedPropertyEvaluator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/ManagedPropertyEvaluator.java index 52e7f62c98e..19e9c09b653 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/ManagedPropertyEvaluator.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/ManagedPropertyEvaluator.java @@ -32,6 +32,7 @@ import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedUiAction; +import ch.systemsx.cisd.openbis.generic.shared.dto.EntityPropertyPE; /** * Class for evaluating scripts that control managed properties. @@ -65,6 +66,8 @@ public class ManagedPropertyEvaluator private static final String PROPERTY_VARIABLE_NAME = "property"; + private static final String PROPERTY_PE_VARIABLE_NAME = "propertyPE"; + /** * Asserts that for all specified batch column names bindings are specified. If the list of * column names is empty the value should be bound at an empty string. @@ -153,7 +156,7 @@ public class ManagedPropertyEvaluator columnNames = Collections.unmodifiableList(names); } - public void configureUI(IManagedProperty managedProperty) + public void configureUI(IManagedProperty managedProperty, EntityPropertyPE entityPropertyPE) { if (operationLog.isDebugEnabled()) { @@ -162,6 +165,7 @@ public class ManagedPropertyEvaluator } evaluator.set(PROPERTY_VARIABLE_NAME, managedProperty); + evaluator.set(PROPERTY_PE_VARIABLE_NAME, entityPropertyPE); evaluator.evalFunction(CONFIGURE_UI_FUNCTION); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/PropertyTranslatorUtils.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/PropertyTranslatorUtils.java index 45d6af550f9..9cb238b01a3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/PropertyTranslatorUtils.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/PropertyTranslatorUtils.java @@ -86,7 +86,7 @@ final class PropertyTranslatorUtils ManagedPropertyEvaluator evaluator = ManagedPropertyEvaluatorFactory.createManagedPropertyEvaluator(script .getScript()); - evaluator.configureUI(result); + evaluator.configureUI(result, property); } catch (EvaluatorException ex) { result.setValue(BasicConstant.ERROR_PROPERTY_PREFIX + ex.getMessage()); diff --git a/openbis/source/java/service.properties b/openbis/source/java/service.properties index c7018a8dcad..04b001615dd 100644 --- a/openbis/source/java/service.properties +++ b/openbis/source/java/service.properties @@ -15,7 +15,10 @@ database.create-from-scratch = false # For debugging set this value to true. database.script-single-step-mode = false database.url-host-part = +# database.kind = new +# database.kind = basynthec database.kind = test +# database.kind = basysbio # database.kind = system_test_strict # database.kind = system_test_plates_on_demand # database.kind = system_test_multi_groups @@ -54,6 +57,7 @@ hibernate.search.index-base = ./targets/indices-${database.kind} # If not specified, default (SKIP_IF_MARKER_FOUND) is taken. #hibernate.search.index-mode = INDEX_FROM_SCRATCH hibernate.search.index-mode = SKIP_IF_MARKER_FOUND + # Defines the maximum number of elements indexed before flushing the transaction-bound queue. # Default is 1000. hibernate.search.batch-size = 1000 diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/ManagedPropertyEvaluatorTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/ManagedPropertyEvaluatorTest.java index cbdde2e1240..f751b9138a8 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/ManagedPropertyEvaluatorTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/ManagedPropertyEvaluatorTest.java @@ -39,6 +39,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedUiAction; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedUiDescription; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.ManagedInputFieldType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.ManagedOutputWidgetType; +import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePropertyPE; import ch.systemsx.cisd.openbis.generic.shared.util.SimpleTableModelBuilder; /** @@ -86,7 +87,7 @@ public class ManagedPropertyEvaluatorTest extends AssertJUnit CommonTestUtils.getResourceAsString(SCRIPT_FOLDER, CONFIGURE_UI_OUTPUT_TEST_PY); ManagedPropertyEvaluator evaluator = new ManagedPropertyEvaluator(script); - evaluator.configureUI(managedProperty); + evaluator.configureUI(managedProperty, new SamplePropertyPE()); assertEquals(true, managedProperty.isOwnTab()); IManagedOutputWidgetDescription outputWidgetDescripion = managedProperty.getUiDescription().getOutputWidgetDescription(); @@ -143,7 +144,7 @@ public class ManagedPropertyEvaluatorTest extends AssertJUnit CommonTestUtils.getResourceAsString(SCRIPT_FOLDER, CONFIGURE_UI_INPUT_TEST_PY); ManagedPropertyEvaluator evaluator = new ManagedPropertyEvaluator(script); - evaluator.configureUI(managedProperty); + evaluator.configureUI(managedProperty, new SamplePropertyPE()); assertEquals(false, managedProperty.isOwnTab()); List<IManagedUiAction> actions = managedProperty.getUiDescription().getActions(); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/StructuredPropertyConverterPythonTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/StructuredPropertyConverterPythonTest.java index c44864b8c53..d205edbc317 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/StructuredPropertyConverterPythonTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/managed_property/structured/StructuredPropertyConverterPythonTest.java @@ -25,6 +25,7 @@ import ch.systemsx.cisd.openbis.generic.shared.CommonTestUtils; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ManagedEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedProperty; +import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePropertyPE; import ch.systemsx.cisd.openbis.generic.shared.managed_property.ManagedPropertyEvaluator; import ch.systemsx.cisd.openbis.generic.shared.managed_property.ManagedPropertyFunctions; import ch.systemsx.cisd.openbis.generic.shared.managed_property.api.IElement; @@ -49,7 +50,7 @@ public class StructuredPropertyConverterPythonTest extends AssertJUnit CommonTestUtils.getResourceAsString(SCRIPT_FOLDER, "structured-property-test.py"); ManagedPropertyEvaluator evaluator = new ManagedPropertyEvaluator(script); - evaluator.configureUI(managedProperty); + evaluator.configureUI(managedProperty, new SamplePropertyPE()); // the script will create several elements and serialize them in the property value List<IElement> elements = @@ -57,5 +58,4 @@ public class StructuredPropertyConverterPythonTest extends AssertJUnit assertEquals(3, elements.size()); } - } -- GitLab