diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/CommonExternalDataColDefKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/CommonExternalDataColDefKind.java new file mode 100644 index 0000000000000000000000000000000000000000..c6cbf8fc3e31cbcad20a35481dd57c02d5fb6976 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/CommonExternalDataColDefKind.java @@ -0,0 +1,179 @@ +/* + * Copyright 2009 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.client.web.client.application.ui.columns.specific.data; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.Dict; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractColumnDefinitionKind; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionKind; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.renderers.SimpleDateRenderer; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.renderers.SimpleYesNoRenderer; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExternalData; + +/** + * @author Franz-Josef Elmer + */ +public enum CommonExternalDataColDefKind implements IColumnDefinitionKind<ExternalData> +{ + CODE(new AbstractColumnDefinitionKind<ExternalData>(Dict.CODE) + { + @Override + public String tryGetValue(ExternalData entity) + { + return entity.getCode(); + } + }), + + PARENT_CODE(new AbstractColumnDefinitionKind<ExternalData>(Dict.PARENT_CODE, true) + { + @Override + public String tryGetValue(ExternalData entity) + { + return entity.getParentCode(); + } + }), + + PRODECUDRE_TYPE(new AbstractColumnDefinitionKind<ExternalData>(Dict.PROCEDURE_TYPE) + { + @Override + public String tryGetValue(ExternalData entity) + { + return entity.getProcedureType().getCode(); + } + }), + + SAMPLE_IDENTIFIER(new AbstractColumnDefinitionKind<ExternalData>(Dict.EXTERNAL_DATA_SAMPLE, + 200, false) + { + @Override + public String tryGetValue(ExternalData entity) + { + return entity.getSampleIdentifier(); + } + }), + + SAMPLE_TYPE(new AbstractColumnDefinitionKind<ExternalData>(Dict.SAMPLE_TYPE) + { + @Override + public String tryGetValue(ExternalData entity) + { + return entity.getSampleType().getCode(); + } + }), + + REGISTRATION_DATE(new AbstractColumnDefinitionKind<ExternalData>(Dict.REGISTRATION_DATE, 200, + false) + { + @Override + public String tryGetValue(ExternalData entity) + { + return renderRegistrationDate(entity); + } + }), + + IS_INVALID(new AbstractColumnDefinitionKind<ExternalData>(Dict.IS_INVALID, true) + { + @Override + public String tryGetValue(ExternalData entity) + { + return renderInvalidationFlag(entity); + } + }), + + IS_DERIVED(new AbstractColumnDefinitionKind<ExternalData>(Dict.IS_DERIVED, true) + { + @Override + public String tryGetValue(ExternalData entity) + { + return SimpleYesNoRenderer.render(entity.isDerived()); + } + }), + + IS_COMPLETE(new AbstractColumnDefinitionKind<ExternalData>(Dict.IS_COMPLETE, true) + { + @Override + public String tryGetValue(ExternalData entity) + { + Boolean complete = entity.getComplete(); + return complete == null ? "?" : SimpleYesNoRenderer.render(complete); + } + }), + + LOCATION(new AbstractColumnDefinitionKind<ExternalData>(Dict.LOCATION) + { + @Override + public String tryGetValue(ExternalData entity) + { + return entity.getLocation(); + } + }), + + FILE_FORMAT_TYPE(new AbstractColumnDefinitionKind<ExternalData>(Dict.FILE_FORMAT_TYPE, true) + { + @Override + public String tryGetValue(ExternalData entity) + { + return entity.getFileFormatType().getCode(); + } + }), + + DATA_SET_TYPE(new AbstractColumnDefinitionKind<ExternalData>(Dict.DATA_SET_TYPE, true) + { + @Override + public String tryGetValue(ExternalData entity) + { + return entity.getDataSetType().getCode(); + } + }), + + PRODUCTION_DATE(new AbstractColumnDefinitionKind<ExternalData>(Dict.PRODUCTION_DATE, 200, true) + { + @Override + public String tryGetValue(ExternalData entity) + { + return SimpleDateRenderer.renderDate(entity.getProductionDate()); + } + }), + + DATA_PRODUCER_CODE( + new AbstractColumnDefinitionKind<ExternalData>(Dict.DATA_PRODUCER_CODE, true) + { + @Override + public String tryGetValue(ExternalData entity) + { + return entity.getDataProducerCode(); + } + }); + + private final AbstractColumnDefinitionKind<ExternalData> columnDefinitionKind; + + private CommonExternalDataColDefKind( + AbstractColumnDefinitionKind<ExternalData> columnDefinitionKind) + { + this.columnDefinitionKind = columnDefinitionKind; + } + + public String id() + { + return name(); + } + + public AbstractColumnDefinitionKind<ExternalData> getDescriptor() + { + return columnDefinitionKind; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetExperimentPropertyColDef.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetExperimentPropertyColDef.java new file mode 100644 index 0000000000000000000000000000000000000000..bb5af8546576cd1f72076f983ec24bbd3ee8d239 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetExperimentPropertyColDef.java @@ -0,0 +1,54 @@ +/* + * Copyright 2009 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.client.web.client.application.ui.columns.specific.data; + +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractPropertyColDef; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DataSetSearchHit; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; + +public final class DataSetExperimentPropertyColDef extends + AbstractPropertyColDef<DataSetSearchHit> +{ + private static final String ID_PREFIX = "exp"; + + // GWT only + public DataSetExperimentPropertyColDef() + { + } + + public DataSetExperimentPropertyColDef(PropertyType propertyType, + boolean isDisplayedByDefault, int width, String propertyTypeLabel) + { + super(propertyType, isDisplayedByDefault, width, propertyTypeLabel, ID_PREFIX); + } + + @Override + protected List<? extends EntityProperty<?, ?>> getProperties(DataSetSearchHit entity) + { + return getExperimentProperties(entity); + } + + public static List<ExperimentProperty> getExperimentProperties(DataSetSearchHit entity) + { + return entity.getDataSet().getProcedure().getExperiment().getProperties(); + } + +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetSamplePropertyColDef.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetSamplePropertyColDef.java new file mode 100644 index 0000000000000000000000000000000000000000..ddff0ea4ef2d7778f27c46fc1fbb1ec1e5cdd501 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetSamplePropertyColDef.java @@ -0,0 +1,52 @@ +/* + * Copyright 2009 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.client.web.client.application.ui.columns.specific.data; + +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractPropertyColDef; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DataSetSearchHit; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleProperty; + +public final class DataSetSamplePropertyColDef extends AbstractPropertyColDef<DataSetSearchHit> +{ + private static final String ID_PREFIX = "sample"; + + // GWT only + public DataSetSamplePropertyColDef() + { + } + + public DataSetSamplePropertyColDef(PropertyType propertyType, boolean isDisplayedByDefault, int width, + String propertyTypeLabel) + { + super(propertyType, isDisplayedByDefault, width, propertyTypeLabel, ID_PREFIX); + } + + @Override + protected List<? extends EntityProperty<?, ?>> getProperties(DataSetSearchHit entity) + { + return getSampleProperties(entity); + } + + public static List<SampleProperty> getSampleProperties(DataSetSearchHit entity) + { + return entity.getDataSet().getSampleProperties(); + } +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetSearchHitColDefKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetSearchHitColDefKind.java new file mode 100644 index 0000000000000000000000000000000000000000..0cc001dc8b8207a30677322fa9c0dcb9a2c23f80 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/DataSetSearchHitColDefKind.java @@ -0,0 +1,218 @@ +/* + * Copyright 2009 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.client.web.client.application.ui.columns.specific.data; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.Dict; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractColumnDefinitionKind; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionKind; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DataSetSearchHit; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Experiment; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Procedure; + +/** + * Definition of data set search results table columns. + * + * @author Izabela Adamczyk + */ +public enum DataSetSearchHitColDefKind implements IColumnDefinitionKind<DataSetSearchHit> +{ + + CODE(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.CODE, 200) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + return entity.getDataSet().getCode(); + } + }), + + PARENT_CODE(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.PARENT_CODE, 200, true) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + return entity.getDataSet().getParentCode(); + } + }), + + LOCATION(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.LOCATION, 200) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + return entity.getDataSet().getLocation(); + } + }), + + DATA_SET_TYPE(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.DATA_SET_TYPE, 120) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + return entity.getDataSet().getDataSetType().getCode(); + } + }), + + FILE_TYPE(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.FILE_FORMAT_TYPE, 120) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + return entity.getDataSet().getFileFormatType().getCode(); + } + }), + + SAMPLE(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.SAMPLE, 100) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + return entity.getDataSet().getSampleCode(); + } + }), + + SAMPLE_IDENTIFIER(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.SAMPLE_IDENTIFIER, + true) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + return entity.getDataSet().getSampleIdentifier(); + } + }), + + SAMPLE_TYPE(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.SAMPLE_TYPE, 100) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + return entity.getDataSet().getSampleType().getCode(); + } + }), + + GROUP(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.GROUP, 100) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + final Experiment exp = tryGetExperiment(entity); + if (exp == null) + { + return null; + } + return exp.getProject().getGroup().getCode(); + } + }), + + PROJECT(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.PROJECT, 100) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + final Experiment exp = tryGetExperiment(entity); + if (exp == null) + { + return null; + } + return exp.getProject().getCode(); + } + }), + + EXPERIMENT(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.EXPERIMENT, 100) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + final Experiment exp = tryGetExperiment(entity); + if (exp == null) + { + return null; + } + return exp.getCode(); + } + }), + + EXPERIMENT_TYPE(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.EXPERIMENT_TYPE, 120) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + final Experiment experimentOrNull = tryGetExperiment(entity); + if (experimentOrNull == null) + { + return null; + } + return experimentOrNull.getExperimentType().getCode(); + } + + }), + + REGISTRATION_DATE(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.REGISTRATION_DATE, + 200, true) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + return renderRegistrationDate(entity.getDataSet()); + } + }), + + IS_INVALID(new AbstractColumnDefinitionKind<DataSetSearchHit>(Dict.IS_INVALID, 100, true) + { + @Override + public String tryGetValue(DataSetSearchHit entity) + { + return renderInvalidationFlag(entity.getDataSet()); + } + }), + + ; + + private final AbstractColumnDefinitionKind<DataSetSearchHit> columnDefinitionKind; + + private DataSetSearchHitColDefKind( + AbstractColumnDefinitionKind<DataSetSearchHit> columnDefinitionKind) + { + this.columnDefinitionKind = columnDefinitionKind; + } + + public String id() + { + return name(); + } + + public AbstractColumnDefinitionKind<DataSetSearchHit> getDescriptor() + { + return columnDefinitionKind; + } + + private static Experiment tryGetExperiment(DataSetSearchHit entity) + { + final Procedure procetureOrNull = tryGetProceture(entity); + if (procetureOrNull == null) + { + return null; + } + return procetureOrNull.getExperiment(); + } + + private static Procedure tryGetProceture(DataSetSearchHit entity) + { + return entity.getDataSet().getProcedure(); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/experiment/CommonExperimentColDefKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/experiment/CommonExperimentColDefKind.java new file mode 100644 index 0000000000000000000000000000000000000000..4c221ac3eaed4314b0a8c88842a770956bbe8d39 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/experiment/CommonExperimentColDefKind.java @@ -0,0 +1,130 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.columns.specific.experiment; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.Dict; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractColumnDefinitionKind; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionKind; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Experiment; + +/** + * Definition of experiment table columns. + * + * @author Tomasz Pylak + */ +public enum CommonExperimentColDefKind implements IColumnDefinitionKind<Experiment> +{ + CODE(new AbstractColumnDefinitionKind<Experiment>(Dict.CODE) + { + @Override + public String tryGetValue(Experiment entity) + { + return entity.getCode(); + } + }), + + EXPERIMENT_TYPE(new AbstractColumnDefinitionKind<Experiment>(Dict.EXPERIMENT_TYPE, true) + { + @Override + public String tryGetValue(Experiment entity) + { + return entity.getExperimentType().getCode(); + } + }), + + EXPERIMENT_IDENTIFIER(new AbstractColumnDefinitionKind<Experiment>(Dict.EXPERIMENT_IDENTIFIER, + 150, true) + { + @Override + public String tryGetValue(Experiment entity) + { + return entity.getIdentifier(); + } + }), + + DATABASE_INSTANCE(new AbstractColumnDefinitionKind<Experiment>(Dict.DATABASE_INSTANCE, true) + { + @Override + public String tryGetValue(Experiment entity) + { + return entity.getProject().getGroup().getInstance().getCode(); + } + }), + + GROUP(new AbstractColumnDefinitionKind<Experiment>(Dict.GROUP, true) + { + @Override + public String tryGetValue(Experiment entity) + { + return entity.getProject().getGroup().getCode(); + } + }), + + PROJECT(new AbstractColumnDefinitionKind<Experiment>(Dict.PROJECT, true) + { + @Override + public String tryGetValue(Experiment entity) + { + return entity.getProject().getCode(); + } + }), + + REGISTRATOR(new AbstractColumnDefinitionKind<Experiment>(Dict.REGISTRATOR) + { + @Override + public String tryGetValue(Experiment entity) + { + return renderRegistrator(entity); + } + }), + + REGISTRATION_DATE(new AbstractColumnDefinitionKind<Experiment>(Dict.REGISTRATION_DATE, 200, + false) + { + @Override + public String tryGetValue(Experiment entity) + { + return renderRegistrationDate(entity); + } + }), + + IS_INVALID(new AbstractColumnDefinitionKind<Experiment>(Dict.IS_INVALID, true) + { + @Override + public String tryGetValue(Experiment entity) + { + return renderInvalidationFlag(entity); + } + }); + + private final AbstractColumnDefinitionKind<Experiment> columnDefinitionKind; + + private CommonExperimentColDefKind(AbstractColumnDefinitionKind<Experiment> columnDefinitionKind) + { + this.columnDefinitionKind = columnDefinitionKind; + } + + public String id() + { + return name(); + } + + public AbstractColumnDefinitionKind<Experiment> getDescriptor() + { + return columnDefinitionKind; + } +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/experiment/PropertyExperimentColDef.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/experiment/PropertyExperimentColDef.java new file mode 100644 index 0000000000000000000000000000000000000000..a6d213ab8d14736250db09f4799c10d0d257fb4e --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/experiment/PropertyExperimentColDef.java @@ -0,0 +1,50 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.columns.specific.experiment; + +import java.util.List; + +import com.google.gwt.user.client.rpc.IsSerializable; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractPropertyColDef; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Experiment; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; + +/** + * @author Tomasz Pylak + */ +public class PropertyExperimentColDef extends AbstractPropertyColDef<Experiment> implements + IsSerializable +{ + // GWT only + public PropertyExperimentColDef() + { + super(null, false, 0, false, null, null); + } + + public PropertyExperimentColDef(PropertyType propertyType) + { + super(propertyType, true); + } + + @Override + protected List<? extends EntityProperty<?, ?>> getProperties(Experiment entity) + { + return entity.getProperties(); + } +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/AbstractParentSampleColDef.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/AbstractParentSampleColDef.java new file mode 100644 index 0000000000000000000000000000000000000000..8b227b0e85a4d9238969200e58ab459b96da69a5 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/AbstractParentSampleColDef.java @@ -0,0 +1,82 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.columns.specific.sample; + +import com.google.gwt.user.client.rpc.IsSerializable; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractColumnDefinition; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractColumnDefinitionKind; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; + +abstract class AbstractParentSampleColDef extends AbstractColumnDefinition<Sample> implements + IsSerializable +{ + abstract protected Sample tryGetParent(Sample sample); + + abstract protected String getIdentifierPrefix(); + + private static final String IDENTIFIER_SEPARATOR = "/"; + + private int/* the level which should be shown */level; + + AbstractParentSampleColDef(int level, String headerText) + { + super(headerText, AbstractColumnDefinitionKind.DEFAULT_COLUMN_WIDTH, false); + this.level = level; + } + + @Override + protected String tryGetValue(Sample sample) + { + Sample parent = tryGetParentSample(sample); + if (parent != null) + { + return printShortIdentifier(parent); + } else + { + return null; + } + } + + public String getIdentifier() + { + return getIdentifierPrefix() + level; + } + + private final Sample tryGetParentSample(final Sample sample) + { + Sample parent = sample; + int depth = level; + while (depth > 0 && parent != null) + { + parent = tryGetParent(parent); + depth--; + } + return parent; + } + + private final static String printShortIdentifier(final Sample sample) + { + if (sample.getDatabaseInstance() != null) + { + return IDENTIFIER_SEPARATOR + sample.getCode(); + } else + { + return sample.getCode(); + } + } +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/CommonSampleColDefKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/CommonSampleColDefKind.java new file mode 100644 index 0000000000000000000000000000000000000000..6a97c961d5eef6612cb95e7d91724a9ec412b00d --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/CommonSampleColDefKind.java @@ -0,0 +1,168 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.columns.specific.sample; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.Dict; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractColumnDefinitionKind; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionKind; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.renderers.SimpleYesNoRenderer; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Experiment; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Group; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Procedure; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseInstance; + +public enum CommonSampleColDefKind implements IColumnDefinitionKind<Sample> +{ + DATABASE_INSTANCE(new AbstractColumnDefinitionKind<Sample>(Dict.DATABASE_INSTANCE, true) + { + @Override + public String tryGetValue(Sample entity) + { + DatabaseInstance databaseInstance = entity.getDatabaseInstance(); + if (databaseInstance == null) + { + databaseInstance = entity.getGroup().getInstance(); + } + return databaseInstance.getCode(); + } + }), + + GROUP(new AbstractColumnDefinitionKind<Sample>(Dict.GROUP, true) + { + @Override + public String tryGetValue(Sample entity) + { + final Group group = entity.getGroup(); + return group == null ? "" : group.getCode(); + } + }), + + CODE(new AbstractColumnDefinitionKind<Sample>(Dict.CODE) + { + @Override + public String tryGetValue(Sample entity) + { + return entity.getCode(); + } + }), + + SAMPLE_IDENTIFIER(new AbstractColumnDefinitionKind<Sample>(Dict.SAMPLE_IDENTIFIER, 150, true) + { + @Override + public String tryGetValue(Sample entity) + { + return entity.getIdentifier(); + } + }), + + IS_INSTANCE_SAMPLE(new AbstractColumnDefinitionKind<Sample>(Dict.IS_INSTANCE_SAMPLE, true) + { + @Override + public String tryGetValue(Sample entity) + { + return SimpleYesNoRenderer.render(entity.getDatabaseInstance() != null); + } + }), + + IS_INVALID(new AbstractColumnDefinitionKind<Sample>(Dict.IS_INVALID, true) + { + @Override + public String tryGetValue(Sample entity) + { + return renderInvalidationFlag(entity); + } + }), + + EXPERIMENT(new AbstractColumnDefinitionKind<Sample>(Dict.EXPERIMENT) + { + @Override + public String tryGetValue(Sample entity) + { + final Experiment exp = tryToGetExperiment(entity); + return exp == null ? null : exp.getCode(); + } + }), + + EXPERIMENT_IDENTIFIER(new AbstractColumnDefinitionKind<Sample>(Dict.EXPERIMENT_IDENTIFIER, 200, + true) + { + @Override + public String tryGetValue(Sample entity) + { + final Experiment exp = tryToGetExperiment(entity); + return exp == null ? null : exp.getIdentifier(); + } + }), + + PROJECT(new AbstractColumnDefinitionKind<Sample>(Dict.PROJECT) + { + @Override + public String tryGetValue(Sample entity) + { + final Experiment exp = tryToGetExperiment(entity); + return exp == null ? null : exp.getProject().getCode(); + } + }), + + REGISTRATOR(new AbstractColumnDefinitionKind<Sample>(Dict.REGISTRATOR) + { + @Override + public String tryGetValue(Sample entity) + { + return renderRegistrator(entity); + } + }), + + REGISTRATION_DATE(new AbstractColumnDefinitionKind<Sample>(Dict.REGISTRATION_DATE, + AbstractColumnDefinitionKind.DATE_COLUMN_WIDTH) + { + @Override + public String tryGetValue(Sample entity) + { + return renderRegistrationDate(entity); + } + }); + + private final AbstractColumnDefinitionKind<Sample> columnDefinitionKind; + + private CommonSampleColDefKind(AbstractColumnDefinitionKind<Sample> columnDefinitionKind) + { + this.columnDefinitionKind = columnDefinitionKind; + } + + public String id() + { + return name(); + } + + public AbstractColumnDefinitionKind<Sample> getDescriptor() + { + return columnDefinitionKind; + } + + private final static Experiment tryToGetExperiment(final Sample sample) + { + final Procedure procedure = sample.getValidProcedure(); + if (procedure != null) + { + return procedure.getExperiment(); + } + return null; + } + +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/ParentContainerSampleColDef.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/ParentContainerSampleColDef.java new file mode 100644 index 0000000000000000000000000000000000000000..d1b636646a573af1eb7dfdc69d30a8e339c03f52 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/ParentContainerSampleColDef.java @@ -0,0 +1,50 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.columns.specific.sample; + +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; + +/** + * @author Izabela Adamczyk + */ +public class ParentContainerSampleColDef extends AbstractParentSampleColDef +{ + private static final String PARENT_PREFIX = "containerParent"; + + // GWT only + public ParentContainerSampleColDef() + { + super(0, null); + } + + public ParentContainerSampleColDef(int level, String headerText) + { + super(level, headerText); + } + + @Override + protected String getIdentifierPrefix() + { + return PARENT_PREFIX; + } + + @Override + protected Sample tryGetParent(Sample sample) + { + return sample.getContainer(); + } +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/ParentGeneratedFromSampleColDef.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/ParentGeneratedFromSampleColDef.java new file mode 100644 index 0000000000000000000000000000000000000000..9325fb2e619099203275202d3c8b81979005be86 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/ParentGeneratedFromSampleColDef.java @@ -0,0 +1,47 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.columns.specific.sample; + +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; + +public class ParentGeneratedFromSampleColDef extends AbstractParentSampleColDef +{ + private static final String PARENT_PREFIX = "generatedFromParent"; + + // GWT only + public ParentGeneratedFromSampleColDef() + { + super(0, null); + } + + public ParentGeneratedFromSampleColDef(int level, String headerText) + { + super(level, headerText); + } + + @Override + protected String getIdentifierPrefix() + { + return PARENT_PREFIX; + } + + @Override + protected Sample tryGetParent(Sample sample) + { + return sample.getGeneratedFrom(); + } +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/PropertySampleColDef.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/PropertySampleColDef.java new file mode 100644 index 0000000000000000000000000000000000000000..e749199636a16697c4879ea50443645e44c6c57a --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/sample/PropertySampleColDef.java @@ -0,0 +1,46 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.columns.specific.sample; + +import java.util.List; + +import com.google.gwt.user.client.rpc.IsSerializable; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractPropertyColDef; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; + +public class PropertySampleColDef extends AbstractPropertyColDef<Sample> implements IsSerializable +{ + // GWT only + public PropertySampleColDef() + { + super(null, false, 0, false, null, null); + } + + public PropertySampleColDef(PropertyType propertyType, boolean isDisplayedByDefault) + { + super(propertyType, isDisplayedByDefault); + } + + @Override + protected List<? extends EntityProperty<?, ?>> getProperties(Sample entity) + { + return entity.getProperties(); + } +} \ No newline at end of file