From 68508dcd52fed66a40d53705a68349ca531eaf32 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Fri, 13 Sep 2013 13:38:45 +0000 Subject: [PATCH] SP-866 / BIS-517 : ELN UI - Update Samples Call and fixes - Ongoing Work. SVN: 29769 --- .../v1/GeneralInformationChangingService.java | 45 +++++++++++++++-- ...neralInformationChangingServiceLogger.java | 12 +++++ .../openbis/public/resources/js/openbis.js | 48 ++++++++++++------- .../IGeneralInformationChangingService.java | 14 ++++++ 4 files changed, 98 insertions(+), 21 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingService.java index 6d18fbab78a..b28e26ce8f2 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingService.java @@ -236,8 +236,8 @@ public class GeneralInformationChangingService extends public IRequestContextProvider requestContextProvider; @Override - @Transactional(readOnly = false) - @RolesAllowed(RoleWithHierarchy.INSTANCE_OBSERVER) + @Transactional + @RolesAllowed(RoleWithHierarchy.SPACE_USER) public final boolean registerSamples( final String sessionToken, final String sampleTypeCode, @@ -340,7 +340,7 @@ public class GeneralInformationChangingService extends } - protected static UploadedFilesBean getUploadedFiles(String sessionKey, HttpSession session) + private static UploadedFilesBean getUploadedFiles(String sessionKey, HttpSession session) { if (session.getAttribute(sessionKey) == null || session.getAttribute(sessionKey) instanceof UploadedFilesBean == false) @@ -351,7 +351,7 @@ public class GeneralInformationChangingService extends return (UploadedFilesBean) session.getAttribute(sessionKey); } - protected static void cleanUploadedFiles(final String sessionKey, HttpSession session, + private static void cleanUploadedFiles(final String sessionKey, HttpSession session, UploadedFilesBean uploadedFiles) { if (uploadedFiles != null) @@ -393,7 +393,7 @@ public class GeneralInformationChangingService extends } } - protected final HttpSession getHttpSession() + private final HttpSession getHttpSession() { return getOrCreateHttpSession(false); } @@ -402,4 +402,39 @@ public class GeneralInformationChangingService extends { return requestContextProvider.getHttpServletRequest().getSession(create); } + + // + // <TEST IMPLEMENTATION For updateSamples> + // + @Override + @Transactional + @RolesAllowed(RoleWithHierarchy.SPACE_USER) + public final boolean updateSamples( + final String sessionToken, + final String sampleTypeCode, + final String sessionKey, + final String defaultGroupIdentifier) + { + List<ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType> sampleTypes = server.listSampleTypes(sessionToken); + ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType sampleType = null; + for (ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType auxSampleType : sampleTypes) + { + if (auxSampleType.getCode().equals(sampleTypeCode)) + { + sampleType = auxSampleType; + break; + } + } + + BatchSamplesOperation info = + parseSamples(sessionToken, sampleType, sessionKey, defaultGroupIdentifier, false, true, null, BatchOperationKind.UPDATE); + try + { + genericServer.updateSamples(sessionToken, info.getSamples()); + return true; + } catch (final ch.systemsx.cisd.common.exceptions.UserFailureException e) + { + throw UserFailureExceptionTranslator.translate(e); + } + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingServiceLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingServiceLogger.java index 19d7dc24a6a..fd819e517bf 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingServiceLogger.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingServiceLogger.java @@ -144,6 +144,18 @@ class GeneralInformationChangingServiceLogger extends AbstractServerLogger imple return false; } + @Override + public boolean updateSamples(String sessionToken, String sampleTypeCode, String sessionKey, String defaultGroupIdentifier) + { + logAccess(sessionToken, "updateSamples", + "sampleTypeCode(%s), sessionKey(%s), defaultGroupIdentifier(%s)", + sampleTypeCode, + sessionKey, + defaultGroupIdentifier); + + return false; + } + @Override public int getMajorVersion() { 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 c6af848a447..8ffe68e077f 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 @@ -1035,22 +1035,6 @@ openbis.prototype.listAttachmentsForSample = function(sampleId, allVersions, act * ========================================================================================== */ -/** - * @see IGeneralInformationChangingService.registerSamples(String, String, String, String) - * @method - */ -openbis.prototype.registerSamples = function(sampleTypeCode, sessionKey, defaultGroupIdentifier, action) { - this._internal.ajaxRequest({ - url: this._internal.generalInfoChangingServiceUrl, - data: { "method" : "registerSamples", - "params" : [ this.getSession(), - sampleTypeCode, - sessionKey, - defaultGroupIdentifier] }, - success: action - }); -} - /** * @see IGeneralInformationChangingService.updateSampleProperties(String, long, Map<String,String>) * @method @@ -1170,6 +1154,38 @@ openbis.prototype.removeFromMetaproject = function(metaprojectId, assignmentsToR }); } +/** + * @see IGeneralInformationChangingService.registerSamples(String, String, String, String) + * @method + */ +openbis.prototype.registerSamples = function(sampleTypeCode, sessionKey, defaultGroupIdentifier, action) { + this._internal.ajaxRequest({ + url: this._internal.generalInfoChangingServiceUrl, + data: { "method" : "registerSamples", + "params" : [ this.getSession(), + sampleTypeCode, + sessionKey, + defaultGroupIdentifier] }, + success: action + }); +} + +/** + * @see IGeneralInformationChangingService.registerSamples(String, String, String, String) + * @method + */ +openbis.prototype.updateSamples = function(sampleTypeCode, sessionKey, defaultGroupIdentifier, action) { + this._internal.ajaxRequest({ + url: this._internal.generalInfoChangingServiceUrl, + data: { "method" : "updateSamples", + "params" : [ this.getSession(), + sampleTypeCode, + sessionKey, + defaultGroupIdentifier] }, + success: action + }); +} + /** * ============================================================================ * ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.IQueryApiServer methods diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationChangingService.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationChangingService.java index 255360a46b0..d4867113801 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationChangingService.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationChangingService.java @@ -151,4 +151,18 @@ public interface IGeneralInformationChangingService extends IRpcService final String sampleTypeCode, final String sessionKey, final String defaultGroupIdentifier); + + /** + * Updates samples parsing a file stored on the HTTP Session. + * + * @param sampleTypeCode Sample type to parse + * @param sessionKey key of the file stored on the HTTP Session + * @param defaultGroupIdentifier key of the file stored on the HTTP Session + * @since 1.4 + */ + public boolean updateSamples( + final String sessionToken, + final String sampleTypeCode, + final String sessionKey, + final String defaultGroupIdentifier); } -- GitLab