diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java index 657e0270b1ab43c950d511096b895864a1232182..a966d924ac0287955ad18ff755dc5c15512d3dba 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java @@ -249,7 +249,7 @@ public interface ICommonClientService extends IClientService public List<SampleType> listSampleTypes() throws UserFailureException; public Map<String, List<IManagedInputWidgetDescription>> listManagedInputWidgetDescriptions( - EntityType entityType) throws UserFailureException; + EntityKind entityKind, String entityTypeCode) throws UserFailureException; /** * Returns a list of samples matching given criteria. diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java index 66dd2159a128557c8490cb7f59a734291859a293..6a6f409f265aadb67b47e750b2ed5d1915747531 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java @@ -199,8 +199,8 @@ public interface ICommonClientServiceAsync extends IClientServiceAsync /** @see ICommonClientService#listSampleTypes() */ public void listSampleTypes(AsyncCallback<List<SampleType>> asyncCallback); - /** @see ICommonClientService#listManagedInputWidgetDescriptions(EntityType) */ - public void listManagedInputWidgetDescriptions(EntityType entityType, + /** @see ICommonClientService#listManagedInputWidgetDescriptions(EntityKind, String) */ + public void listManagedInputWidgetDescriptions(EntityKind entityKind, String entityTypeCode, AsyncCallback<Map<String, List<IManagedInputWidgetDescription>>> asyncCallback); /** @see ICommonClientService#listFileTypes() */ diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/EntityRegistrationPanel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/EntityRegistrationPanel.java index 57b295c8ccb10d786b4ab8749dfed95e0a44d601..aa5ebb8601a4f8569868dd2322590fe69628d4c1 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/EntityRegistrationPanel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/EntityRegistrationPanel.java @@ -143,7 +143,8 @@ abstract public class EntityRegistrationPanel<T extends ModelData, S extends Dro private void showAndUpdateRegistrationForm(final T entityTypeModel, final EntityType entityType) { viewContext.getService().listManagedInputWidgetDescriptions( - entityType, + entityKind, + entityType.getCode(), new AbstractAsyncCallback<Map<String, List<IManagedInputWidgetDescription>>>( viewContext) { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java index 36be9fd0f58e34f425bcedf2d4bbf0a6e7655b5f..82af3c7a7313bf9e269444d185cddf6cb76d4ba3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java @@ -397,10 +397,11 @@ public final class CommonClientService extends AbstractClientService implements @Override public Map<String, List<IManagedInputWidgetDescription>> listManagedInputWidgetDescriptions( - EntityType entityType) + EntityKind entityKind, String entityTypeCode) { final String sessionToken = getSessionToken(); - return commonServer.listManagedInputWidgetDescriptions(sessionToken, entityType); + return commonServer.listManagedInputWidgetDescriptions(sessionToken, entityKind, + entityTypeCode); } @Override 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 7111ca7b59532c88e86acde2945f7a0bb730486d..1dfe6db5dc0350e27721a612d11d4f371905e224 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 @@ -303,6 +303,7 @@ import ch.systemsx.cisd.openbis.generic.shared.translator.DataStoreTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.DataTypeTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.DtoConverters; import ch.systemsx.cisd.openbis.generic.shared.translator.EntityHistoryTranslator; +import ch.systemsx.cisd.openbis.generic.shared.translator.EntityTypeTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.ExperimentTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.ExperimentTranslator.LoadableFields; import ch.systemsx.cisd.openbis.generic.shared.translator.ExternalDataManagementSystemTranslator; @@ -613,12 +614,19 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt @Override @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) public Map<String, List<IManagedInputWidgetDescription>> listManagedInputWidgetDescriptions( - String sessionToken, EntityType entityType) + String sessionToken, EntityKind entityKind, String entityTypeCode) { checkSession(sessionToken); + EntityTypePE entityTypePE = + getDAOFactory().getEntityTypeDAO(DtoConverters.convertEntityKind(entityKind)) + .tryToFindEntityTypeByCode(entityTypeCode); + + EntityType entityType = EntityTypeTranslator.translate(entityTypePE); + List<? extends EntityTypePropertyType<?>> assignedPropertyTypes = entityType.getAssignedPropertyTypes(); + return listManagedInputWidgetDescriptions(assignedPropertyTypes); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServerLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServerLogger.java index 107b55458010da59691e50b96c117c5586dae866..8d574679183fea3eb9217906b36c09cd2adac6a2 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServerLogger.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServerLogger.java @@ -261,10 +261,10 @@ final class CommonServerLogger extends AbstractServerLogger implements ICommonSe @Override public Map<String, List<IManagedInputWidgetDescription>> listManagedInputWidgetDescriptions( - String sessionToken, EntityType entityType) + String sessionToken, EntityKind entityKind, String entityTypeCode) { logAccess(sessionToken, "list_managed_input_widget_descriptions", "TYPE(%s)", - entityType.getCode()); + entityTypeCode); return null; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/EntityTypeTranslator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/EntityTypeTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..187dbe31800931324bc0496f8c378697f41ca7fb --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/EntityTypeTranslator.java @@ -0,0 +1,71 @@ +/* + * Copyright 2012 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.translator; + +import java.util.HashMap; +import java.util.Map; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; +import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePE; +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.PropertyTypePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SampleTypePE; +import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; + +/** + * @author pkupczyk + */ +public class EntityTypeTranslator +{ + + public static EntityType translate(EntityTypePE entityTypePE) + { + if (entityTypePE == null) + { + return null; + } + + Map<PropertyTypePE, PropertyType> cache = new HashMap<PropertyTypePE, PropertyType>(); + + switch (entityTypePE.getEntityKind()) + { + case EXPERIMENT: + ExperimentTypePE experimentTypePE = (ExperimentTypePE) entityTypePE; + HibernateUtils.initialize(experimentTypePE.getExperimentTypePropertyTypes()); + return ExperimentTypeTranslator.translate(experimentTypePE, cache); + case SAMPLE: + SampleTypePE sampleTypePE = (SampleTypePE) entityTypePE; + HibernateUtils.initialize(sampleTypePE.getSampleTypePropertyTypes()); + return SampleTypeTranslator.translate(sampleTypePE, cache); + case DATA_SET: + DataSetTypePE dataSetTypePE = (DataSetTypePE) entityTypePE; + HibernateUtils.initialize(dataSetTypePE.getDataSetTypePropertyTypes()); + return DataSetTypeTranslator.translate(dataSetTypePE, cache); + case MATERIAL: + MaterialTypePE materialTypePE = (MaterialTypePE) entityTypePE; + HibernateUtils.initialize(materialTypePE.getMaterialTypePropertyTypes()); + return MaterialTypeTranslator.translate(materialTypePE, cache); + default: + throw new IllegalArgumentException("Unsupported entity kind: " + + entityTypePE.getEntityKind()); + } + + } +}