diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/MetaprojectArea.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/MetaprojectArea.java index 1b8ba83927cafec557b7b96a67e416ec5deebb51..e52e7442f425bf91356d6e8fbf9930d55c0f1a5b 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/MetaprojectArea.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/MetaprojectArea.java @@ -64,7 +64,31 @@ public class MetaprojectArea extends MultilineItemsField public final String[] tryGetMetaprojects() { - return tryGetModifiedItemList(); + return getNotEmptyItems(getItems()); + } + + public final String[] tryGetModifiedMetaprojects() + { + return getNotEmptyItems(tryGetModifiedItemList()); + } + + private String[] getNotEmptyItems(String[] items) + { + if (items != null) + { + List<String> notEmptyItems = new ArrayList<String>(); + for (String item : items) + { + if (item != null && item.trim().length() > 0) + { + notEmptyItems.add(item.trim()); + } + } + return notEmptyItems.toArray(new String[notEmptyItems.size()]); + } else + { + return null; + } } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObject.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObject.java index 7648ff30ca0350d347431032abae26317229e6eb..37836efe912448c3b7204f6440ff5a1652659933 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObject.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObject.java @@ -216,6 +216,11 @@ abstract class AbstractBusinessObject implements IDAOFactory for (String metaprojectsOrNullItem : metaprojectsOrNull) { + if (metaprojectsOrNullItem == null) + { + throw new IllegalArgumentException("Metaproject cannot be null"); + } + MetaprojectPE metaproject = getMetaprojectDAO().tryFindByOwnerAndName(session.getUserName(), metaprojectsOrNullItem); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/GenericDataSetEditForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/GenericDataSetEditForm.java index 7cf9d8dfeba01676dfbd1de01308eccbec7b4b9a..6f24d3aef451037708f665321dc2afd7df669b21 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/GenericDataSetEditForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/GenericDataSetEditForm.java @@ -141,7 +141,7 @@ public final class GenericDataSetEditForm extends result.setExperimentIdentifierOrNull(extractExperimentIdentifier()); } result.setModifiedParentDatasetCodesOrNull(extractParentDatasetCodes()); - result.setMetaprojectsOrNull(metaprojectArea.tryGetMetaprojects()); + result.setMetaprojectsOrNull(metaprojectArea.tryGetModifiedMetaprojects()); builder.fillUpdates(result); return result; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentEditForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentEditForm.java index ef8e78bf509175b3cdb32c45b188aa5afc3023cd..b9ff6791d8d2fa6ebcfba9c92128c25d608b68fd 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentEditForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentEditForm.java @@ -101,7 +101,7 @@ public final class GenericExperimentEditForm extends AbstractGenericExperimentRe updates.setGenerateCodes(autoGenerateCodes.getValue().booleanValue()); updates.setRegisterSamples(existingSamplesRadio.getValue() == false); updates.setSamplesSessionKey(samplesSessionKey); - updates.setMetaprojectsOrNull(metaprojectArea.tryGetMetaprojects()); + updates.setMetaprojectsOrNull(metaprojectArea.tryGetModifiedMetaprojects()); viewContext.getService().updateExperiment(updates, new UpdateExperimentCallback(viewContext)); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentRegistrationForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentRegistrationForm.java index 052f7b35ec4cd0b310eb86486255a78e4645ffaa..87cfd201422554c5f79d51d90079af59aa1a24df 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentRegistrationForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentRegistrationForm.java @@ -104,7 +104,7 @@ public final class GenericExperimentRegistrationForm extends newExp.setGenerateCodes(autoGenerateCodes.getValue().booleanValue()); newExp.setRegisterSamples(existingSamplesRadio.getValue() == false); newExp.setAttachments(attachmentsManager.extractAttachments()); - newExp.setMetaprojectsOrNull(metaprojectArea.tryGetMetaprojects()); + newExp.setMetaprojectsOrNull(metaprojectArea.tryGetModifiedMetaprojects()); viewContext.getService().registerExperiment(attachmentsSessionKey, samplesSessionKey, newExp, new RegisterExperimentCallback(viewContext)); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/material/GenericMaterialEditForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/material/GenericMaterialEditForm.java index b6a6fccf2f591b4295bbd190f0e5068f2fd2a56c..6b0745fef7c274693003396e2758f429a478240b 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/material/GenericMaterialEditForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/material/GenericMaterialEditForm.java @@ -67,7 +67,7 @@ public final class GenericMaterialEditForm extends public final void submitValidForm() { viewContext.getService().updateMaterial(techIdOrNull, extractProperties(), - metaprojectArea.tryGetMetaprojects(), originalMaterial.getModificationDate(), + metaprojectArea.tryGetModifiedMetaprojects(), originalMaterial.getModificationDate(), new UpdateMaterialCallback(viewContext)); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleEditForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleEditForm.java index db871fa537617af8dfe648886bc9440b9a8ef31c..38605464146bb5c4e375d268a097468e5bd7148b 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleEditForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleEditForm.java @@ -75,7 +75,7 @@ public final class GenericSampleEditForm extends AbstractGenericSampleRegisterEd new SampleUpdates(attachmentsSessionKey, techIdOrNull, properties, attachments, experimentIdent, originalSample.getModificationDate(), createSampleIdentifier(), containerOrNull, parents); - sampleUpdates.setMetaprojectsOrNull(metaprojectArea.tryGetMetaprojects()); + sampleUpdates.setMetaprojectsOrNull(metaprojectArea.tryGetModifiedMetaprojects()); viewContext.getService().updateSample(sampleUpdates, enrichWithPostRegistration(new UpdateSampleCallback(viewContext))); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleRegistrationForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleRegistrationForm.java index b8084927924af200ed4899224e72f72d1a6f3226..8ee034d6548c5806276da434ac7ec8768f63ddc9 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleRegistrationForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleRegistrationForm.java @@ -110,7 +110,7 @@ public final class GenericSampleRegistrationForm extends AbstractGenericSampleRe newSample.setProperties(properties.toArray(IEntityProperty.EMPTY_ARRAY)); newSample.setAttachments(attachmentsManager.extractAttachments()); newSample.setExperimentIdentifier(experimentIdentifier); - newSample.setMetaprojectsOrNull(metaprojectArea.tryGetMetaprojects()); + newSample.setMetaprojectsOrNull(metaprojectArea.tryGetModifiedMetaprojects()); viewContext.getService().registerSample(attachmentsSessionKey, newSample, enrichWithPostRegistration(new RegisterSampleCallback(viewContext)));