diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java index 3a2584a90b61906a189f4c80860fe5a61418ae92..d5643a4986eed95f5c3f0924450a0aff2e59fc3c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java @@ -660,9 +660,27 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt IEntityTypePropertyTypeBO etptBO = businessObjectFactory.createEntityTypePropertyTypeBO(session, kind); etptBO.createAssignment(assignment); + return String.format("%s property type '%s' successfully assigned to %s type '%s'", - assignment.isMandatory() ? "Mandatory" : "Optional", - assignment.getPropertyTypeCode(), kind.getLabel(), assignment.getEntityTypeCode()); + getAssignmentType(assignment), assignment.getPropertyTypeCode(), kind.getLabel(), + assignment.getEntityTypeCode()); + } + + private String getAssignmentType(NewETPTAssignment assignment) + { + if (assignment.isDynamic()) + { + return "Dynamic"; + } else if (assignment.isManaged()) + { + return "Managed"; + } else if (assignment.isMandatory()) + { + return "Mandatory"; + } else + { + return "Optional"; + } } public void updatePropertyTypeAssignment(final String sessionToken, diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/DefaultBatchDynamicPropertyEvaluator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/DefaultBatchDynamicPropertyEvaluator.java index 3516f4812848e88261571d556470d6bd89832431..971195f2d3c38316b0d35a2c9066a0595f146e9d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/DefaultBatchDynamicPropertyEvaluator.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/dynamic_property/DefaultBatchDynamicPropertyEvaluator.java @@ -35,6 +35,8 @@ import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.openbis.generic.server.business.bo.EntityPropertiesConverter.IHibernateSessionProvider; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ScriptType; +import ch.systemsx.cisd.openbis.generic.shared.dto.ColumnNames; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.IEntityInformationWithPropertiesHolder; @@ -52,7 +54,7 @@ final class DefaultBatchDynamicPropertyEvaluator implements IBatchDynamicPropert private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, DefaultBatchDynamicPropertyEvaluator.class); - private static String ID_PROPERTY_NAME = "id"; + private static String ID_PROPERTY_NAME = ColumnNames.ID_COLUMN; private final static Map<Class<? extends IEntityInformationWithPropertiesHolder>, EntityKind> entityKindsByClass; @@ -261,7 +263,7 @@ final class DefaultBatchDynamicPropertyEvaluator implements IBatchDynamicPropert /** * Retains only those elements in the <code>ids</code> list that are ids of entities of given - * class that have a dynamic property. + * class that have a dynamic property (connected with one of specified scripts). */ private static <T extends IEntityInformationWithPropertiesHolder> void retainDynamicIds( final Session hibernateSession, final Class<T> clazz, final List<Long> ids) @@ -282,9 +284,11 @@ final class DefaultBatchDynamicPropertyEvaluator implements IBatchDynamicPropert EntityKind entityKind) throws DataAccessException { final String query = - String.format("SELECT DISTINCT pv.entity.id FROM %s pa join pa.propertyValues pv " - + "WHERE pa.dynamic = true", entityKind - .getEntityTypePropertyTypeAssignmentClass().getSimpleName()); + String.format("SELECT DISTINCT pv.entity.id FROM %s pa JOIN pa.propertyValues pv " + + "WHERE pa.script IS NOT NULL " + + "AND pa.script.scriptType = '%s'", entityKind + .getEntityTypePropertyTypeAssignmentClass().getSimpleName(), + ScriptType.DYNAMIC_PROPERTY); final List<Long> list = list(hibernateSession.createQuery(query)); if (operationLog.isDebugEnabled()) diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/plugin/generic/DynamicPropertiesEvaluationTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/plugin/generic/DynamicPropertiesEvaluationTest.java index e9bb60c7edd0f4bd8fba7f835b41d18239f694b2..8812089f51455868e4c2527387b7496c47a17248 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/plugin/generic/DynamicPropertiesEvaluationTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/plugin/generic/DynamicPropertiesEvaluationTest.java @@ -46,8 +46,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; * * @author Piotr Buczek */ -// @Test(groups = "system test") -@Test(groups = "broken") +@Test(groups = "system test") public class DynamicPropertiesEvaluationTest extends GenericSystemTestCase { private static final String CELL_PLATE = "CELL_PLATE";