From 2b6e646c15f56c3d0c4e8d0dd1f9747c5307db6f Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Tue, 15 Feb 2011 10:49:08 +0000 Subject: [PATCH] [LMS-2049] extended action with person SVN: 19957 --- .../openbis/generic/server/CommonServer.java | 23 ++++++++ .../basic/dto/ManagedUiActionDescription.java | 15 +++++- .../shared/basic/dto/PersonAdapter.java | 54 +++++++++++++++++++ .../basic/dto/api/IManagedUiAction.java | 3 ++ .../generic/shared/basic/dto/api/IPerson.java | 35 ++++++++++++ 5 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PersonAdapter.java create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IPerson.java 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 53ad60a3948..dd81f9a5b71 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 @@ -116,6 +116,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.LinkModel; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListMaterialCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListOrSearchSampleCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListSampleCriteria; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ManagedUiActionDescription; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MatchingEntity; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Material; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialIdentifier; @@ -129,6 +130,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewMaterial; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewVocabulary; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Person; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PersonAdapter; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleAssignment; @@ -145,6 +147,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTerm; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTermReplacement; 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.basic.dto.api.IPerson; import ch.systemsx.cisd.openbis.generic.shared.dto.AttachmentHolderPE; import ch.systemsx.cisd.openbis.generic.shared.dto.AttachmentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.AuthorizationGroupPE; @@ -2247,6 +2250,7 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt experimentBO.getExperiment().getProperties(); ManagedPropertyEvaluator evaluator = tryManagedPropertyEvaluator(managedProperty, properties); + extendWithPerson(updateAction, session.tryGetPerson()); evaluator.updateFromUI(managedProperty, updateAction); experimentBO.updateManagedProperty(managedProperty); @@ -2271,6 +2275,7 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt Set<? extends EntityPropertyPE> properties = sampleBO.getSample().getProperties(); ManagedPropertyEvaluator evaluator = tryManagedPropertyEvaluator(managedProperty, properties); + extendWithPerson(updateAction, session.tryGetPerson()); evaluator.updateFromUI(managedProperty, updateAction); sampleBO.updateManagedProperty(managedProperty); @@ -2296,6 +2301,7 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt dataSetBO.getExternalData().getProperties(); ManagedPropertyEvaluator evaluator = tryManagedPropertyEvaluator(managedProperty, properties); + extendWithPerson(updateAction, session.tryGetPerson()); evaluator.updateFromUI(managedProperty, updateAction); dataSetBO.updateManagedProperty(managedProperty); @@ -2320,6 +2326,7 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt Set<? extends EntityPropertyPE> properties = materialBO.getMaterial().getProperties(); ManagedPropertyEvaluator evaluator = tryManagedPropertyEvaluator(managedProperty, properties); + extendWithPerson(updateAction, session.tryGetPerson()); evaluator.updateFromUI(managedProperty, updateAction); materialBO.updateManagedProperty(managedProperty); @@ -2330,6 +2337,22 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt } } + private static void extendWithPerson(IManagedUiAction updateAction, PersonPE personOrNull) + { + if (personOrNull != null && updateAction instanceof ManagedUiActionDescription) + { + final String userId = personOrNull.getUserId(); + String userName = userId; + if (personOrNull.getFirstName() != null && personOrNull.getLastName() != null) + { + userName = personOrNull.getFirstName() + " " + personOrNull.getLastName(); + } + final IPerson person = new PersonAdapter(userId, userName); + final ManagedUiActionDescription action = (ManagedUiActionDescription) updateAction; + action.setPerson(person); + } + } + private ManagedPropertyEvaluator tryManagedPropertyEvaluator(IManagedProperty managedProperty, Set<? extends EntityPropertyPE> properties) { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedUiActionDescription.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedUiActionDescription.java index c9887376a70..1d93280a129 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedUiActionDescription.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ManagedUiActionDescription.java @@ -22,6 +22,7 @@ import java.util.List; import ch.systemsx.cisd.openbis.generic.shared.basic.ISerializable; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedInputWidgetDescription; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IManagedUiAction; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.IPerson; /** * Object that declaratively describes a UI for an action (e.g. describing UI of a dialog that @@ -33,10 +34,12 @@ public class ManagedUiActionDescription implements IManagedUiAction, ISerializab { private static final long serialVersionUID = ServiceVersionHolder.VERSION; - String name; + private String name; private String description; + private IPerson person; // invoker of the action + private List<IManagedInputWidgetDescription> inputWidgets = new ArrayList<IManagedInputWidgetDescription>(); @@ -96,4 +99,14 @@ public class ManagedUiActionDescription implements IManagedUiAction, ISerializab return null; } + public IPerson getPerson() + { + return person; + } + + public void setPerson(IPerson person) + { + this.person = person; + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PersonAdapter.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PersonAdapter.java new file mode 100644 index 00000000000..c44ffe39dd9 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PersonAdapter.java @@ -0,0 +1,54 @@ +/* + * 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.IPerson; + +/** + * @author Piotr Buczek + */ +public class PersonAdapter implements IPerson +{ + private static final long serialVersionUID = ServiceVersionHolder.VERSION; + + private String userId; + + private String userName; + + public PersonAdapter(String userId, String userName) + { + this.userId = userId; + this.userName = userName; + } + + public String getUserId() + { + return userId; + } + + public String getUserName() + { + return userName; + } + + @SuppressWarnings("unused") + // for GWT + private PersonAdapter() + { + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedUiAction.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedUiAction.java index cfa845f8cc5..e2a0bdd3f67 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedUiAction.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IManagedUiAction.java @@ -59,4 +59,7 @@ public interface IManagedUiAction extends ISerializable * doesn't exist. */ public String getInputValue(String inputLabel); + + /** Returns invoker of the action or <code>null</code> if action wasn't invoked yet. */ + public IPerson getPerson(); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IPerson.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IPerson.java new file mode 100644 index 00000000000..593c44a8a6f --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/api/IPerson.java @@ -0,0 +1,35 @@ +/* + * 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.api; + +import ch.systemsx.cisd.openbis.generic.shared.basic.ISerializable; + +/** + * Representation of a user, e.g. one who modifies a property. + * <p> + * <b>All methods of this interface are part of the Managed Properties API.</b> + * + * @author Piotr Buczek + */ +public interface IPerson extends ISerializable +{ + /** @return id of the user */ + String getUserId(); + + /** @return first name and last name of the user if known, otherwise id of the user */ + String getUserName(); +} -- GitLab