diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java index ef4251f3f26f50b17244a2dfe56342fe88496f5b..4ef7ff32f79551c1c11c2ca963994c61fc2276d8 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java @@ -42,6 +42,7 @@ import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExternalDataDAO; import ch.systemsx.cisd.openbis.generic.shared.ICommonServer; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Role; @@ -159,7 +160,7 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio public int getMinorVersion() { - return 3; + return 5; } private Map<String, List<RoleAssignmentPE>> getRoleAssignmentsPerSpace() @@ -247,7 +248,8 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio return samples; } - public List<Sample> listSamplesForExperiment(String sessionToken, String experimentIdentifierString) + public List<Sample> listSamplesForExperiment(String sessionToken, + String experimentIdentifierString) { checkSession(sessionToken); ExperimentIdentifier experimentId = @@ -367,4 +369,10 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio return data.getDataStore().getDownloadUrl(); } + + public List<DataSetType> listDataSetTypes(String sessionToken) + { + // TODO Auto-generated method stub + return new ArrayList<DataSetType>(); + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationServiceLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationServiceLogger.java index 962b949228111cf959360bff4dce94e754f1d45b..5a142d637fa220f7e80bf40b975f13aaa68ea008 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationServiceLogger.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationServiceLogger.java @@ -25,6 +25,7 @@ import ch.systemsx.cisd.common.spring.IInvocationLoggerContext; import ch.systemsx.cisd.openbis.generic.shared.AbstractServerLogger; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Role; @@ -117,4 +118,10 @@ class GeneralInformationServiceLogger extends AbstractServerLogger implements return null; } + public List<DataSetType> listDataSetTypes(String sessionToken) + { + logAccess(sessionToken, "list-data-set-types"); + return null; + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java index dab82b9dc3269fdc64613adf2780824ca8989d88..4f262eb34c3a40a3af2b5a896a855a0059509d38 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java @@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional; import ch.systemsx.cisd.common.api.IRpcService; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Role; @@ -161,4 +162,14 @@ public interface IGeneralInformationService extends IRpcService { RoleWithHierarchy.SPACE_OBSERVER, RoleWithHierarchy.SPACE_ETL_SERVER }) public String tryGetDataStoreBaseURL(String sessionToken, String dataSetCode); + /** + * Returns the URL for the default data store server for this openBIS AS. Available since minor + * version 5. + * + * @since 1.5 + */ + @Transactional(readOnly = true) + @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) + public List<DataSetType> listDataSetTypes(String sessionToken); + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSetType.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSetType.java new file mode 100644 index 0000000000000000000000000000000000000000..5059eac4205d5b5a207b5c229970932440fd823c --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSetType.java @@ -0,0 +1,142 @@ +/* + * 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.shared.api.v1.dto; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +/** + * Immutable value object representing a data set type. + * + * @author Chandrasekhar Ramakrishnan + */ +public final class DataSetType implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** + * Class used to initialize a new data set instance. Necessary since all the fields of a DataSet + * are final. + * + * @author Chandrasekhar Ramakrishnan + */ + public static final class DataSetTypeInitializer + { + private String code; + + private ArrayList<PropertyType> propertyTypes = new ArrayList<PropertyType>(); + + public String getCode() + { + return code; + } + + public void setCode(String code) + { + this.code = code; + } + + public ArrayList<PropertyType> getPropertyTypes() + { + return propertyTypes; + } + + public void addPropertyType(PropertyType propertyType) + { + propertyTypes.add(propertyType); + } + } + + private final String code; + + private final ArrayList<PropertyType> propertyTypes; + + /** + * Creates a new instance with the provided initializer + * + * @throws IllegalArgumentException if some of the required information is not provided. + */ + public DataSetType(DataSetTypeInitializer initializer) + { + checkValidString(initializer.getCode(), "Unspecified code."); + this.code = initializer.getCode(); + + this.propertyTypes = initializer.getPropertyTypes(); + } + + private void checkValidString(String string, String message) throws IllegalArgumentException + { + if (string == null || string.length() == 0) + { + throw new IllegalArgumentException(message); + } + } + + /** + * Returns the sample code; + */ + public String getCode() + { + return code; + } + + public List<PropertyType> getPropertyTypes() + { + return propertyTypes; + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + if (obj instanceof DataSetType == false) + { + return false; + } + + EqualsBuilder builder = new EqualsBuilder(); + DataSetType other = (DataSetType) obj; + builder.append(getCode(), other.getCode()); + return builder.isEquals(); + } + + @Override + public int hashCode() + { + HashCodeBuilder builder = new HashCodeBuilder(); + builder.append(getCode()); + return builder.toHashCode(); + } + + @Override + public String toString() + { + ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); + builder.append(getCode()); + builder.append(getPropertyTypes()); + return builder.toString(); + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/PropertyType.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/PropertyType.java new file mode 100644 index 0000000000000000000000000000000000000000..f7d9014220f1642d05fb7bca75362f087c25e8d2 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/PropertyType.java @@ -0,0 +1,164 @@ +/* + * 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.shared.api.v1.dto; + +import java.io.Serializable; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +/** + * Immutable value object representing a property type. + * + * @author Chandrasekhar Ramakrishnan + */ +public final class PropertyType implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** + * Class used to initialize a new data set instance. Necessary since all the fields of a DataSet + * are final. + * + * @author Chandrasekhar Ramakrishnan + */ + public static final class PropertyTypeInitializer + { + private String code; + + private String label; + + private String description; + + public String getCode() + { + return code; + } + + public void setCode(String code) + { + this.code = code; + } + + public String getLabel() + { + return label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } + + } + + private final String code; + + private final String label; + + private final String description; + + /** + * Creates a new instance with the provided initializer + * + * @throws IllegalArgumentException if some of the required information is not provided. + */ + public PropertyType(PropertyTypeInitializer initializer) + { + checkValidString(initializer.getCode(), "Unspecified code."); + this.code = initializer.getCode(); + + checkValidString(initializer.getLabel(), "Unspecified label."); + this.label = initializer.getLabel(); + + this.description = initializer.getDescription(); + } + + private void checkValidString(String string, String message) throws IllegalArgumentException + { + if (string == null || string.length() == 0) + { + throw new IllegalArgumentException(message); + } + } + + /** + * Returns the sample code; + */ + public String getCode() + { + return code; + } + + public String getLabel() + { + return label; + } + + public String getDescription() + { + return description; + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + if (obj instanceof PropertyType == false) + { + return false; + } + + EqualsBuilder builder = new EqualsBuilder(); + PropertyType other = (PropertyType) obj; + builder.append(getCode(), other.getCode()); + return builder.isEquals(); + } + + @Override + public int hashCode() + { + HashCodeBuilder builder = new HashCodeBuilder(); + builder.append(getCode()); + return builder.toHashCode(); + } + + @Override + public String toString() + { + ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); + builder.append(getCode()); + builder.append(getLabel()); + builder.append(getDescription()); + return builder.toString(); + } +} diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSetTypeTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSetTypeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a96f1c84fef1fd6863022d6eda2f44e1a38af4c6 --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSetTypeTest.java @@ -0,0 +1,107 @@ +/* + * 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.shared.api.v1.dto; + +import org.testng.AssertJUnit; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType.DataSetTypeInitializer; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType.PropertyTypeInitializer; + +/** + * @author Chandrasekhar Ramakrishnan + */ +public class DataSetTypeTest extends AssertJUnit +{ + private static final String DATA_SET_TYPE_CODE = "dataSet-type"; + + private DataSetType dataSetType; + + @BeforeMethod + public void setUp() + { + DataSetTypeInitializer initializer = new DataSetTypeInitializer(); + initializer.setCode(DATA_SET_TYPE_CODE); + + PropertyTypeInitializer propTypeInitializer = new PropertyTypeInitializer(); + propTypeInitializer.setCode("PROP1"); + propTypeInitializer.setLabel("Property 1"); + initializer.addPropertyType(new PropertyType(propTypeInitializer)); + + propTypeInitializer.setCode("PROP2"); + propTypeInitializer.setLabel("Property 2"); + propTypeInitializer.setDescription("Property 2 Description"); + + initializer.addPropertyType(new PropertyType(propTypeInitializer)); + dataSetType = new DataSetType(initializer); + } + + @Test(expectedExceptions = + { IllegalArgumentException.class }) + public void testInitialization() + { + DataSetTypeInitializer initializer = new DataSetTypeInitializer(); + new DataSetType(initializer); + } + + @Test + public void testEquals() + { + DataSetTypeInitializer initializer = new DataSetTypeInitializer(); + initializer.setCode(DATA_SET_TYPE_CODE); + PropertyTypeInitializer propTypeInitializer = new PropertyTypeInitializer(); + propTypeInitializer.setCode("PROP200"); + propTypeInitializer.setLabel("Property 200"); + initializer.addPropertyType(new PropertyType(propTypeInitializer)); + + DataSetType myDataSetType = new DataSetType(initializer); + assertTrue("Data sets with the same code should be equal.", + dataSetType.equals(myDataSetType)); + assertEquals(dataSetType.hashCode(), myDataSetType.hashCode()); + + initializer = new DataSetTypeInitializer(); + initializer.setCode(DATA_SET_TYPE_CODE); + myDataSetType = new DataSetType(initializer); + assertTrue("Data sets with the same code should be equal.", + dataSetType.equals(myDataSetType)); + assertEquals(dataSetType.hashCode(), myDataSetType.hashCode()); + + initializer = new DataSetTypeInitializer(); + initializer.setCode("code-2"); + propTypeInitializer = new PropertyTypeInitializer(); + propTypeInitializer.setCode("PROP1"); + propTypeInitializer.setLabel("Property 1"); + initializer.addPropertyType(new PropertyType(propTypeInitializer)); + + propTypeInitializer.setCode("PROP2"); + propTypeInitializer.setLabel("Property 2"); + propTypeInitializer.setDescription("Property 2 Description"); + myDataSetType = new DataSetType(initializer); + assertFalse("Data sets with the different ids should not be equal.", + dataSetType.equals(myDataSetType)); + } + + @Test + public void testToString() + { + String stringRepresentation = dataSetType.toString(); + assertEquals( + "DataSetType[dataSet-type,[PropertyType[PROP1,Property 1,<null>], PropertyType[PROP2,Property 2,Property 2 Description]]]", + stringRepresentation); + } +}