diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/ExperimentTypeModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/ExperimentTypeModel.java index cede272f56b9779475f5e1eb04601f8ddb34a7f9..e42e300f60acd9192b6e9fb408424d62b9f37e03 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/ExperimentTypeModel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/ExperimentTypeModel.java @@ -17,12 +17,16 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.model; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import com.extjs.gxt.ui.client.data.BaseModelData; import com.extjs.gxt.ui.client.data.ModelData; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentTypePropertyType; /** * {@link ModelData} for {@link ExperimentType}. @@ -40,14 +44,36 @@ public class ExperimentTypeModel extends BaseModelData set(ModelDataPropertyNames.OBJECT, experimentType); } - public final static List<ExperimentTypeModel> convert(final List<ExperimentType> experimentTypes) + public final static List<ExperimentTypeModel> convert( + final List<ExperimentType> experimentTypes, final boolean withAll) { final List<ExperimentTypeModel> result = new ArrayList<ExperimentTypeModel>(); for (final ExperimentType st : experimentTypes) { result.add(new ExperimentTypeModel(st)); } + if (withAll && experimentTypes.size() > 0) + { + result.add(0, createAllTypesModel(experimentTypes)); + } return result; } + private static ExperimentTypeModel createAllTypesModel(List<ExperimentType> basicTypes) + { + final ExperimentType allExperimentType = new ExperimentType(); + allExperimentType.setCode(EntityType.ALL_TYPES_CODE); + + Set<ExperimentTypePropertyType> allPropertyTypes = + new HashSet<ExperimentTypePropertyType>(); + for (ExperimentType basicType : basicTypes) + { + allPropertyTypes.addAll(basicType.getAssignedPropertyTypes()); + } + allExperimentType.setExperimentTypePropertyTypes(new ArrayList<ExperimentTypePropertyType>( + allPropertyTypes)); + + return new ExperimentTypeModel(allExperimentType); + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentBrowserToolbar.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentBrowserToolbar.java index fb839e7cd471727946a40d1512036513de8f6ada..4a4a43a9efc18da8f919ac6b3c927d1fefce35f6 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentBrowserToolbar.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentBrowserToolbar.java @@ -60,7 +60,7 @@ class ExperimentBrowserToolbar extends ToolBar implements ProjectSelectionTreeWidget tree) { this.viewContext = viewContext; - selectExperimentTypeCombo = new ExperimentTypeSelectionWidget(viewContext, ID); + selectExperimentTypeCombo = new ExperimentTypeSelectionWidget(viewContext, ID, true); selectProjectTree = tree; display(); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentTypeSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentTypeSelectionWidget.java index 0407d22881680100c6fc744497081f43157706f7..4db8b129df90be3a98b6c2483df029739f4706b4 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentTypeSelectionWidget.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ExperimentTypeSelectionWidget.java @@ -43,12 +43,23 @@ public final class ExperimentTypeSelectionWidget extends private final IViewContext<ICommonClientServiceAsync> viewContext; + private final boolean withAll; + public ExperimentTypeSelectionWidget(final IViewContext<ICommonClientServiceAsync> viewContext, - final String idSuffix) + final String idSuffix, final boolean withAll) { super(viewContext, SUFFIX + idSuffix, Dict.EXPERIMENT_TYPE, ModelDataPropertyNames.CODE, "experiment type", "experiment types"); this.viewContext = viewContext; + this.withAll = withAll; + // TODO 2009-06-22, Piotr Buczek: uncomment this to select all types by default + // setAutoSelectFirst(withAll); + } + + public ExperimentTypeSelectionWidget(final IViewContext<ICommonClientServiceAsync> viewContext, + final String idSuffix) + { + this(viewContext, idSuffix, false); } /** @@ -64,7 +75,7 @@ public final class ExperimentTypeSelectionWidget extends @Override protected List<ExperimentTypeModel> convertItems(List<ExperimentType> result) { - return ExperimentTypeModel.convert(result); + return ExperimentTypeModel.convert(result, withAll); } @Override @@ -72,7 +83,7 @@ public final class ExperimentTypeSelectionWidget extends { viewContext.getService().listExperimentTypes(callback); } - + public DatabaseModificationKind[] getRelevantModifications() { return DatabaseModificationKind.any(ObjectKind.EXPERIMENT_TYPE); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentTable.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentTable.java index 7a05d2eaf3bfdf2e7d01f53903446126b5a438fc..cc54bf3b20bfa10a0eb3cfbbbed67788b9878434 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentTable.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExperimentTable.java @@ -20,6 +20,7 @@ import java.util.List; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityType; import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentTypePE; @@ -50,18 +51,24 @@ public final class ExperimentTable extends AbstractBusinessObject implements IEx final ProjectIdentifier projectIdentifier) { checkNotNull(experimentTypeCode, projectIdentifier); - final EntityTypePE entityType = - getEntityTypeDAO(EntityKind.EXPERIMENT).tryToFindEntityTypeByCode( - experimentTypeCode); - checkNotNull(experimentTypeCode, entityType); fillGroupIdentifier(projectIdentifier); final ProjectPE project = getProjectDAO().tryFindProject(projectIdentifier.getDatabaseInstanceCode(), projectIdentifier.getGroupCode(), projectIdentifier.getProjectCode()); checkNotNull(projectIdentifier, project); - experiments = - getExperimentDAO().listExperimentsWithProperties((ExperimentTypePE) entityType, - project); + if (EntityType.isAllTypesCode(experimentTypeCode)) + { + experiments = getExperimentDAO().listExperimentsWithProperties(project); + } else + { + final EntityTypePE entityType = + getEntityTypeDAO(EntityKind.EXPERIMENT).tryToFindEntityTypeByCode( + experimentTypeCode); + checkNotNull(experimentTypeCode, entityType); + experiments = + getExperimentDAO().listExperimentsWithProperties((ExperimentTypePE) entityType, + project); + } } private void checkNotNull(final ProjectIdentifier projectIdentifier, final ProjectPE project) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IExperimentDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IExperimentDAO.java index a18b89b9478bc168e278ab77c176e5d7b5a95512..4632bf4a70cbee3fc1eb23115904fbe24c7c92f5 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IExperimentDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/IExperimentDAO.java @@ -31,6 +31,12 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; */ public interface IExperimentDAO extends IGenericDAO<ExperimentPE> { + /** + * Lists all belonging to given <code>project</code>. Fetches also properties. + */ + public List<ExperimentPE> listExperimentsWithProperties(final ProjectPE project) + throws DataAccessException; + /** * Lists all of given <code>type</code> belonging to given <code>project</code>. Fetches also * properties. diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExperimentDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExperimentDAO.java index bf8786cca8b914692134a5e5986c84b0b88d59b1..144527e11a9ddc7be7cc07a477e1921764c3a3f6 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExperimentDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/ExperimentDAO.java @@ -56,23 +56,32 @@ public class ExperimentDAO extends AbstractGenericEntityDAO<ExperimentPE> implem super(sessionFactory, databaseInstance, ExperimentPE.class); } - public List<ExperimentPE> listExperimentsWithProperties(final ExperimentTypePE experimentType, - final ProjectPE project) throws DataAccessException + public List<ExperimentPE> listExperimentsWithProperties(final ProjectPE project) + throws DataAccessException + { + return listExperimentsWithProperties(null, project); + } + + public List<ExperimentPE> listExperimentsWithProperties( + final ExperimentTypePE experimentTypeOrNull, final ProjectPE project) + throws DataAccessException { - assert experimentType != null : "Unspecified experiment type."; assert project != null : "Unspecified project."; final DetachedCriteria criteria = DetachedCriteria.forClass(getEntityClass()); - criteria.add(Restrictions.eq("experimentType", experimentType)); + if (experimentTypeOrNull != null) + { + criteria.add(Restrictions.eq("experimentType", experimentTypeOrNull)); + } criteria.add(Restrictions.eq("projectInternal", project)); criteria.setFetchMode("experimentProperties", FetchMode.JOIN); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); final List<ExperimentPE> list = cast(getHibernateTemplate().findByCriteria(criteria)); if (operationLog.isDebugEnabled()) { - operationLog.debug(String.format( - "%d experiments have been found for experiment type '%s' and project '%s'.", - list.size(), experimentType, project)); + operationLog.debug(String.format("%d experiments have been found for project '%s'%s.", + list.size(), project, (experimentTypeOrNull == null) ? "" + : " and experiment type '" + experimentTypeOrNull + "'")); } return list; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/EntityType.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/EntityType.java index 6e7d079ff723564a9b5c93c1b85c4a80d68a0d98..b4a83394f5c594e94251df16d5ccca1d60f63f60 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/EntityType.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/EntityType.java @@ -27,7 +27,7 @@ abstract public class EntityType extends BasicEntityType { private static final long serialVersionUID = ServiceVersionHolder.VERSION; - public static final String ALL_TYPES_CODE = "(ALL)"; + public static final String ALL_TYPES_CODE = "(all)"; abstract public List<? extends EntityTypePropertyType<?>> getAssignedPropertyTypes();