diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java index d1a4b50782032d09f33f941c47d6b550b656a2ab..3ac72d2c4bb6f9dbc081c40f3f61a67056a585a6 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java @@ -462,7 +462,8 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp throw UserFailureException.fromTemplate("Sample type with code '%s' does not exist.", sampleTypeCode); } - getPropertiesBatchManager().manageProperties(sampleTypePE, newSamplesWithType); + getPropertiesBatchManager().manageProperties(sampleTypePE, newSamplesWithType, + registratorOrNull); getSampleTypeSlaveServerPlugin(sampleTypePE).registerSamples(session, newSamples, registratorOrNull); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/IPropertiesBatchManager.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/IPropertiesBatchManager.java index 69112f488168050cbf163173f90a7ec965328738..32aab8637cdb3229c1274d0031913b6466471e64 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/IPropertiesBatchManager.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/IPropertiesBatchManager.java @@ -23,6 +23,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewMaterial; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSamplesWithTypes; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialTypePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleTypePE; /** @@ -32,9 +33,12 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.SampleTypePE; */ public interface IPropertiesBatchManager { - public void manageProperties(SampleTypePE sampleType, NewSamplesWithTypes newSamplesWithTypes); + public void manageProperties(SampleTypePE sampleType, NewSamplesWithTypes newSamplesWithTypes, + PersonPE registrator); - public void manageProperties(ExperimentTypePE experimentType, NewExperimentsWithType experiments); + public void manageProperties(ExperimentTypePE experimentType, + NewExperimentsWithType experiments, PersonPE registrator); - public void manageProperties(MaterialTypePE materialType, List<NewMaterial> newMaterials); + public void manageProperties(MaterialTypePE materialType, List<NewMaterial> newMaterials, + PersonPE registrator); } \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/PropertiesBatchEvaluationErrors.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/PropertiesBatchEvaluationErrors.java new file mode 100644 index 0000000000000000000000000000000000000000..6911dcfbc545d35cda7c197d4851126833064f43 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/PropertiesBatchEvaluationErrors.java @@ -0,0 +1,215 @@ +/* + * 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.server.business; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import ch.systemsx.cisd.common.evaluator.EvaluatorException; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.ScriptPE; + +/** + * @author Kaloyan Enimanev + */ +class PropertiesBatchEvaluationErrors +{ + /** + * limitation on the number of ErrorDetails objects kept in memory. This guards us from + * scripts generating unique error messages for excessively large batches. + */ + private static final int MAX_ERROR_DETAILS_KEPT = 10; + + /** the maximum number of errors displayed to the user. */ + private static final int MAX_ERROR_IN_USER_MESSAGE = 2; + + private class ErrorDetail + { + ScriptPE scriptPE; + + EvaluatorException evaluationError; + + String propertyCode; + + List<Integer> rows = new ArrayList<Integer>(); + } + + private PersonPE registrator; + + private Map<String, ErrorDetail> errorDetails = new HashMap<String, ErrorDetail>(); + + private int totalRowsNumber; + + private int totalFailedRowsNumber; + + PropertiesBatchEvaluationErrors(PersonPE registrator, int totalRowsNumber) + { + this.registrator = registrator; + this.totalRowsNumber = totalRowsNumber; + } + + void accumulateError(int row, EvaluatorException evaluationError, String propertyCode, + ScriptPE script) + { + totalFailedRowsNumber++; + String errorMessage = evaluationError.getMessage(); + if (shouldSkipDetailsAccumulation(errorMessage)) + { + return; + } + + ErrorDetail details = errorDetails.get(errorMessage); + if (details == null) + { + details = new ErrorDetail(); + details.evaluationError = evaluationError; + details.scriptPE = script; + details.propertyCode = propertyCode; + } + details.rows.add(row); + errorDetails.put(errorMessage, details); + } + + /** + * @return <code>true</code> when the memory is full and no more errors should be + * accumulated. + */ + boolean shouldSkipDetailsAccumulation(String errorMessage) + { + return errorDetails.containsKey(errorMessage) == false + && errorDetails.size() >= MAX_ERROR_DETAILS_KEPT; + } + + boolean hasErrors() { + return totalFailedRowsNumber > 0; + } + + + /** + * creates a messages to be displayed to the user. + */ + String constructUserFailureMessage() + { + assert hasErrors() : "Cannot construct message when no errors were accumulated."; + StringBuilder message = new StringBuilder(); + message.append("Script malfunction in "); + message.append(totalFailedRowsNumber); + message.append(" out of "); + message.append(totalRowsNumber); + message.append(" rows."); + + int numDisplayErrors = Math.min(errorDetails.size(), MAX_ERROR_IN_USER_MESSAGE); + List<ErrorDetail> formatDetails = sortErrorDetailsByRow().subList(0, numDisplayErrors); + for (ErrorDetail errDetail : formatDetails) + { + message.append("\n"); + appendErrorDetails(message, errDetail, false); + message.append(": "); + message.append(errDetail.evaluationError.getMessage()); + } + + message.append("\n"); + message.append("A detailed error report has been sent to your system administrator."); + return message.toString(); + + } + + /** + * creates an e-mail, containg the error report + */ + String constructErrorReportEmail() + { + assert hasErrors() : "Cannot construct message when no errors were accumulated."; + StringBuilder message = new StringBuilder(); + message.append("A batch operation initiated from user "); + message.append(registrator); + message.append("has failed due to a script malfunction in "); + message.append(totalFailedRowsNumber); + message.append(" out of "); + message.append(totalRowsNumber); + message.append(" rows."); + message.append("\n"); + + for (ErrorDetail errDetail : sortErrorDetailsByRow()) + { + message.append("\n\n"); + appendErrorDetails(message, errDetail, true); + message.append(": "); + StringWriter sw = new StringWriter(); + errDetail.evaluationError.printStackTrace(new PrintWriter(sw)); + message.append(sw.toString()); + } + + return message.toString(); + + } + + private List<ErrorDetail> sortErrorDetailsByRow() { + List<ErrorDetail> result = new ArrayList<ErrorDetail>(errorDetails.values()); + Collections.sort(result, new Comparator<ErrorDetail>() + { + public int compare(ErrorDetail o1, ErrorDetail o2) + { + return o1.rows.get(0) - o2.rows.get(0); + } + }); + return result; + } + + private void appendErrorDetails(StringBuilder message, ErrorDetail errDetail, + boolean includeFullRegistratorDetails) + { + message.append(formatRows(errDetail.rows)); + message.append(" failed due to the property '"); + message.append(errDetail.propertyCode); + message.append("' causing a malfuction in the script (name = '"); + message.append(errDetail.scriptPE.getName()); + message.append("', registrator = '"); + if (errDetail.scriptPE.getRegistrator() != null) + { + if (includeFullRegistratorDetails) + { + message.append(errDetail.scriptPE.getRegistrator()); + } else + { + message.append(errDetail.scriptPE.getRegistrator().getEmail()); + } + } + message.append("')"); + } + + private String formatRows(List<Integer> rows) + { + if (rows.size() == 1) + { + return "Row " + rows.get(0) + " has"; + } + int displayRows = Math.min(rows.size(), 3); + List<Integer> displayRowsList = rows.subList(0, displayRows); + if (displayRows == rows.size()) + { + return "Rows " + displayRowsList + " have"; + } + return rows.size() + " rows including " + displayRowsList + " have"; + } +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/PropertiesBatchManager.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/PropertiesBatchManager.java index 356cfbdf8c2d22c28fd617a9df46059fb980c9a6..30004e9f67f87c986135e4296d80f30a11fb3438 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/PropertiesBatchManager.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/PropertiesBatchManager.java @@ -24,9 +24,12 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import org.apache.log4j.Logger; + import ch.systemsx.cisd.common.evaluator.EvaluatorException; import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant; +import ch.systemsx.cisd.common.logging.LogCategory; +import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityProperty; @@ -41,7 +44,9 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.ValidationException import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePropertyTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialTypePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleTypePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.ScriptPE; import ch.systemsx.cisd.openbis.generic.shared.managed_property.ManagedPropertyEvaluator; import ch.systemsx.cisd.openbis.generic.shared.managed_property.ManagedPropertyEvaluatorFactory; @@ -52,81 +57,131 @@ import ch.systemsx.cisd.openbis.generic.shared.managed_property.ManagedPropertyE */ public class PropertiesBatchManager implements IPropertiesBatchManager { - public void manageProperties(SampleTypePE sampleType, NewSamplesWithTypes newSamplesWithTypes) + + private static class EvaluationContext + { + ManagedPropertyEvaluator evaluator; + + ScriptPE scriptPE; + } + + private final Logger notificationLog = LogFactory.getLogger(LogCategory.NOTIFY, getClass()); + + + + public void manageProperties(SampleTypePE sampleType, NewSamplesWithTypes newSamplesWithTypes, + PersonPE registrator) { Set<? extends EntityTypePropertyTypePE> sampleTypePropertyTypes = sampleType.getSampleTypePropertyTypes(); - managePropertiesBeans(newSamplesWithTypes.getNewSamples(), sampleTypePropertyTypes); + managePropertiesBeans(newSamplesWithTypes.getNewSamples(), sampleTypePropertyTypes, + registrator); } - public void manageProperties(ExperimentTypePE experimentType, NewExperimentsWithType experiments) + public void manageProperties(ExperimentTypePE experimentType, + NewExperimentsWithType experiments, PersonPE registrator) { Set<? extends EntityTypePropertyTypePE> entityTypePropertyTypes = experimentType.getExperimentTypePropertyTypes(); - managePropertiesBeans(experiments.getNewExperiments(), entityTypePropertyTypes); + managePropertiesBeans(experiments.getNewExperiments(), entityTypePropertyTypes, registrator); } - public void manageProperties(MaterialTypePE materialType, List<NewMaterial> newMaterials) + public void manageProperties(MaterialTypePE materialType, List<NewMaterial> newMaterials, + PersonPE registrator) { Set<? extends EntityTypePropertyTypePE> entityTypePropertyTypes = materialType.getMaterialTypePropertyTypes(); - managePropertiesBeans(newMaterials, entityTypePropertyTypes); + managePropertiesBeans(newMaterials, entityTypePropertyTypes, registrator); } private void managePropertiesBeans(List<? extends IPropertiesBean> propertiesBeans, - Set<? extends EntityTypePropertyTypePE> entityTypePropertyTypes) + Set<? extends EntityTypePropertyTypePE> entityTypePropertyTypes, PersonPE registrator) + { + Map<String, EvaluationContext> contexts = + createEvaluationContexts(entityTypePropertyTypes); + PropertiesBatchEvaluationErrors errors = new PropertiesBatchEvaluationErrors(registrator, propertiesBeans.size()); + + int rowNumber = 0; + for (IPropertiesBean propertiesBean : propertiesBeans) + { + rowNumber++; + List<IEntityProperty> newProperties = + accumulateNewProperties(propertiesBean, rowNumber, contexts, errors); + IEntityProperty[] newPropArray = + newProperties.toArray(new IEntityProperty[newProperties.size()]); + propertiesBean.setProperties(newPropArray); + } + + if (errors.hasErrors()) + { + // send an email, so that actions can be taken to repair the script + notificationLog.error(errors.constructErrorReportEmail()); + // inform the user that batch import has failed + throw new UserFailureException(errors.constructUserFailureMessage()); + } + } + + private List<IEntityProperty> accumulateNewProperties(IPropertiesBean propertiesBean, + int rowNumber, Map<String, EvaluationContext> contexts, + PropertiesBatchEvaluationErrors errors) { - Map<String, ManagedPropertyEvaluator> evaluators = - createEvaluators(entityTypePropertyTypes); - for (int i = 0; i < propertiesBeans.size(); i++) + List<IEntityProperty> newProperties = new ArrayList<IEntityProperty>(); + + Map<String, Map<String, String>> subColumnBindings = + createColumnBindingsMap(propertiesBean.getProperties()); + for (Entry<String, Map<String, String>> entry : subColumnBindings.entrySet()) { - IPropertiesBean propertiesBean = propertiesBeans.get(i); - IEntityProperty[] properties = propertiesBean.getProperties(); - List<IEntityProperty> newProperties = new ArrayList<IEntityProperty>(); - Map<String, Map<String, String>> subColumnBindings = - createColumnBindingsMap(properties); - for (Entry<String, Map<String, String>> entry : subColumnBindings.entrySet()) + String code = entry.getKey(); + EvaluationContext evalContext = contexts.get(code); + try { - String code = entry.getKey(); - Map<String, String> bindings = entry.getValue(); - ManagedPropertyEvaluator evaluator = evaluators.get(code); - EntityProperty entityProperty = new EntityProperty(); - PropertyType propertyType = new PropertyType(); - propertyType.setCode(code); - propertyType.setDataType(new DataType(DataTypeCode.VARCHAR)); - entityProperty.setPropertyType(propertyType); - if (evaluator == null) - { - ManagedPropertyEvaluator.assertBatchColumnNames(code, - Collections.<String> emptyList(), bindings); - entityProperty.setValue(bindings.get("")); - } else + EntityProperty entityProperty = + evaluateManagedProperty(code, entry.getValue(), evalContext); + newProperties.add(entityProperty); + } catch (EvaluatorException ex) + { + Throwable cause = ex.getCause(); + if (cause instanceof ValidationException) { - try - { - ManagedProperty managedProperty = new ManagedProperty(); - managedProperty.setPropertyTypeCode(code); - evaluator.updateFromBatchInput(managedProperty, bindings); - entityProperty.setValue(managedProperty.getValue()); - } catch (EvaluatorException ex) - { - Throwable cause = ex.getCause(); - if (cause instanceof ValidationException) - { - throw new UserFailureException("Error in row " + (i + 1) + ": " - + cause.getMessage()); - } - entityProperty.setValue(BasicConstant.ERROR_PROPERTY_PREFIX - + ex.getMessage()); - } + throw new UserFailureException("Error in row " + rowNumber + ": " + + cause.getMessage()); } - newProperties.add(entityProperty); + errors.accumulateError(rowNumber, ex, code, evalContext.scriptPE); } - propertiesBean.setProperties(newProperties.toArray(new IEntityProperty[newProperties - .size()])); } + return newProperties; + } + + private EntityProperty evaluateManagedProperty(String code, Map<String, String> bindings, + EvaluationContext evalContext) + { + EntityProperty entityProperty = createNewEntityProperty(code); + if (evalContext == null) + { + ManagedPropertyEvaluator.assertBatchColumnNames(code, + Collections.<String> emptyList(), bindings); + entityProperty.setValue(bindings.get("")); + } else + { + ManagedPropertyEvaluator evaluator = evalContext.evaluator; + ManagedProperty managedProperty = new ManagedProperty(); + managedProperty.setPropertyTypeCode(code); + evaluator.updateFromBatchInput(managedProperty, bindings); + entityProperty.setValue(managedProperty.getValue()); + } + return entityProperty; + } + + private EntityProperty createNewEntityProperty(String code) + { + EntityProperty entityProperty = new EntityProperty(); + PropertyType propertyType = new PropertyType(); + propertyType.setCode(code); + propertyType.setDataType(new DataType(DataTypeCode.VARCHAR)); + entityProperty.setPropertyType(propertyType); + return entityProperty; } private Map<String, Map<String, String>> createColumnBindingsMap(IEntityProperty[] properties) @@ -155,22 +210,23 @@ public class PropertiesBatchManager implements IPropertiesBatchManager return subColumnBindings; } - private Map<String, ManagedPropertyEvaluator> createEvaluators( + private Map<String, EvaluationContext> createEvaluationContexts( Set<? extends EntityTypePropertyTypePE> entityTypePropertyTypes) { - Map<String, ManagedPropertyEvaluator> evaluators = - new HashMap<String, ManagedPropertyEvaluator>(); + Map<String, EvaluationContext> result = new HashMap<String, EvaluationContext>(); for (EntityTypePropertyTypePE entityTypePropertyType : entityTypePropertyTypes) { if (entityTypePropertyType.isManaged()) { String propertyTypeCode = entityTypePropertyType.getPropertyType().getCode(); String script = entityTypePropertyType.getScript().getScript(); - ManagedPropertyEvaluator evaluator = + EvaluationContext context = new EvaluationContext(); + context.evaluator = ManagedPropertyEvaluatorFactory.createManagedPropertyEvaluator(script); - evaluators.put(propertyTypeCode, evaluator); + context.scriptPE = entityTypePropertyType.getScript(); + result.put(propertyTypeCode, context); } } - return evaluators; + return result; } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java index 6b4bcdfe74ad6c68fdf4b72ff43f6bdf6db00d71..9d61ce3d32f495465fe0e6c70db8a1e661f431be 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java @@ -548,9 +548,10 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen return; } ServerUtils.prevalidate(newMaterials, "material"); - final MaterialTypePE materialTypePE = findMaterialType(materialTypeCode); - getPropertiesBatchManager().manageProperties(materialTypePE, newMaterials); final Session session = getSession(sessionToken); + final MaterialTypePE materialTypePE = findMaterialType(materialTypeCode); + getPropertiesBatchManager().manageProperties(materialTypePE, newMaterials, + session.tryGetPerson()); IBatchOperation<NewMaterial> strategy = new IBatchOperation<NewMaterial>() { @@ -836,7 +837,8 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen throw UserFailureException.fromTemplate( "Experiment type with code '%s' does not exist.", experimentTypePE); } - getPropertiesBatchManager().manageProperties(experimentTypePE, experiments); + getPropertiesBatchManager().manageProperties(experimentTypePE, experiments, + session.tryGetPerson()); BatchOperationExecutor.executeInBatches(new ExperimentBatchRegistration( businessObjectFactory.createExperimentTable(session), newExperiments, experimentTypePE)); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/PropertiesBatchManagerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/PropertiesBatchManagerTest.java index c0eae0542c16be5dff7d81076ab6ddb42e64b2f0..6ed9c440ca813aa238323fb016f8bc7291e317ba 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/PropertiesBatchManagerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/PropertiesBatchManagerTest.java @@ -22,7 +22,6 @@ import org.testng.AssertJUnit; import org.testng.annotations.Test; import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IPropertiesBean; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewBasicExperiment; @@ -35,8 +34,6 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.builders.ExperimentTypePEBuil import ch.systemsx.cisd.openbis.generic.shared.dto.builders.SampleTypePEBuilder; /** - * - * * @author felmer */ public class PropertiesBatchManagerTest extends AssertJUnit @@ -71,7 +68,8 @@ public class PropertiesBatchManagerTest extends AssertJUnit addProperties(e2, p3, p4, p5); NewExperimentsWithType experiments = new NewExperimentsWithType("T", Arrays.asList(e1, e2)); - new PropertiesBatchManager().manageProperties(builder.getExperimentTypePE(), experiments); + new PropertiesBatchManager().manageProperties(builder.getExperimentTypePE(), experiments, + null); assertProperties("UN-MANAGED:hello, MANAGED-NO-SUBCOLUMNS:hi", e1); assertProperties("MANAGED-NO-SUBCOLUMNS-BUT-UPDATE:hi alpha, MANAGED_SUBCOLUMNS:ab12", e2); @@ -92,12 +90,21 @@ public class PropertiesBatchManagerTest extends AssertJUnit addProperties(s2, p2); NewSamplesWithTypes samples = new NewSamplesWithTypes(null, Arrays.asList(s1, s2)); - new PropertiesBatchManager().manageProperties(builder.getSampleType(), samples); + try + { + new PropertiesBatchManager().manageProperties(builder.getSampleType(), samples, null); + } catch (UserFailureException ufe) + { + assertEquals( + "Script malfunction in 1 out of 2 rows.\n" + + "Row 2 has failed due to the property 'MANAGED-NO-SUBCOLUMNS-BUT-UPDATE' causing a malfuction " + + "in the script (name = 'null', registrator = ''): Error evaluating 'updateFromBatchInput({=two})': " + + "ValueError: invalid literal for __int__: two\n" + + "A detailed error report has been sent to your system administrator.", + ufe.getMessage()); + } assertProperties("MANAGED-NO-SUBCOLUMNS-BUT-UPDATE:43", s1); - assertProperties("MANAGED-NO-SUBCOLUMNS-BUT-UPDATE:" + BasicConstant.ERROR_PROPERTY_PREFIX - + "Error evaluating 'updateFromBatchInput({=two})': " - + "ValueError: invalid literal for __int__: two", s2); } @Test @@ -114,7 +121,8 @@ public class PropertiesBatchManagerTest extends AssertJUnit try { - new PropertiesBatchManager().manageProperties(builder.getExperimentTypePE(), experiments); + new PropertiesBatchManager().manageProperties(builder.getExperimentTypePE(), + experiments, null); fail("UserFailureException expected"); } catch (UserFailureException ex) { @@ -135,7 +143,8 @@ public class PropertiesBatchManagerTest extends AssertJUnit try { - new PropertiesBatchManager().manageProperties(builder.getExperimentTypePE(), experiments); + new PropertiesBatchManager().manageProperties(builder.getExperimentTypePE(), + experiments, null); fail("UserFailureException expected"); } catch (UserFailureException ex) { diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java index 5f1fa78301ad0a0cdfa72d0d49b9509cb8ba6f72..b08783e5049ae670735ef8c1141202a510325e49 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java @@ -280,7 +280,8 @@ public final class GenericServerTest extends AbstractServerTestCase one(sampleTypeSlaveServerPlugin).registerSamples(SESSION, newSamples, null); - one(propertiesBatchManager).manageProperties(sampleTypePE, newSamplesWithType); + one(propertiesBatchManager).manageProperties(sampleTypePE, newSamplesWithType, + null); } }); createServer().registerOrUpdateSamples(SESSION_TOKEN, samplesWithTypes); @@ -309,7 +310,8 @@ public final class GenericServerTest extends AbstractServerTestCase one(sampleTypeSlaveServerPlugin).registerSamples(SESSION, newSamples, null); - one(propertiesBatchManager).manageProperties(sampleTypePE, newSamplesWithType); + one(propertiesBatchManager).manageProperties(sampleTypePE, newSamplesWithType, + null); } }); createServer().registerSamples(SESSION_TOKEN, samplesWithTypes); @@ -450,7 +452,8 @@ public final class GenericServerTest extends AbstractServerTestCase one(daoFactory).getEntityTypeDAO(EntityKind.MATERIAL); will(returnValue(entityTypeDAO)); - one(propertiesBatchManager).manageProperties(materialTypePE, newMaterials); + one(propertiesBatchManager) + .manageProperties(materialTypePE, newMaterials, null); one(entityTypeDAO).tryToFindEntityTypeByCode(typeCode); will(returnValue(materialTypePE)); @@ -837,7 +840,8 @@ public final class GenericServerTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(propertiesBatchManager).manageProperties(experimentTypePE, experiments); + one(propertiesBatchManager).manageProperties(experimentTypePE, experiments, + null); one(daoFactory).getEntityTypeDAO(EntityKind.EXPERIMENT); will(returnValue(entityTypeDAO)); one(entityTypeDAO).tryToFindEntityTypeByCode(EXPERIMENT_TYPE);