From 801cc10d47187766a8bda4f4fe741be92c593feb Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Fri, 18 Apr 2014 13:46:30 +0000 Subject: [PATCH] SSDM-110: support link annotations - new api call SVN: 31397 --- .../api/v1/GeneralInformationService.java | 20 +++++++++++++++- .../v1/GeneralInformationServiceLogger.java | 8 +++++++ .../generic/shared/api/v1/Translator.java | 24 +++++++++++++++++++ .../openbis/public/resources/js/openbis.js | 14 +++++++++++ .../api/v1/IGeneralInformationService.java | 12 +++++++++- .../newbrowser/html/js/server/ServerFacade.js | 4 ++++ 6 files changed, 80 insertions(+), 2 deletions(-) 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 d14c4547822..7be13826f15 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,22 @@ 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) + throws ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException + { + 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)); + } + 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 247fdfdccc5..7d05a835d97 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; @@ -463,4 +464,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 84294c7eaba..2f3822bea5b 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,28 @@ 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) + { + PropertyTypeInitializer ptInitializer; + + boolean isControlledVocabulary = propertyType.getDataType().getCode() == DataTypeCode.CONTROLLEDVOCABULARY; + if (isControlledVocabulary) + { + ControlledVocabularyPropertyTypeInitializer cvptInitializer = new ControlledVocabularyPropertyTypeInitializer(); + + cvptInitializer.setVocabulary(propertyType.getVocabulary()); + cvptInitializer.setTerms(new ArrayList<ControlledVocabularyPropertyType.VocabularyTerm>()); + ptInitializer = cvptInitializer; + } else + { + ptInitializer = new PropertyTypeInitializer(); + } + ptInitializer.setDataType(propertyType.getDataType().getCode()); + ptInitializer.setCode(propertyType.getCode()); + ptInitializer.setLabel(propertyType.getLabel()); + ptInitializer.setDescription(propertyType.getDescription()); + + 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 20d4836efed..bdce310a0d4 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,20 @@ 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 051bda86848..406fb7f69cf 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,14 @@ 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 +524,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 6f4581a9976..75876be55b1 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 // -- GitLab