diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/AbstractEntityAdaptor.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/AbstractEntityAdaptor.java new file mode 100644 index 0000000000000000000000000000000000000000..d13dcd0e749d85deba8c9c0f8de76699d9d9cd55 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/AbstractEntityAdaptor.java @@ -0,0 +1,85 @@ +/* + * Copyright 2010 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.server.calculator.property; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import ch.systemsx.cisd.openbis.generic.shared.dto.EntityPropertyPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.IEntityPropertiesHolder; + +/** + * Abstract {@link IEntityAdaptor} implementation. + * + * @author Piotr Buczek + */ +public class AbstractEntityAdaptor implements IEntityAdaptor +{ + protected final Map<String, IEntityPropertyAdaptor> propertiesByCode = + new HashMap<String, IEntityPropertyAdaptor>(); + + private final String code; + + public AbstractEntityAdaptor(String code) + { + this.code = code; + } + + protected void initProperties(IEntityPropertiesHolder propertiesHolder) + { + for (EntityPropertyPE property : propertiesHolder.getProperties()) + { + final String propertyTypeCode = + property.getEntityTypePropertyType().getPropertyType().getCode(); + final String value; + if (property.getMaterialValue() != null) + { + value = property.getMaterialValue().getCode(); + } else if (property.getVocabularyTerm() != null) + { + value = property.getVocabularyTerm().getCode(); + } else + { + value = property.getValue(); + } + propertiesByCode.put(propertyTypeCode, new BasicPropertyAdaptor(propertyTypeCode, + value, property)); + } + } + + public String getCode() + { + return code; + } + + public IEntityPropertyAdaptor getPropertyByCode(String propertyTypeCode) + { + return propertiesByCode.get(propertyTypeCode); + } + + public String getPropertyValueByCode(String propertyTypeCode) + { + return propertiesByCode.get(propertyTypeCode).getValueAsString(); + } + + public Collection<IEntityPropertyAdaptor> getProperties() + { + return propertiesByCode.values(); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/BasicPropertyAdaptor.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/BasicPropertyAdaptor.java index f55503ee6ba36cf91f175001d6b1097f0f8d371b..05f107138192408bbcb9fb6829f568fe5531e028 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/BasicPropertyAdaptor.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/BasicPropertyAdaptor.java @@ -23,7 +23,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.EntityPropertyPE; * * @author Piotr Buczek */ -public class BasicPropertyAdaptor implements IEntityPropertyAdaptor +class BasicPropertyAdaptor implements IEntityPropertyAdaptor { private final String code; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/ExperimentAdaptor.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/ExperimentAdaptor.java new file mode 100644 index 0000000000000000000000000000000000000000..2e39019591ecbb0d252f95416a7d8caee22f7a4e --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/ExperimentAdaptor.java @@ -0,0 +1,42 @@ +/* + * Copyright 2010 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.server.calculator.property; + +import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; + +/** + * {@link IEntityAdaptor} implementation for {@link ExperimentPE}. + * + * @author Piotr Buczek + */ +public class ExperimentAdaptor extends AbstractEntityAdaptor +{ + private final ExperimentPE experimentPE; + + public ExperimentAdaptor(ExperimentPE experimentPE) + { + super(experimentPE.getCode()); + initProperties(experimentPE); + this.experimentPE = experimentPE; + } + + public ExperimentPE getExperimentPE() + { + return experimentPE; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/ExternalDataAdaptor.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/ExternalDataAdaptor.java new file mode 100644 index 0000000000000000000000000000000000000000..136315769d6eee291a45c7fbede8d3ccdd45b9d0 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/ExternalDataAdaptor.java @@ -0,0 +1,42 @@ +/* + * Copyright 2010 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.server.calculator.property; + +import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; + +/** + * {@link IEntityAdaptor} implementation for {@link ExternalDataPE}. + * + * @author Piotr Buczek + */ +public class ExternalDataAdaptor extends AbstractEntityAdaptor +{ + private final ExternalDataPE externalDataPE; + + public ExternalDataAdaptor(ExternalDataPE externalDataPE) + { + super(externalDataPE.getCode()); + initProperties(externalDataPE); + this.externalDataPE = externalDataPE; + } + + public ExternalDataPE getExternalDataPE() + { + return externalDataPE; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/MaterialAdaptor.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/MaterialAdaptor.java new file mode 100644 index 0000000000000000000000000000000000000000..2bc0ea95a27e5f787704633b22c719687ccf4655 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/MaterialAdaptor.java @@ -0,0 +1,42 @@ +/* + * Copyright 2010 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.server.calculator.property; + +import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialPE; + +/** + * {@link IEntityAdaptor} implementation for {@link MaterialPE}. + * + * @author Piotr Buczek + */ +public class MaterialAdaptor extends AbstractEntityAdaptor +{ + private final MaterialPE MaterialPE; + + public MaterialAdaptor(MaterialPE MaterialPE) + { + super(MaterialPE.getCode()); + initProperties(MaterialPE); + this.MaterialPE = MaterialPE; + } + + public MaterialPE getMaterialPE() + { + return MaterialPE; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/SampleAdaptor.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/SampleAdaptor.java index 1a8e04bcfc30f7deb0fc2a8ea74b4fc6c2da1993..e98da322ac34974c65f2c898f0a675ef13a1e15b 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/SampleAdaptor.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/calculator/property/SampleAdaptor.java @@ -16,49 +16,22 @@ package ch.systemsx.cisd.openbis.generic.client.web.server.calculator.property; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePropertyPE; /** * {@link IEntityAdaptor} implementation for {@link SamplePE}. * * @author Piotr Buczek */ -public class SampleAdaptor implements IEntityAdaptor +public class SampleAdaptor extends AbstractEntityAdaptor { - private final Map<String, IEntityPropertyAdaptor> propertiesByCode = - new HashMap<String, IEntityPropertyAdaptor>(); - - private final String code; - private final SamplePE samplePE; public SampleAdaptor(SamplePE samplePE) { + super(samplePE.getCode()); + initProperties(samplePE); this.samplePE = samplePE; - this.code = samplePE.getCode(); - for (SamplePropertyPE property : samplePE.getProperties()) - { - final String propertyTypeCode = - property.getEntityTypePropertyType().getPropertyType().getCode(); - final String value; - if (property.getMaterialValue() != null) - { - value = property.getMaterialValue().getCode(); - } else if (property.getVocabularyTerm() != null) - { - value = property.getVocabularyTerm().getCode(); - } else - { - value = property.getValue(); - } - propertiesByCode.put(propertyTypeCode, new BasicPropertyAdaptor(propertyTypeCode, - value, property)); - } } public SamplePE getSamplePE() @@ -66,24 +39,4 @@ public class SampleAdaptor implements IEntityAdaptor return samplePE; } - public String getCode() - { - return code; - } - - public IEntityPropertyAdaptor getPropertyByCode(String propertyTypeCode) - { - return propertiesByCode.get(propertyTypeCode); - } - - public String getPropertyValueByCode(String propertyTypeCode) - { - return propertiesByCode.get(propertyTypeCode).getValueAsString(); - } - - public Collection<IEntityPropertyAdaptor> getProperties() - { - return propertiesByCode.values(); - } - }