Skip to content
Snippets Groups Projects
Commit a3c01563 authored by pkupczyk's avatar pkupczyk
Browse files

SP-362 / BIS-246: Show metaproject tags in Web GUI and allow editing them when...

SP-362 / BIS-246: Show metaproject tags in Web GUI and allow editing them when editing an entity - handle a situation when metaprojects are specified in separate lines

SVN: 27487
parent 6111d08a
No related branches found
No related tags found
No related merge requests found
Showing
with 36 additions and 7 deletions
...@@ -64,7 +64,31 @@ public class MetaprojectArea extends MultilineItemsField ...@@ -64,7 +64,31 @@ public class MetaprojectArea extends MultilineItemsField
public final String[] tryGetMetaprojects() 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;
}
} }
} }
...@@ -216,6 +216,11 @@ abstract class AbstractBusinessObject implements IDAOFactory ...@@ -216,6 +216,11 @@ abstract class AbstractBusinessObject implements IDAOFactory
for (String metaprojectsOrNullItem : metaprojectsOrNull) for (String metaprojectsOrNullItem : metaprojectsOrNull)
{ {
if (metaprojectsOrNullItem == null)
{
throw new IllegalArgumentException("Metaproject cannot be null");
}
MetaprojectPE metaproject = MetaprojectPE metaproject =
getMetaprojectDAO().tryFindByOwnerAndName(session.getUserName(), getMetaprojectDAO().tryFindByOwnerAndName(session.getUserName(),
metaprojectsOrNullItem); metaprojectsOrNullItem);
......
...@@ -141,7 +141,7 @@ public final class GenericDataSetEditForm extends ...@@ -141,7 +141,7 @@ public final class GenericDataSetEditForm extends
result.setExperimentIdentifierOrNull(extractExperimentIdentifier()); result.setExperimentIdentifierOrNull(extractExperimentIdentifier());
} }
result.setModifiedParentDatasetCodesOrNull(extractParentDatasetCodes()); result.setModifiedParentDatasetCodesOrNull(extractParentDatasetCodes());
result.setMetaprojectsOrNull(metaprojectArea.tryGetMetaprojects()); result.setMetaprojectsOrNull(metaprojectArea.tryGetModifiedMetaprojects());
builder.fillUpdates(result); builder.fillUpdates(result);
return result; return result;
} }
......
...@@ -101,7 +101,7 @@ public final class GenericExperimentEditForm extends AbstractGenericExperimentRe ...@@ -101,7 +101,7 @@ public final class GenericExperimentEditForm extends AbstractGenericExperimentRe
updates.setGenerateCodes(autoGenerateCodes.getValue().booleanValue()); updates.setGenerateCodes(autoGenerateCodes.getValue().booleanValue());
updates.setRegisterSamples(existingSamplesRadio.getValue() == false); updates.setRegisterSamples(existingSamplesRadio.getValue() == false);
updates.setSamplesSessionKey(samplesSessionKey); updates.setSamplesSessionKey(samplesSessionKey);
updates.setMetaprojectsOrNull(metaprojectArea.tryGetMetaprojects()); updates.setMetaprojectsOrNull(metaprojectArea.tryGetModifiedMetaprojects());
viewContext.getService().updateExperiment(updates, viewContext.getService().updateExperiment(updates,
new UpdateExperimentCallback(viewContext)); new UpdateExperimentCallback(viewContext));
} }
......
...@@ -104,7 +104,7 @@ public final class GenericExperimentRegistrationForm extends ...@@ -104,7 +104,7 @@ public final class GenericExperimentRegistrationForm extends
newExp.setGenerateCodes(autoGenerateCodes.getValue().booleanValue()); newExp.setGenerateCodes(autoGenerateCodes.getValue().booleanValue());
newExp.setRegisterSamples(existingSamplesRadio.getValue() == false); newExp.setRegisterSamples(existingSamplesRadio.getValue() == false);
newExp.setAttachments(attachmentsManager.extractAttachments()); newExp.setAttachments(attachmentsManager.extractAttachments());
newExp.setMetaprojectsOrNull(metaprojectArea.tryGetMetaprojects()); newExp.setMetaprojectsOrNull(metaprojectArea.tryGetModifiedMetaprojects());
viewContext.getService().registerExperiment(attachmentsSessionKey, samplesSessionKey, viewContext.getService().registerExperiment(attachmentsSessionKey, samplesSessionKey,
newExp, new RegisterExperimentCallback(viewContext)); newExp, new RegisterExperimentCallback(viewContext));
} }
......
...@@ -67,7 +67,7 @@ public final class GenericMaterialEditForm extends ...@@ -67,7 +67,7 @@ public final class GenericMaterialEditForm extends
public final void submitValidForm() public final void submitValidForm()
{ {
viewContext.getService().updateMaterial(techIdOrNull, extractProperties(), viewContext.getService().updateMaterial(techIdOrNull, extractProperties(),
metaprojectArea.tryGetMetaprojects(), originalMaterial.getModificationDate(), metaprojectArea.tryGetModifiedMetaprojects(), originalMaterial.getModificationDate(),
new UpdateMaterialCallback(viewContext)); new UpdateMaterialCallback(viewContext));
} }
......
...@@ -75,7 +75,7 @@ public final class GenericSampleEditForm extends AbstractGenericSampleRegisterEd ...@@ -75,7 +75,7 @@ public final class GenericSampleEditForm extends AbstractGenericSampleRegisterEd
new SampleUpdates(attachmentsSessionKey, techIdOrNull, properties, attachments, new SampleUpdates(attachmentsSessionKey, techIdOrNull, properties, attachments,
experimentIdent, originalSample.getModificationDate(), experimentIdent, originalSample.getModificationDate(),
createSampleIdentifier(), containerOrNull, parents); createSampleIdentifier(), containerOrNull, parents);
sampleUpdates.setMetaprojectsOrNull(metaprojectArea.tryGetMetaprojects()); sampleUpdates.setMetaprojectsOrNull(metaprojectArea.tryGetModifiedMetaprojects());
viewContext.getService().updateSample(sampleUpdates, viewContext.getService().updateSample(sampleUpdates,
enrichWithPostRegistration(new UpdateSampleCallback(viewContext))); enrichWithPostRegistration(new UpdateSampleCallback(viewContext)));
......
...@@ -110,7 +110,7 @@ public final class GenericSampleRegistrationForm extends AbstractGenericSampleRe ...@@ -110,7 +110,7 @@ public final class GenericSampleRegistrationForm extends AbstractGenericSampleRe
newSample.setProperties(properties.toArray(IEntityProperty.EMPTY_ARRAY)); newSample.setProperties(properties.toArray(IEntityProperty.EMPTY_ARRAY));
newSample.setAttachments(attachmentsManager.extractAttachments()); newSample.setAttachments(attachmentsManager.extractAttachments());
newSample.setExperimentIdentifier(experimentIdentifier); newSample.setExperimentIdentifier(experimentIdentifier);
newSample.setMetaprojectsOrNull(metaprojectArea.tryGetMetaprojects()); newSample.setMetaprojectsOrNull(metaprojectArea.tryGetModifiedMetaprojects());
viewContext.getService().registerSample(attachmentsSessionKey, newSample, viewContext.getService().registerSample(attachmentsSessionKey, newSample,
enrichWithPostRegistration(new RegisterSampleCallback(viewContext))); enrichWithPostRegistration(new RegisterSampleCallback(viewContext)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment