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 53ad60a3948d12b0ba9db181a9082de090c60cd8..dd81f9a5b71300defed765fbe1ac4a74b36e8099 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 c9887376a706e73a6aacb581f88364aac82e5d25..1d93280a12975c367e458dde62648b158da0da54 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 0000000000000000000000000000000000000000..c44ffe39dd938c90c4a662e318142a90400c0b9c --- /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 cfa845f8cc5c126761813c45ab8cd2a1e9490f67..e2a0bdd3f673784953ef2da53fd60d445dbca14b 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 0000000000000000000000000000000000000000..593c44a8a6f1cb3351e709e0e31dea09f8b0d50f --- /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(); +}