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 d14c45478220d494dd7905d862b894b4b2145517..831579386e048b7111718dfe220afc76939a671d 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 @@ -141,7 +141,7 @@ import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; public class GeneralInformationService extends AbstractServer<IGeneralInformationService> implements IGeneralInformationService { - public static final int MINOR_VERSION = 25; + public static final int MINOR_VERSION = 26; @Resource(name = ch.systemsx.cisd.openbis.generic.shared.ResourceNames.COMMON_SERVER) private ICommonServer commonServer; @@ -1275,4 +1275,23 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio } return userSettings; } + + @Override + @Transactional(readOnly = true) + @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) + public List<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType> listPropertyTypes(String sessionToken, boolean withRelations) + { + HashMap<ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary, List<ControlledVocabularyPropertyType.VocabularyTerm>> vocabTerms = + getVocabularyTermsMap(sessionToken); + List<ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType> basic = commonServer.listPropertyTypes(sessionToken, withRelations); + + List<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType> api = + new ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType>(); + + for (ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType propertyType : basic) + { + api.add(Translator.translate(propertyType, vocabTerms)); + } + return api; + } } 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 247fdfdccc5ac4190edbb7bb608765330b48bc9a..d7a3828d8340a45a3e049d08797b152ed4aa1a70 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 @@ -40,6 +40,7 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Material; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.MaterialIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.MetaprojectAssignments; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Role; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleFetchOption; @@ -54,6 +55,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Metaproject; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; + /** * @author Franz-Josef Elmer */ @@ -463,4 +465,11 @@ class GeneralInformationServiceLogger extends AbstractServerLogger implements logAccess(sessionToken, "getUserDisplaySettings", "sessionToken(%s)", sessionToken); return null; } + + @Override + public List<PropertyType> listPropertyTypes(String sessionToken, boolean withRelations) + { + logAccess(sessionToken, "listPropertyTypes", "sessionToken(%s) withRelations(%s)", sessionToken, withRelations); + return null; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/Translator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/Translator.java index 84294c7eaba363f10145c10774ee31b5cf5602b8..67494af5adef06cfa7a86adfbd56bdace93b10fd 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/Translator.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/Translator.java @@ -776,4 +776,35 @@ public class Translator initializer.setDownloadLink(url.toString()); return new Attachment(initializer); } + + public static PropertyType translate(ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType propertyType, + HashMap<ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary, List<ControlledVocabularyPropertyType.VocabularyTerm>> vocabTerms) + { + PropertyTypeInitializer ptInitializer; + + boolean isControlledVocabulary = propertyType.getDataType().getCode() == DataTypeCode.CONTROLLEDVOCABULARY; + if (isControlledVocabulary) + { + ControlledVocabularyPropertyTypeInitializer cvptInitializer = new ControlledVocabularyPropertyTypeInitializer(); + + cvptInitializer.setVocabulary(propertyType.getVocabulary()); + cvptInitializer.setTerms(vocabTerms.get(propertyType.getVocabulary())); + ptInitializer = cvptInitializer; + } else + { + ptInitializer = new PropertyTypeInitializer(); + } + ptInitializer.setDataType(propertyType.getDataType().getCode()); + ptInitializer.setCode(propertyType.getCode()); + ptInitializer.setLabel(propertyType.getLabel()); + ptInitializer.setDescription(propertyType.getDescription()); + + if (isControlledVocabulary) + { + return new ControlledVocabularyPropertyType((ControlledVocabularyPropertyTypeInitializer) ptInitializer); + } else + { + return new PropertyType(ptInitializer); + } + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js/openbis.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js/openbis.js index 20d4836efed56980163b5c0745ff3aaa0803953a..bc7838e7128cffd4265b9c3cd050736340d000a9 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js/openbis.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js/openbis.js @@ -719,6 +719,21 @@ openbis.prototype.listVocabularies = function(action) { }); } +/** + * @see IGeneralInformationService.listPropertyTypes(String, boolean withRelations) + * @method + */ +openbis.prototype.listPropertyTypes = function(withRelations, action) { + this._internal.ajaxRequest({ + url: this._internal.generalInfoServiceUrl, + data: { "method" : "listPropertyTypes", + "params" : [ this.getSession() , withRelations] + }, + success: action + }); +} + + /** * @see IGeneralInformationService.listDataSets(String, List<Sample>, EnumSet<Connections>) * @method diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java index 051bda86848c808ded8b3bc17d40910032a59bff..ee1986b06d89800e3fc829f7953272f968b031f0 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java @@ -48,13 +48,15 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.id.experiment.IExperim import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.id.metaproject.IMetaprojectId; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.id.project.IProjectId; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.id.sample.ISampleId; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Metaproject; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary; + /** * Service for retrieving general informations. * - * @author Franz-Josef Elmer + * @author Franz Josef Elmer */ public interface IGeneralInformationService extends IRpcService { @@ -523,4 +525,13 @@ public interface IGeneralInformationService extends IRpcService boolean allVersions); public Map<String, String> getUserDisplaySettings(final String sessionToken); + + /** + * Lists property types. + * + * @param withRelations If <code>true</code>, return relations. + * @since 1.26 + */ + public List<PropertyType> listPropertyTypes(String sessionToken, boolean withRelations); } + diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js index 6f4581a9976d5522f7e3a22f7645ded6e6c8f941..2d1eb5e7e1c201aa5865be5773a55ab3227ac6a3 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js @@ -65,6 +65,10 @@ function ServerFacade(openbisServer) { this.openbisServer.listExperiments(projects, null, callbackFunction); } + this.listPropertyTypes = function(callbackFunction) { + this.openbisServer.listPropertyTypes(false, callbackFunction); + } + // // Data Set Related Functions // @@ -218,6 +222,7 @@ function ServerFacade(openbisServer) { { sampleOrId = samplesById[sampleOrId]; } + result[i] = sampleOrId; //Fill Parents if(sampleOrId.parents) {