diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/as/initialize-master-data.py b/core-plugin-openbis/dist/core-plugins/imaging/1/as/initialize-master-data.py deleted file mode 100644 index e1ed0ce1fa3d472f8da523901244a6565f68343d..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/as/initialize-master-data.py +++ /dev/null @@ -1,73 +0,0 @@ -# -# Copyright 2014 ETH Zuerich, Scientific IT Services -# -# 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. -# -# MasterDataRegistrationTransaction Class -from ch.ethz.sis.openbis.generic.server.asapi.v3 import ApplicationServerApi -from ch.systemsx.cisd.openbis.generic.server import CommonServiceProvider -from ch.ethz.sis.openbis.generic.asapi.v3.dto.service.id import CustomASServiceCode -from ch.ethz.sis.openbis.generic.asapi.v3.dto.service import CustomASServiceExecutionOptions -from ch.systemsx.cisd.openbis.generic.server.jython.api.v1.impl import MasterDataRegistrationHelper -import sys - -helper = MasterDataRegistrationHelper(sys.path) -api = CommonServiceProvider.getApplicationContext().getBean(ApplicationServerApi.INTERNAL_SERVICE_NAME) -sessionToken = api.loginAsSystem() -props = CustomASServiceExecutionOptions().withParameter('xls', helper.listXlsByteArrays()) \ - .withParameter('method', 'import').withParameter('zip', False).withParameter('xls_name', 'IMAGING').withParameter('update_mode', 'UPDATE_IF_EXISTS') \ - .withParameter('scripts', helper.getAllScripts()) -result = api.executeCustomASService(sessionToken, CustomASServiceCode("xls-import"), props) -api.logout(sessionToken) -print("======================== imaging-master-data xls ingestion result ========================") -print(result) -print("======================== imaging-data xls ingestion result ========================") - - - -# from ch.ethz.sis.openbis.generic.server.asapi.v3 import ApplicationServerApi -# from ch.systemsx.cisd.openbis.generic.server import CommonServiceProvider -# from ch.ethz.sis.openbis.generic.asapi.v3.dto.service.id import CustomASServiceCode -# from ch.ethz.sis.openbis.generic.asapi.v3.dto.service import CustomASServiceExecutionOptions -# from ch.systemsx.cisd.openbis.generic.server.jython.api.v1.impl import MasterDataRegistrationHelper -# import sys -# -# from ch.systemsx.cisd.openbis.generic.server.hotfix import ELNFixes -# from ch.systemsx.cisd.openbis.generic.server.hotfix import ELNAnnotationsMigration -# from ch.systemsx.cisd.openbis.generic.server.hotfix import ELNCollectionTypeMigration -# -# api = CommonServiceProvider.getApplicationContext().getBean(ApplicationServerApi.INTERNAL_SERVICE_NAME) -# sessionToken = api.loginAsSystem() -# -# if ELNFixes.isELNInstalled(): -# ELNFixes.beforeUpgrade(sessionToken) -# ELNAnnotationsMigration.beforeUpgrade(sessionToken) -# ELNCollectionTypeMigration.beforeUpgrade(sessionToken) -# -# helper = MasterDataRegistrationHelper(sys.path) -# props = CustomASServiceExecutionOptions().withParameter('xls', helper.getByteArray("common-data-model.xls"))\ -# .withParameter('method', 'import').withParameter('zip', False).withParameter('xls_name', 'ELN-LIMS').withParameter('update_mode', 'UPDATE_IF_EXISTS')\ -# .withParameter('scripts', helper.getAllScripts()) -# result = api.executeCustomASService(sessionToken, CustomASServiceCode("xls-import"), props) -# -# if not ELNFixes.isMultiGroup(): -# props = CustomASServiceExecutionOptions().withParameter('xls', helper.getByteArray("single-group-data-model.xls"))\ -# .withParameter('method', 'import').withParameter('zip', False).withParameter('xls_name', 'ELN-LIMS').withParameter('update_mode', 'UPDATE_IF_EXISTS')\ -# .withParameter('scripts', helper.getAllScripts()) -# result = api.executeCustomASService(sessionToken, CustomASServiceCode("xls-import"), props) -# -# ELNCollectionTypeMigration.afterUpgrade() -# api.logout(sessionToken) -# print("======================== master-data xls ingestion result ========================") -# print(result) -# print("======================== master-data xls ingestion result ========================") diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/as/master-data/imaging-data-model.xls b/core-plugin-openbis/dist/core-plugins/imaging/1/as/master-data/imaging-data-model.xls deleted file mode 100644 index 8f88765f4618a3462bf4118c977d56eb9f621c5d..0000000000000000000000000000000000000000 Binary files a/core-plugin-openbis/dist/core-plugins/imaging/1/as/master-data/imaging-data-model.xls and /dev/null differ diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/as/master-data/scripts/imaging_dataset_config_validation.py b/core-plugin-openbis/dist/core-plugins/imaging/1/as/master-data/scripts/imaging_dataset_config_validation.py deleted file mode 100644 index 6766c2ff21171002a28224386024fbd241407c28..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/as/master-data/scripts/imaging_dataset_config_validation.py +++ /dev/null @@ -1,182 +0,0 @@ -# Copyright ETH 2023 Zürich, Scientific IT Services -# -# 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. -# - -import json - - -def assert_control(control_config): - if not control_config: - return True, '' - obligatory_tags = ['@type', 'label', 'type'] - for tag in obligatory_tags: - if tag not in control_config: - return False, tag+': is missing!' - if control_config[tag] is None: - return False, tag+': can not be empty!' - - list_tags = ['values', 'range', 'speeds', 'visibility'] - for list_tag in list_tags: - if list_tag in control_config and control_config[list_tag] is not None and not isinstance(control_config[list_tag], list): - return False, list_tag+': must be a list or null!' - - boolean_tags = ['playable', 'multiselect'] - for boolean_tag in boolean_tags: - if boolean_tag in control_config and control_config[boolean_tag] is not None and not isinstance(control_config[boolean_tag], bool): - return False, boolean_tag+': must be a boolean or empty!' - - if 'visibility' in control_config and control_config['visibility'] is not None: - visibility = control_config['visibility'] - for vis in visibility: - tags = ['label', 'values'] - all_tags = tags + ['range', 'unit'] - for tag in ['label', 'values']: - if tag not in vis: - return False, 'visibility->'+tag+': is missing!' - if vis[tag] is None: - return False, 'visibility->'+tag+': can not be empty!' - - for tag in ['values', 'range']: - if tag in vis and vis[tag] is not None and not isinstance(vis[tag], list): - return False, 'visibility->'+tag+': must be a list!' - - if 'metadata' in control_config and control_config['metadata'] is not None and not isinstance(control_config['metadata'], dict): - return False, '->metadata: must be a dictionary or null!' - - return True, '' - - -def assert_config(json_config): - if 'config' in json_config: - config = json_config['config'] - obligatory_tags = ['@type', 'adaptor', 'version', 'playable', 'exports', 'inputs'] - for tag in obligatory_tags: - if tag not in config: - return False, 'config->' + tag + ': is missing!' - if config[tag] is None: - return False, 'config->' + tag + ': can not be empty!' - - if config['adaptor'].strip() == '': - return False, 'config->adaptor: can not be blank!' - - list_tags = ['speeds', 'resolutions', 'exports', 'inputs'] - for list_tag in list_tags: - if list_tag in config and config[list_tag] is not None and not isinstance(config[list_tag], list): - return False, '\''+list_tag+'\' must be a list or null!' - - if not isinstance(config['playable'], bool): - return False, 'config->playable: must be a boolean!' - - for control in config['exports']: - result, err = assert_control(control) - if not result: - return result, 'config->exports->' + err - - for control in config['inputs']: - result, err = assert_control(control) - if not result: - return result, 'config->inputs->' + err - - if 'metadata' in config and config['metadata'] is not None and not isinstance(config['metadata'], dict): - return False, 'config->metadata: must be a dictionary or null!' - else: - return False, 'Missing \'config\' tag in configuration!' - return True, '' - - -def assert_preview(preview_config): - obligatory_tags = ['@type', 'format', 'show'] - for tag in obligatory_tags: - if tag not in config: - return False, tag + ': is missing!' - if config[tag] is None: - return False, tag + ': can not be empty!' - - if not isinstance(preview_config['show'], bool): - return False, 'show: must be boolean!' - - if not isinstance(preview_config['format'], str): - return False, 'format: must be string!' - - if 'bytes' in preview_config and preview_config['bytes'] is not None and not isinstance(preview_config['bytes'], str): - return False, 'bytes: must be a base64 encoded string or null!' - - if 'metadata' in preview_config and preview_config['metadata'] is not None and not isinstance(preview_config['metadata'], dict): - return False, 'metadata: must be a dictionary or null!' - - if 'config' in preview_config and preview_config['config'] is not None and not isinstance(preview_config['config'], dict): - return False, 'config: must be a dictionary or null!' - - return True, '' - - -def assert_images(json_config): - if 'images' in json_config: - images = json_config['images'] - if images is None: - return False, '\'images\' tag can not be null!' - if not isinstance(images, list): - return False, '\'images\' tag must be a list!' - - for image in images: - obligatory_tags = ['@type'] - for tag in obligatory_tags: - if tag not in image: - return False, 'images->' + tag + ': missing tag!' - if image[tag] is None: - return False, 'images->' + tag + ': can not be empty!' - - if 'metadata' in image and image['metadata'] is not None and not isinstance(image['metadata'], dict): - return False, 'images->metadata: must be a dictionary or null!' - - if 'previews' in image and image['previews'] is not None and not isinstance(image['previews'], list): - return False, 'images->previews: must be a list or null!' - - for preview in image['previews']: - res, err = assert_preview(preview) - if not res: - return result, 'images->previews->' + err - - else: - return False, 'Missing \'images\' tag in configuration!' - return True, '' - - -def get_rendered_property(entity, property): - properties = entity.externalDataPE().getProperties() - for prop in properties: - etpt = prop.getEntityTypePropertyType() - pt = etpt.getPropertyType() - code = pt.getCode() - if code == property: - return prop.tryGetUntypedValue() - return None - - -def validate(entity, is_new): - imaging_dataset_config = get_rendered_property(entity, "$IMAGING_DATA_CONFIG") - if imaging_dataset_config is None or imaging_dataset_config == "": - return "Imaging dataset config can not be empty!" - elif "test_validation_failure" in imaging_dataset_config: - return "Imaging dataset config validation failure!" - else: - - try: - config = json.loads(imaging_dataset_config) - except Exception as e: - return "Could not parse JSON: " + e - - result, err = assert_config(config) - if not result: - return err diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/openBIS-premise-imaging.jar b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/openBIS-premise-imaging.jar deleted file mode 100644 index 4b4684b9fca92f5c299aa0ac081570eae50770bb..0000000000000000000000000000000000000000 Binary files a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/openBIS-premise-imaging.jar and /dev/null differ diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/build.gradle b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/build.gradle deleted file mode 100644 index 0f364e5221162812c2b0f0e7de1b132145701821..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/build.gradle +++ /dev/null @@ -1,59 +0,0 @@ -apply from: 'javaproject.gradle' -apply from: 'repository.gradle' - -//evaluationDependsOn(':api-openbis-java') - -dependencies { - api project(':api-openbis-java'), - project(':server-original-data-store') - - implementation 'fasterxml:jackson-annotations:2.9.10', - 'fasterxml:jackson-core:2.9.10', - 'fasterxml:jackson-databind:2.9.10.8', - 'fasterxml:jackson-datatype-jsr310:2.9.10' - -// testImplementation 'testng:testng:6.8-CISD' -// project(':server-original-data-store') - - testImplementation 'junit:junit:4.10', - 'testng:testng:6.8-CISD' - - testRuntimeOnly 'hamcrest:hamcrest-core:1.3', - project(':server-original-data-store') -} - -sourceSets { - main { - resources { - srcDirs = ['source/java/*'] - } - } - test { - resources { - srcDirs = ['sourceTest/java'] - } - } -} - -//test { -// workingDir = '.' -//} - -def premiseArchiveName = 'openBIS-premise-imaging.jar' -jar { - dependsOn compileJava - archiveName premiseArchiveName - includeEmptyDirs false -} - - -task premiseImagingJar(type: Copy) { - dependsOn jar - from("${project.buildDir}/libs/${premiseArchiveName}") - into ".." - doLast { -// delete "${project.buildDir}/${premiseArchiveName}" -// delete "${project.buildDir}" -// delete - } -} \ No newline at end of file diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/gradle/wrapper/gradle-wrapper.jar b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 5c2d1cf016b3885f6930543d57b744ea8c220a1a..0000000000000000000000000000000000000000 Binary files a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/gradle/wrapper/gradle-wrapper.properties b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 7745c4ec463c7bb1c4ff6a5e58db239890345152..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://sissource.ethz.ch/openbis/openbis-public/openbis-ivy/-/raw/main/gradle/distribution/7.4/gradle-7.4-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/gradlew b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/gradlew deleted file mode 100755 index 83f2acfdc319a24e8766cca78f32474ad7a22dd6..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/gradlew +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# 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 -# -# https://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. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/gradlew.bat b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/gradlew.bat deleted file mode 100644 index 9618d8d9607cd91a0efb866bcac4810064ba6fac..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/gradlew.bat +++ /dev/null @@ -1,100 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/javaproject.gradle b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/javaproject.gradle deleted file mode 100644 index 82beac14965d9eac35b897c9be2a26e2ff3cb54f..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/javaproject.gradle +++ /dev/null @@ -1,412 +0,0 @@ -apply plugin: 'java-library' -apply plugin: 'project-report' - -evaluationDependsOnChildren() - -configurations { - implementation { - canBeResolved = true - } - testImplementation { - canBeResolved = true - } - runtimeOnly { - canBeResolved = true - } - tests.extendsFrom testRuntimeOnly -} - -configurations { - ecj -} - -configurations.all { - resolutionStrategy.cacheDynamicVersionsFor 0, 'hours' - resolutionStrategy.cacheChangingModulesFor 0, 'hours' -} - -//task wrapper(type: Wrapper) { -// gradleVersion = '4.10.3' -// distributionUrl = "https://services.gradle.org/distributions/gradle-4.10.3-bin.zip" -//} -sourceCompatibility='11' -targetCompatibility='11' - -sourceSets { - main { - java { - srcDirs = ['source/java'] - } - } - test { - java { - srcDirs = ['sourceTest/java'] - } - resources { - srcDirs = ['sourceTest/java'] - } - } - examples { - java { - srcDirs = ['sourceExamples/java'] - } - } -} - -buildDir = 'targets/gradle' - -buildscript { - apply from: './repository.gradle' - - repositories repositoryConfig - - dependencies { - classpath 'cisd:cisd-ant-tasks:r29834' - } -} - -repositories repositoryConfig - -def execute(command, arguments) { - new ByteArrayOutputStream().withStream { os -> - print "execute: ${command}" - arguments.collect({print " ${it}"}) - println '' - def result = exec { - executable = command - args = arguments - standardOutput = os - } - return os.toString().split('\n') - } -} - -ext.executeFunction = { - command, arguments -> execute(command, arguments) -} - -def execute_working_dir(command, arguments, working_dir) { - new ByteArrayOutputStream().withStream { os -> - print "execute: ${command}" - arguments.collect({print " ${it}"}) - println '' - def result = exec { - executable = command - args = arguments - standardOutput = os - } - return os.toString().split('\n') - } -} - -ext.svnCommand = 'svn' - -def isSvnProject() { - return new java.io.File(projectDir, ".svn").isDirectory() || new java.io.File(projectDir, "../.svn").isDirectory() -} - -def isGitProject() { - return new java.io.File(projectDir, ".git").isDirectory() || new java.io.File(projectDir, "../.git").isDirectory() -} - -def executeSVN(arguments) { - arguments.add(0, '--non-interactive') - return execute(svnCommand, arguments) -} - -def calculateCleanFlag() { - return 'clean' - for (childProject in project.childProjects.values()) { - if (childProject.cleanFlag == 'dirty') { - return 'dirty' - } - } - def isSvn = isSvnProject() - if (isSvn) { - def output = executeSVN(['status', '../' + project.name]) - def lines = output.findAll({ (it.startsWith('?') || it.trim().isEmpty()) == false}) - return lines.isEmpty() ? 'clean' : 'dirty' - } else if (isGitProject()) { - def output = execute_working_dir('git', ['status', '--porcelain'], '../' + project.name) - return output.length == 0 ? 'clean' : 'dirty' - } else { - return 'dirty' - } -} - -def findMaximum(lines, key) { - return lines.findAll({ it.startsWith(key)}).collect({element -> element.split(':')[1].toInteger()}).max() -} - -def calculateBuildInfo() { - if (isSvnProject()) { - def output = executeSVN(['info', '-R', '../' + project.name]) - def maxRevisionNumber = findMaximum(output, 'Revision:') - project.ext.revisionNumber = findMaximum(output, 'Last Changed Rev:') - if (maxRevisionNumber < project.ext.revisionNumber) { - throw new GradleException("Maximum revision ($maxRevisionNumber) is less than the maximum " - + "last changed revision ($project.ext.revisionNumber).") - } - project.ext.versionNumber = 'SNAPSHOT' - def url = output.findAll({ it.startsWith('URL:')})[0].split('URL:')[1].trim() - if (url.contains('/trunk') == false) { - def pathElements = url.split('/') - project.ext.versionNumber = 'libraries' == pathElements[-2] ? pathElements[-3] : pathElements[-2] - } - } else if (isGitProject()) { - def gitlogoutput = execute_working_dir('git', ['log', '-1', '--format=%at'], '../' + project.name) - project.ext.revisionNumber = Integer.parseInt(gitlogoutput[0]) - def tag = 'git tag -l --points-at HEAD'.execute().text.trim() - if (tag == null || tag.isEmpty() || tag.contains('pybis')) { - project.ext.versionNumber = 'SNAPSHOT' - } else { - project.ext.versionNumber = tag - } - } else { - project.ext.revisionNumber = 1 - project.ext.versionNumber = 'SNAPSHOT' - } - - for (childProject in project.childProjects.values()) { - project.ext.revisionNumber = Math.max(project.ext.revisionNumber, childProject.revisionNumber) - if (project.ext.versionNumber != childProject.versionNumber) { - throw new GradleException("Inconsistent version numbers: " - + "${project.name} at version ${project.ext.versionNumber} but " - + "${childProject.name} at version ${childProject.versionNumber}.") - } - } - version = "${project.ext.versionNumber}-r${project.ext.revisionNumber}" - project.ext.revisionForPublication = project.ext.versionNumber.startsWith('SNAPSHOT') ? "r${project.ext.revisionNumber}" : project.ext.versionNumber - project.ext.cleanFlag = calculateCleanFlag() - - def buildInfo = "${project.ext.versionNumber}:${project.ext.revisionNumber}:${project.ext.cleanFlag}" - def buildInfoDev = "${project.ext.versionNumber}-dev:${project.ext.revisionNumber}:${project.ext.cleanFlag}" - - println "BUILD INFO for $project: $buildInfo" - - def targetsDistFolder = new File("${project.projectDir}/targets/dist") - targetsDistFolder.deleteDir() - targetsDistFolder.mkdirs() - - def targetDistBuildInfo = new File(targetsDistFolder, "BUILD-${project.name}.INFO") - targetDistBuildInfo << buildInfo - - def mainClassesFolder = new File("${project.projectDir}/targets/gradle/classes/java/main") - mainClassesFolder.mkdirs() - - def mainClassesBuildInfo = new File(mainClassesFolder, "BUILD-${project.name}.INFO") - mainClassesBuildInfo.delete() - mainClassesBuildInfo << buildInfoDev -} - -calculateBuildInfo() - -group='cisd' - -task checkRestrictions(type: Exec, dependsOn: [classes, testClasses]) { - doFirst { -/* - def cp = configurations.testImplementation.filter({ f -> f.name.startsWith('restrictionchecker') || f.name.startsWith('bcel')}).asPath - def cmd = ['java', '-cp', cp, 'ch.rinn.restrictions.RestrictionChecker', '-r', sourceSets.main.output.classesDirs.first()] - if (sourceSets.test.output.classesDirs.first().exists()) { - cmd.add(sourceSets.test.output.classesDirs.first()) - } - cmd.add('-cp') - cmd.add(sourceSets.main.output.classesDirs.first()) - if (sourceSets.test.output.classesDirs.first().exists()) { - cmd.add(sourceSets.test.output.classesDirs.first()) - } - cmd.add(configurations.testImplementation.asPath) - commandLine cmd -*/ - commandLine = ['pwd'] - } -} - -def deleteSymbolicLinksRecursively(file) { - def absolutePath = file.getAbsolutePath() - def canonicalPath = file.getCanonicalPath() - if (absolutePath.equals(canonicalPath) == false) { - file.delete(); - } else if (file.isDirectory()) { - File[] files = file.listFiles() - for (File child : files) { - deleteSymbolicLinksRecursively(child) - } - } -} - -task deleteSymLinks { - doFirst { - println "DELETE SYM LINKS in $buildDir" - deleteSymbolicLinksRecursively buildDir - } -} - -clean.dependsOn deleteSymLinks - -test { - useTestNG() - options.suites('sourceTest/java/tests.xml') - - systemProperty "ant.project.name", project.name - - maxHeapSize = "8192m" - jvmArgs '-Duser.timezone=Europe/Zurich', '-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StrErrLog' - - testLogging.showStandardStreams = true - ignoreFailures = true -} -test.dependsOn checkRestrictions - -// Legacy Java 8 compiler from eclipse -dependencies { - ecj "eclipse:ecj:4.6.1" -} - -if(System.getProperty("java.version").startsWith("1.8.")) { - tasks.withType(JavaCompile) { - options.headerOutputDirectory.convention(null) - } -} - -compileJava { - options.encoding = 'utf-8' - options.fork = true - doFirst { - // Use the legacy Java 8 compiler from eclipse for Java 8 - if(System.getProperty("java.version").startsWith("1.8.")) { - options.forkOptions.with { - executable = 'java' - jvmArgs = createEclipseJDK8Args() - } - } else if(System.getProperty("java.version").startsWith("11.") || System.getProperty("java.version").startsWith("17.")) { - // Use modern openJDK 11 or 17 Compiler - } else { - throw new Exception("Unsupported Java version found: '" + System.getProperty("java.version") + "', please use JDK8, JDK11 or JDK17"); - } - } -} - -compileTestJava { - options.encoding = 'utf-8' - options.fork = true - doFirst { - // Use the legacy Java 8 compiler from eclipse for Java 8 - if(System.getProperty("java.version").startsWith("1.8.")) { - options.forkOptions.with { - executable = 'java' - jvmArgs = createEclipseJDK8Args() - } - } else if(System.getProperty("java.version").startsWith("11.") || System.getProperty("java.version").startsWith("17.")) { - // Use modern openJDK 11 or 17 Compiler - } else { - throw new Exception("Unsupported Java version found: '" + System.getProperty("java.version") + "', please use JDK8, JDK11 or JDK17"); - } - } -} - -def createEclipseJDK8Args() { - def args = ['-cp', configurations.ecj.asPath, 'org.eclipse.jdt.internal.compiler.batch.Main', '-nowarn'] - return args -} - -processTestResources { - fileMode=0666 -} - -apply plugin: 'eclipse' - -eclipse { - classpath { - downloadSources=true - defaultOutputDir = file('targets/classes') - } -} - -eclipse.classpath.file { - whenMerged{ classpath -> - def projectRefs = classpath.entries.findAll{entry -> entry.kind =='src' && entry.path.startsWith('/')} - classpath.entries.removeAll(projectRefs) - classpath.entries.addAll(projectRefs) - } -} - -task testJar(type: Jar, dependsOn: testClasses) { - baseName = "test-${project.archivesBaseName}" - from sourceSets.test.output -} - -task sourcesJar(type: Jar) { - duplicatesStrategy 'include' - classifier = 'sources' - from sourceSets.main.allSource -} - -compileJava.dependsOn sourcesJar - -artifacts { - tests testJar -} - -artifacts { - archives sourcesJar -} - -task compileDependencies(type: Copy) { - into "$buildDir/output/compile-dependencies" - from configurations.implementation -} - -task runtimeDependencies(type: Copy) { - into "$buildDir/output/runtime-dependencies" - from configurations.runtimeOnly -} - -task testCompileDependencies(type: Copy) { - into "$buildDir/output/testCompile-dependencies" - from configurations.testImplementation -} - -task testRuntimeDependencies(type: Copy) { - into "$buildDir/output/testRuntime-dependencies" - from configurations.testRuntimeOnly -} - -task checkDependencies(dependsOn: classes) { - doLast { - ant.taskdef(name: 'dependencychecker', classname: 'classycle.ant.DependencyCheckingTask', classpath: configurations.testRuntime.asPath) - ant.dependencychecker( - definitionFile: 'resource/dependency-structure.ddf', - failOnUnwantedDependencies: 'true', - mergeInnerClasses: 'true') { - fileset(dir: "${buildDir}", includes: "**/*.class") - } - } -} - -apply plugin: 'ivy-publish' -if (hasProperty('ivyRepository') == false || ''.equals(project.ivyRepository)) -{ - project.ext.ivyRepository = "${project.projectDir}/../ivy-repository" -} -publishing { - - repositories { - ivy { - ivyPattern "file://${project.ivyRepository}/[organisation]/[module]/[revision]/ivy.xml" - artifactPattern "file://${project.ivyRepository}/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]" - } - } -} - -publish { - dependsOn build -} - -if (JavaVersion.current().isJava8Compatible()) { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - options.addStringOption('encoding', 'utf-8') - } -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/repository.gradle b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/repository.gradle deleted file mode 100644 index 1672a54cfb7dfe17c5369ae440228f76f117e29f..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/repository.gradle +++ /dev/null @@ -1,6 +0,0 @@ -ext.repositoryConfig = { - ivy { - ivyPattern "https://sissource.ethz.ch/openbis/openbis-public/openbis-ivy/-/raw/main/[organisation]/[module]/[revision]/ivy.xml" - artifactPattern "https://sissource.ethz.ch/openbis/openbis-public/openbis-ivy/-/raw/main/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]" - } -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/settings.gradle b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/settings.gradle deleted file mode 100644 index 0abc667a6661bc3dc5205baaeb3696a474efda62..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/settings.gradle +++ /dev/null @@ -1,21 +0,0 @@ -//includeFlat 'lib-commonbase', 'lib-common', 'api-openbis-java', 'lib-openbis-common', 'lib-authentication', 'lib-dbmigration', 'server-application-server', -// 'server-original-data-store', 'server-screening', 'server-external-data-store', -// 'ui-admin', 'lib-microservice-server', 'ui-eln-lims', 'api-openbis-javascript' -// -//def includes = ['lib-commonbase', 'lib-common', 'api-openbis-java', 'lib-openbis-common', 'api-openbis-javascript', -// 'lib-authentication', 'lib-dbmigration', 'server-application-server', 'server-original-data-store'] -// -//includes.forEach { name -> -// includeFlat(name) -// project(":${name}").projectDir = new File("../openbis/${name}") -//} - -def includes = ['lib-common', 'lib-commonbase', 'api-openbis-java', -'api-openbis-javascript', 'lib-openbis-common', 'lib-dbmigration', 'lib-authentication', -'server-original-data-store', 'server-application-server' -] - -includes.forEach { name -> - includeFlat(name) - project(":${name}").projectDir = new File("../../../../../../../../../../${name}") -} \ No newline at end of file diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/PingPongService.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/PingPongService.java deleted file mode 100644 index ae4934db548a3dec51d7b352a6a60c6a09fb26d1..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/PingPongService.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins; - -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.service.CustomDSSServiceExecutionOptions; -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.service.id.ICustomDSSServiceId; -import ch.ethz.sis.openbis.generic.dssapi.v3.plugin.service.ICustomDSSServiceExecutor; - -import java.io.Serializable; -import java.util.Map; -import java.util.Properties; - -public class PingPongService implements ICustomDSSServiceExecutor -{ - public PingPongService(Properties properties) - { - System.out.println("||> INIT PING PONG SERVICE"); - } - @Override - public Serializable executeService(String sessionToken, ICustomDSSServiceId serviceId, - CustomDSSServiceExecutionOptions options) - { - Map<String, Object> params = options.getParameters(); - if(params.containsKey("key") && params.get("key").toString().equalsIgnoreCase("PING")) - { - return "PONG"; - } - throw new IllegalArgumentException("Missing Ping parameter"); - } -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetConfig.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetConfig.java deleted file mode 100644 index 7ce7ed60b56e81ba8617b11eefda81e9ce642505..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetConfig.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.dssapi.v3.dto.imaging; - -import ch.systemsx.cisd.base.annotation.JsonObject; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -@JsonObject("dss.dto.imaging.ImagingDataSetConfig") -public class ImagingDataSetConfig implements Serializable -{ - private static final long serialVersionUID = 1L; - - - @JsonProperty - private String adaptor; - - @JsonProperty - private Double version; - - @JsonProperty - private List<Integer> speeds; - - @JsonProperty - private List<String> resolutions; - - @JsonProperty - private boolean playable; - - @JsonProperty - private List<ImagingDataSetControl> exports; - - @JsonProperty - private List<ImagingDataSetControl> inputs; - - @JsonProperty - private Map<String, String> metaData; - - @JsonIgnore - public String getAdaptor() - { - return adaptor; - } - - public void setAdaptor(String adaptor) - { - this.adaptor = adaptor; - } - - @JsonIgnore - public Double getVersion() - { - return version; - } - - public void setVersion(Double version) - { - this.version = version; - } - - @JsonIgnore - public List<Integer> getSpeeds() - { - return speeds; - } - - public void setSpeeds(List<Integer> speeds) - { - this.speeds = speeds; - } - - @JsonIgnore - public List<String> getResolutions() - { - return resolutions; - } - - public void setResolutions(List<String> resolutions) - { - this.resolutions = resolutions; - } - - @JsonIgnore - public boolean isPlayable() - { - return playable; - } - - public void setPlayable(boolean playable) - { - this.playable = playable; - } - - @JsonIgnore - public List<ImagingDataSetControl> getExports() - { - return exports; - } - - public void setExports( - List<ImagingDataSetControl> exports) - { - this.exports = exports; - } - - @JsonIgnore - public List<ImagingDataSetControl> getInputs() - { - return inputs; - } - - public void setInputs( - List<ImagingDataSetControl> inputs) - { - this.inputs = inputs; - } - - @JsonIgnore - public Map<String, String> getMetaData() - { - return metaData; - } - - public void setMetaData(Map<String, String> metaData) - { - this.metaData = metaData; - } - - @Override - public String toString() - { - return "ImagingDataSetConfig: " + adaptor; - } -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetControl.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetControl.java deleted file mode 100644 index 7d5c27fe9ce8562ced6418828f8734a80d90e365..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetControl.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.dssapi.v3.dto.imaging; - -import ch.systemsx.cisd.base.annotation.JsonObject; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -@JsonObject("dss.dto.imaging.ImagingDataSetControl") -public class ImagingDataSetControl implements Serializable -{ - private static final long serialVersionUID = 1L; - - @JsonProperty - private String label; - - @JsonProperty - private String section; - - @JsonProperty - private String type; - - @JsonProperty - private List<String> values; - - @JsonProperty - private String unit; - - @JsonProperty - private List<String> range; - - @JsonProperty - private boolean multiselect; - - @JsonProperty - private Boolean playable; - - @JsonProperty - private List<Integer> speeds; - @JsonProperty - private List<ImagingDataSetControlVisibility> visibility; - - @JsonProperty - private Map<String, String> metaData; - - @JsonIgnore - public String getLabel() - { - return label; - } - - public void setLabel(String label) - { - this.label = label; - } - - @JsonIgnore - public String getSection() - { - return section; - } - - public void setSection(String section) - { - this.section = section; - } - - @JsonIgnore - public String getUnit() - { - return unit; - } - - public void setUnit(String unit) - { - this.unit = unit; - } - - @JsonIgnore - public String getType() - { - return type; - } - - public void setType(String type) - { - this.type = type; - } - - @JsonIgnore - public List<String> getValues() - { - return values; - } - - public void setValues(List<String> values) - { - this.values = values; - } - - @JsonIgnore - public boolean isMultiselect() - { - return multiselect; - } - - public void setMultiselect(boolean multiselect) - { - this.multiselect = multiselect; - } - - @JsonIgnore - public Boolean getPlayable() - { - return playable; - } - - public void setPlayable(Boolean playable) - { - this.playable = playable; - } - - @JsonIgnore - public List<Integer> getSpeeds() - { - return speeds; - } - - public void setSpeeds(List<Integer> speeds) - { - this.speeds = speeds; - } - - @JsonIgnore - public List<String> getRange() - { - return range; - } - - public void setRange(List<String> range) - { - this.range = range; - } - - @JsonIgnore - public List<ImagingDataSetControlVisibility> getVisibility() - { - return visibility; - } - - public void setVisibility( - List<ImagingDataSetControlVisibility> visibility) - { - this.visibility = visibility; - } - - @JsonIgnore - public Map<String, String> getMetaData() - { - return metaData; - } - - public void setMetaData(Map<String, String> metaData) - { - this.metaData = metaData; - } - - @Override - public String toString() - { - return "ImagingDataSetControl: " + label; - } -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetControlVisibility.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetControlVisibility.java deleted file mode 100644 index 2a364ad0745a2c5f8205090e428b27662bbaa792..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetControlVisibility.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.dssapi.v3.dto.imaging; - -import ch.systemsx.cisd.base.annotation.JsonObject; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.io.Serializable; -import java.util.List; - -@JsonObject("dss.dto.imaging.ImagingDataSetControlVisibility") -public class ImagingDataSetControlVisibility implements Serializable -{ - private static final long serialVersionUID = 1L; - - @JsonProperty - private String label; - @JsonProperty - private List<String> values; - @JsonProperty - private List<String> range; - @JsonProperty - private String unit; - - @JsonIgnore - public String getLabel() - { - return label; - } - - public void setLabel(String label) - { - this.label = label; - } - @JsonIgnore - public List<String> getValues() - { - return values; - } - - public void setValues(List<String> values) - { - this.values = values; - } - @JsonIgnore - public List<String> getRange() - { - return range; - } - - public void setRange(List<String> range) - { - this.range = range; - } - - @JsonIgnore - public String getUnit() - { - return unit; - } - - public void setUnit(String unit) - { - this.unit = unit; - } - - @Override - public String toString() - { - return "ImagingDataSetControlVisibility: " + label; - } -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetExport.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetExport.java deleted file mode 100644 index 8d46949ea194fead71a42248edc6e3ccbcc75025..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetExport.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.dssapi.v3.dto.imaging; - -import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.property.PropertiesDeserializer; -import ch.systemsx.cisd.base.annotation.JsonObject; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.io.Serializable; -import java.util.Map; - -@JsonObject("dss.dto.imaging.ImagingDataSetExport") -public class ImagingDataSetExport implements Serializable -{ - private static final long serialVersionUID = 1L; - - @JsonProperty - @JsonDeserialize(contentUsing = PropertiesDeserializer.class) - private Map<String, Serializable> config; - - @JsonProperty - @JsonDeserialize(contentUsing = PropertiesDeserializer.class) - private Map<String, String> metaData; - - @JsonIgnore - public Map<String, Serializable> getConfig() - { - return config; - } - - public void setConfig(Map<String, Serializable> config) - { - this.config = config; - } - - @JsonIgnore - public Map<String, String> getMetaData() - { - return metaData; - } - - public void setMetaData(Map<String, String> metaData) - { - this.metaData = metaData; - } - - @Override - public String toString() - { - return "ImagingDataSetExport"; - } - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetImage.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetImage.java deleted file mode 100644 index e726231d0e42141dd27912cffa0dd75b9e6b497c..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetImage.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.dssapi.v3.dto.imaging; - -import ch.systemsx.cisd.base.annotation.JsonObject; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -@JsonObject("dss.dto.imaging.ImagingDataSetImage") -public class ImagingDataSetImage implements Serializable -{ - private static final long serialVersionUID = 1L; - - @JsonProperty - private List<ImagingDataSetPreview> previews; - - @JsonProperty - private Map<String, Serializable> config; - - @JsonProperty - private Map<String, String> metaData; - - @JsonIgnore - public List<ImagingDataSetPreview> getPreviews() - { - return previews; - } - - public void setPreviews( - List<ImagingDataSetPreview> previews) - { - this.previews = previews; - } - - public Map<String, Serializable> getConfig() - { - return config; - } - - public void setConfig(Map<String, Serializable> config) - { - this.config = config; - } - - @JsonIgnore - public Map<String, String> getMetaData() - { - return metaData; - } - - public void setMetaData(Map<String, String> metaData) - { - this.metaData = metaData; - } - - @Override - public String toString() - { - return "ImagingDataSetImage:"; - } - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetMultiExport.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetMultiExport.java deleted file mode 100644 index d46ced3b5a06b2cbf46a7bb28748ed7f6955d9fd..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetMultiExport.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.dssapi.v3.dto.imaging; - - -import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.property.PropertiesDeserializer; -import ch.systemsx.cisd.base.annotation.JsonObject; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -@JsonObject("dss.dto.imaging.ImagingDataSetMultiExport") -public class ImagingDataSetMultiExport implements Serializable -{ - private static final long serialVersionUID = 1L; - - @JsonProperty - private String permId; - @JsonProperty - private int index; - - @JsonProperty - @JsonDeserialize(contentUsing = PropertiesDeserializer.class) - private Map<String, Serializable> config; - - @JsonProperty - @JsonDeserialize(contentUsing = PropertiesDeserializer.class) - private Map<String, String> metaData; - - @JsonIgnore - public String getPermId() - { - return permId; - } - - public void setPermId(String permId) { - this.permId = permId; - } - - @JsonIgnore - public int getIndex() - { - return index; - } - - public void setIndex(int index) { - this.index = index; - } - - @JsonIgnore - public Map<String, Serializable> getConfig() - { - return config; - } - - public void setConfig(Map<String, Serializable> config) - { - this.config = config; - } - - @JsonIgnore - public Map<String, String> getMetaData() - { - return metaData; - } - - public void setMetaData(Map<String, String> metaData) - { - this.metaData = metaData; - } - - @Override - public String toString() - { - return "ImagingDataSetMultiExport:" + permId; - } - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetPreview.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetPreview.java deleted file mode 100644 index 39e85e507c7e95387897dcfd9c7f136f5f3f273a..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetPreview.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.dssapi.v3.dto.imaging; - -import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.property.PropertiesDeserializer; -import ch.systemsx.cisd.base.annotation.JsonObject; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -@JsonObject("dss.dto.imaging.ImagingDataSetPreview") -public class ImagingDataSetPreview implements Serializable -{ - private static final long serialVersionUID = 1L; - - @JsonProperty - @JsonDeserialize(contentUsing = PropertiesDeserializer.class) - private Map<String, Serializable> config; - - @JsonProperty - private String format; - - @JsonProperty - private String bytes; - - @JsonProperty - private boolean show; - - @JsonProperty - private Map<String, String> metaData; - - - @JsonIgnore - public Map<String, Serializable> getConfig() - { - return config; - } - - public void setConfig(Map<String, Serializable> config) - { - this.config = config; - } - - @JsonIgnore - public String getFormat() - { - return format; - } - - public void setFormat(String format) - { - this.format = format; - } - - @JsonIgnore - public String getBytes() - { - return bytes; - } - - public void setBytes(String bytes) - { - this.bytes = bytes; - } - - @JsonIgnore - public boolean isShow() - { - return show; - } - - public void setShow(boolean show) - { - this.show = show; - } - - @JsonIgnore - public Map<String, String> getMetaData() - { - return metaData; - } - - public void setMetaData(Map<String, String> metaData) - { - this.metaData = metaData; - } - - @Override - public String toString() - { - return "ImagingDataSetPreview"; - } - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetPropertyConfig.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetPropertyConfig.java deleted file mode 100644 index 7b9d9b71eb00bd109bb61218469ab131e72cc009..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/dssapi/v3/dto/imaging/ImagingDataSetPropertyConfig.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.dssapi.v3.dto.imaging; - -import ch.systemsx.cisd.base.annotation.JsonObject; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.io.Serializable; -import java.util.List; - -@JsonObject("dss.dto.imaging.ImagingDataSetPropertyConfig") -public class ImagingDataSetPropertyConfig implements Serializable -{ - private static final long serialVersionUID = 1L; - - @JsonProperty - ImagingDataSetConfig config; - - @JsonProperty - List<ImagingDataSetImage> images; - - @JsonIgnore - public ImagingDataSetConfig getConfig() - { - return config; - } - - public void setConfig(ImagingDataSetConfig config) - { - this.config = config; - } - - @JsonIgnore - public List<ImagingDataSetImage> getImages() - { - return images; - } - - public void setImages( - List<ImagingDataSetImage> images) - { - this.images = images; - } - - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/ImagingArchiver.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/ImagingArchiver.java deleted file mode 100644 index b550053a46c271b9bb670f8ee0bb503fb6df6f1d..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/ImagingArchiver.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging; - -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.openbis.dss.generic.server.AbstractDataSetPackager; -import ch.systemsx.cisd.openbis.dss.generic.server.DataStoreServer; -import ch.systemsx.cisd.openbis.dss.generic.server.TarDataSetPackager; -import ch.systemsx.cisd.openbis.dss.generic.server.ZipDataSetPackager; -import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.ISessionWorkspaceProvider; -import org.apache.commons.io.FileUtils; - -import java.io.*; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.*; -import java.util.function.Function; - -class ImagingArchiver -{ - private final String sessionToken; - private final String exportDirName; - private final String exportArchiveName; - private final Function<InputStream, Long> checksumFunction; - private final AbstractDataSetPackager packager; - private final File archiveFile; - private boolean isFinished; - private final long archiveDate; - - private static final int DEFAULT_BUFFER_SIZE = (int) (10 * FileUtils.ONE_MB); - - ImagingArchiver(String sessionToken, String archiveFormat) throws IOException { - this.sessionToken = sessionToken; - isFinished = false; - - archiveDate = System.currentTimeMillis(); - exportDirName = "imaging_export_" + String.valueOf(archiveDate); - - ISessionWorkspaceProvider sessionWorkspaceProvider = getSessionWorkspaceProvider(sessionToken); - File rootDirectory = sessionWorkspaceProvider.getSessionWorkspace(); - - Path tempDir = Files.createDirectory( - Path.of(rootDirectory.getAbsolutePath(), exportDirName)); - - - if (archiveFormat.equalsIgnoreCase("zip")) - { - exportArchiveName = "export.zip"; - archiveFile = - Files.createFile(Path.of(tempDir.toAbsolutePath().toString(), exportArchiveName)) - .toFile(); - packager = new ZipDataSetPackager(archiveFile, true, null, null); - checksumFunction = Util::getCRC32Checksum; - } else if (archiveFormat.equalsIgnoreCase("tar")) - { - exportArchiveName = "export.tar.gz"; - archiveFile = - Files.createFile(Path.of(tempDir.toAbsolutePath().toString(), exportArchiveName)) - .toFile(); - packager = new TarDataSetPackager(archiveFile, null, null, DEFAULT_BUFFER_SIZE, - 5L * DEFAULT_BUFFER_SIZE); - checksumFunction = (x) -> 0L; - } else - { - throw new UserFailureException("Unknown archive format!"); - } - - - } - - void addToArchive(String folderName, String fileName, byte[] byteArray) { - assertNotFinished(); - long size = byteArray.length; - packager.addEntry(Paths.get(folderName, fileName).toString(), - archiveDate, - size, - checksumFunction.apply(new ByteArrayInputStream(byteArray)), - new ByteArrayInputStream(byteArray)); - } - - void addToArchive(String folderName, File fileOrDirectoryToArchive) { - assertNotFinished(); - - Deque<Map.Entry<String, File>> queue = new LinkedList<>(); - - queue.add(new AbstractMap.SimpleImmutableEntry<>(folderName, fileOrDirectoryToArchive)); - while (!queue.isEmpty()) - { - Map.Entry<String, File> element = queue.pollFirst(); - String prefixPath = element.getKey(); - File file = element.getValue(); - String path = Paths.get(prefixPath, file.getName()).toString(); - if (file.isDirectory()) - { - for (File f : file.listFiles()) - { - queue.add(new AbstractMap.SimpleImmutableEntry<>(path, f)); - } - packager.addDirectoryEntry(path); - } else - { - try - { - packager.addEntry(path, - file.lastModified(), - file.getTotalSpace(), - checksumFunction.apply(new FileInputStream(file)), - new FileInputStream(file)); - } catch (IOException exc) - { - throw new UserFailureException("Failed during export!", exc); - } - } - } - - } - - String build() { - if(!isFinished) { - isFinished = true; - packager.close(); - } - String url = DataStoreServer.getConfigParameters().getDownloadURL() + "/datastore_server/session_workspace_file_download?sessionID=" + sessionToken + "&filePath="; - return url + Path.of(exportDirName, exportArchiveName); - } - - private ISessionWorkspaceProvider getSessionWorkspaceProvider(String sessionToken) - { - return ServiceProvider.getDataStoreService().getSessionWorkspaceProvider(sessionToken); - } - - private void assertNotFinished() - { - if(isFinished){ - throw new UserFailureException("Archive file is already closed!"); - } - } - - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/ImagingService.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/ImagingService.java deleted file mode 100644 index 6c1278fddd9ba657e57e074b5ae51ce690ed9174..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/ImagingService.java +++ /dev/null @@ -1,398 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging; - -import ch.ethz.sis.openbis.generic.asapi.v3.IApplicationServerApi; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSet; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.fetchoptions.DataSetFetchOptions; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.DataSetPermId; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.IDataSetId; -import ch.ethz.sis.openbis.generic.dssapi.v3.IDataStoreServerApi; -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.imaging.ImagingDataSetImage; -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.imaging.ImagingDataSetMultiExport; -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.imaging.ImagingDataSetPreview; -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.imaging.ImagingDataSetPropertyConfig; -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.service.CustomDSSServiceExecutionOptions; -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.service.id.ICustomDSSServiceId; -import ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.adaptor.IImagingDataSetAdaptor; -import ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.container.ImagingDataContainer; -import ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.container.ImagingExportContainer; -import ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.container.ImagingMultiExportContainer; -import ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.container.ImagingPreviewContainer; -import ch.ethz.sis.openbis.generic.dssapi.v3.plugin.service.ICustomDSSServiceExecutor; -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.common.logging.LogCategory; -import ch.systemsx.cisd.common.reflection.ClassUtils; -import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContent; -import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContentNode; -import ch.systemsx.cisd.openbis.dss.generic.server.AbstractDataSetPackager; -import ch.systemsx.cisd.openbis.dss.generic.server.DataStoreServer; -import ch.systemsx.cisd.openbis.dss.generic.server.TarDataSetPackager; -import ch.systemsx.cisd.openbis.dss.generic.server.ZipDataSetPackager; -import ch.systemsx.cisd.openbis.dss.generic.shared.IHierarchicalContentProvider; -import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.ISessionWorkspaceProvider; -import ch.systemsx.cisd.openbis.generic.shared.dto.OpenBISSessionHolder; -import ch.systemsx.cisd.common.logging.LogFactory; -import org.apache.commons.io.FileUtils; -import org.apache.log4j.Logger; - -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.*; -import java.util.function.Function; - -public class ImagingService implements ICustomDSSServiceExecutor -{ - - private final Properties properties; - - private IHierarchicalContentProvider contentProvider; - - private static final Logger - operationLog = LogFactory.getLogger(LogCategory.OPERATION, ImagingService.class); - - private static final int DEFAULT_BUFFER_SIZE = (int) (10 * FileUtils.ONE_MB); - - private static final String IMAGING_CONFIG_PROPERTY_NAME = "$IMAGING_DATA_CONFIG"; - - public ImagingService(Properties properties) - { - this.properties = properties; - } - - @Override - public Serializable executeService(String sessionToken, ICustomDSSServiceId serviceId, - CustomDSSServiceExecutionOptions options) - { - operationLog.info("Executing imaging service:" + serviceId); - ImagingDataContainer data = getDataFromParams(options.getParameters()); - try - { - if (data.getType().equalsIgnoreCase("preview")) - { - return processPreviewFlow(sessionToken, (ImagingPreviewContainer) data); - } else if (data.getType().equalsIgnoreCase("export")) - { - return processExportFlow(sessionToken, (ImagingExportContainer) data); - } else if (data.getType().equalsIgnoreCase("multi-export")) - { - return processMultiExportFlow(sessionToken, (ImagingMultiExportContainer) data); - } else - { - throw new UserFailureException("Unknown request type!"); - } - } catch (Exception e) - { - data.setError(e.toString()); - } - return data; - } - - private IImagingDataSetAdaptor getAdaptor(ImagingDataSetPropertyConfig config) - { - final String adaptorName = config.getConfig().getAdaptor(); - - if (adaptorName == null || adaptorName.isBlank()) - { - throw new UserFailureException("Adaptor name is missing from the config!"); - } - try - { - return ClassUtils.create(IImagingDataSetAdaptor.class, adaptorName, properties); - } catch (Exception e) - { - throw new UserFailureException("Could not load adapter: " + adaptorName, e); - } - } - - private File getRootFile(String sessionToken, DataSet dataSet) - { - IHierarchicalContent content = - getHierarchicalContentProvider(sessionToken).asContent( - dataSet.getPermId().getPermId()); - IHierarchicalContentNode root = content.getRootNode(); - return root.getFile(); - } - - private ImagingPreviewContainer processPreviewFlow(String sessionToken, - ImagingPreviewContainer data) - { - DataSet dataSet = getDataSet(sessionToken, data.getPermId()); - - ImagingDataSetPropertyConfig config = - Util.readConfig(dataSet.getJsonProperty("$IMAGING_DATA_CONFIG"), - ImagingDataSetPropertyConfig.class); - - IImagingDataSetAdaptor adaptor = getAdaptor(config); - File rootFile = getRootFile(sessionToken, dataSet); - Map<String, Serializable> previewParams = data.getPreview().getConfig(); - Map<String, String> meta = data.getPreview().getMetaData(); - String format = data.getPreview().getFormat(); - - int index = data.getIndex(); - if (config.getImages().size() <= index) - { - throw new UserFailureException("There is no image with index:" + index); - } - Map<String, Serializable> imageConfig = config.getImages().get(index).getConfig(); - - if (format == null || format.isBlank()) - { - throw new UserFailureException("Format can not be empty!"); - } - - ImagingServiceContext context = - new ImagingServiceContext(sessionToken, getApplicationServerApi(), - getDataStoreServerApi()); - - data.getPreview().setBytes( - adaptor.process(context, - rootFile, imageConfig, previewParams, meta, format).toString()); - return data; - } - - - - private Serializable processExportFlow(String sessionToken, ImagingExportContainer data) - { - // Get all parameters - final DataSet dataSet = getDataSet(sessionToken, data.getPermId()); - final ImagingDataSetPropertyConfig config = - Util.readConfig(dataSet.getJsonProperty(IMAGING_CONFIG_PROPERTY_NAME), - ImagingDataSetPropertyConfig.class); - - final File rootFile = getRootFile(sessionToken, dataSet); - final int index = data.getIndex(); - if (config.getImages().size() <= index) - { - throw new UserFailureException("There is no image with index:" + index); - } - - final ImagingDataSetImage image = config.getImages().get(index); - - // TODO: discuss image config as filtering for export - Map<String, Serializable> imageConfig = image.getConfig(); - - Map<String, Serializable> exportConfig = data.getExport().getConfig(); - Validator.validateExportConfig(exportConfig); - - Serializable[] exportTypes = (Serializable[]) exportConfig.get("include"); - - ImagingArchiver archiver; - - // Prepare archiver - try - { - archiver = new ImagingArchiver(sessionToken, exportConfig.get("archive-format").toString()); - } catch (IOException exception) - { - throw new UserFailureException("Could not export data!", exception); - } - - // For each export type, perform adequate action - for (Serializable exportType : exportTypes) - { - if (exportType.toString().equalsIgnoreCase("image")) - { - ImagingServiceContext context = - new ImagingServiceContext(sessionToken, getApplicationServerApi(), - getDataStoreServerApi()); - IImagingDataSetAdaptor adaptor = getAdaptor(config); - archiveImage(context, adaptor, image, index, exportConfig, rootFile, "", archiver); - } else if (exportType.toString().equalsIgnoreCase("raw data")) - { - archiveRawData(rootFile, "", archiver, dataSet); - } else - { - throw new UserFailureException("Unknown export type!"); - } - - } - - data.setUrl(archiver.build()); - return data; - } - - private Serializable processMultiExportFlow(String sessionToken, ImagingMultiExportContainer data) - { - // multi export case - final String archiveFormat = "zip"; - ImagingArchiver archiver; - try - { - archiver = new ImagingArchiver(sessionToken, archiveFormat); - } catch (IOException exception) - { - throw new UserFailureException("Could not export data!", exception); - } - - for (ImagingDataSetMultiExport export : data.getExports()) - { - DataSet dataSet = getDataSet(sessionToken, export.getPermId()); - ImagingDataSetPropertyConfig config = - Util.readConfig(dataSet.getJsonProperty(IMAGING_CONFIG_PROPERTY_NAME), - ImagingDataSetPropertyConfig.class); - - File rootFile = getRootFile(sessionToken, dataSet); - - final int index = export.getIndex(); - if (config.getImages().size() <= index) - { - throw new UserFailureException("There is no image with index:" + index); - } - - ImagingDataSetImage image = config.getImages().get(index); - - // TODO: discuss image config as filtering for export - Map<String, Serializable> imageConfig = image.getConfig(); - - Map<String, Serializable> exportConfig = export.getConfig(); - Validator.validateExportConfig(exportConfig); - - Serializable[] exportTypes = (Serializable[]) exportConfig.get("include"); - - // For each export type, perform adequate action - for (Serializable exportType : exportTypes) - { - if (exportType.toString().equalsIgnoreCase("image")) - { - ImagingServiceContext context = - new ImagingServiceContext(sessionToken, getApplicationServerApi(), - getDataStoreServerApi()); - IImagingDataSetAdaptor adaptor = getAdaptor(config); - archiveImage(context, adaptor, image, index, exportConfig, rootFile, export.getPermId(), archiver); - } else if (exportType.toString().equalsIgnoreCase("raw data")) - { - archiveRawData(rootFile, export.getPermId(), archiver, dataSet); - } else - { - throw new UserFailureException("Unknown export type!"); - } - - } - } - data.setUrl(archiver.build()); - return data; - } - - - private IHierarchicalContentProvider getHierarchicalContentProvider(String sessionToken) - { - if (contentProvider == null) - { - contentProvider = ServiceProvider.getHierarchicalContentProvider(); - } - OpenBISSessionHolder sessionTokenHolder = new OpenBISSessionHolder(); - sessionTokenHolder.setSessionToken(sessionToken); - return contentProvider.cloneFor(sessionTokenHolder); - } - - private IApplicationServerApi getApplicationServerApi() - { - return ServiceProvider.getV3ApplicationService(); - } - - private IDataStoreServerApi getDataStoreServerApi() - { - return ServiceProvider.getV3DataStoreService(); - } - - private DataSet getDataSet(String sessionToken, String permId) - { - DataSetFetchOptions fetchOptions = new DataSetFetchOptions(); - fetchOptions.withProperties(); - fetchOptions.withType(); - fetchOptions.withDataStore(); - fetchOptions.withPhysicalData(); - Map<IDataSetId, DataSet> result = getApplicationServerApi() - .getDataSets(sessionToken, List.of(new DataSetPermId(permId)), - fetchOptions); - if (result.isEmpty()) - { - throw new UserFailureException("Could not find Dataset:" + permId); - } - return result.get(new DataSetPermId(permId)); - } - - - - private ImagingDataContainer getDataFromParams(Map<String, Object> params) - { - Validator.validateInputParams(params); - - String type = (String) params.get("type"); - String json = Util.mapToJson(params); - - switch (type.toLowerCase()) - { - case "preview": - return Util.readConfig(json, ImagingPreviewContainer.class); - case "export": - return Util.readConfig(json, ImagingExportContainer.class); - case "multi-export": - return Util.readConfig(json, ImagingMultiExportContainer.class); - default: - throw new UserFailureException("Wrong type:" + type); - } - } - - private void archiveRawData(File rootFile, String rootFolderName, - ImagingArchiver archiver, DataSet dataSet) - { - //Add dataset files to archive - archiver.addToArchive(rootFolderName, rootFile); - //Add dataset properties to archive - Map<String, Serializable> properties = dataSet.getProperties(); - properties.remove(IMAGING_CONFIG_PROPERTY_NAME); - if(!properties.isEmpty()) { - byte[] json = Util.mapToJson(properties).getBytes(StandardCharsets.UTF_8); - archiver.addToArchive(rootFolderName, "properties.txt", json); - } - } - - - private void archiveImage(ImagingServiceContext context, IImagingDataSetAdaptor adaptor, - ImagingDataSetImage image, int imageIdx, Map<String, Serializable> exportConfig, - File rootFile, String rootFolderName, ImagingArchiver archiver) { - - String imageFormat = exportConfig.get("image-format").toString(); - int previewIdx = 0; - for(ImagingDataSetPreview preview : image.getPreviews()) - { - String format = imageFormat; - if(imageFormat.equalsIgnoreCase("original")) { - format = preview.getFormat(); - } - Map<String, Serializable> params = preview.getConfig(); - params.put("resolution", exportConfig.get("resolution")); - Serializable img = adaptor.process(context, - rootFile, image.getConfig(), params, image.getMetaData(), format); - String imgString = img.toString(); - byte[] decoded = Base64.getDecoder().decode(imgString); - String fileName = "image" + imageIdx +"_preview" + previewIdx + "." + format; - - archiver.addToArchive(rootFolderName, fileName, decoded); - previewIdx++; - } - } - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/ImagingServiceContext.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/ImagingServiceContext.java deleted file mode 100644 index b6d33d169f693b2627a59584c6e9219df75e63ef..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/ImagingServiceContext.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging; - -import ch.ethz.sis.openbis.generic.asapi.v3.IApplicationServerApi; -import ch.ethz.sis.openbis.generic.dssapi.v3.IDataStoreServerApi; - -import java.io.Serializable; - -public final class ImagingServiceContext implements Serializable -{ - - private final String sessionToken; - private final IApplicationServerApi asApi; - private final IDataStoreServerApi dssApi; - - - public ImagingServiceContext(String sessionToken, IApplicationServerApi asApi, IDataStoreServerApi dssApi) { - this.sessionToken = sessionToken; - this.asApi = asApi; - this.dssApi = dssApi; - } - - public String getSessionToken() - { - return sessionToken; - } - - public IApplicationServerApi getAsApi() - { - return asApi; - } - - public IDataStoreServerApi getDssApi() - { - return dssApi; - } -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/Util.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/Util.java deleted file mode 100644 index f39f10af48cc54037c6bf6f1d10b37d4db0a1283..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/Util.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging; - -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.openbis.dss.generic.server.AbstractDataSetPackager; -import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.nio.file.Paths; -import java.util.AbstractMap; -import java.util.Deque; -import java.util.LinkedList; -import java.util.Map; -import java.util.function.Function; -import java.util.zip.CRC32; - -class Util -{ - private Util() {} - - private static ObjectMapper getObjectMapper() - { - return ServiceProvider.getObjectMapperV3(); - } - - static long getCRC32Checksum(InputStream input) - { - if (input == null) - throw new UserFailureException("Can not compute crc32!"); - CRC32 crc = new CRC32(); - byte[] buffer = new byte[4096]; - try - { - while (true) - { - int length = input.read(buffer); - if (length == -1) - break; - crc.update(buffer, 0, length); - } - } catch (Exception ex) - { - try - { - input.close(); - } catch (Exception ignored) - { - } - } - return crc.getValue(); - } - - static <T> T readConfig(String val, Class<T> clazz) - { - try - { - ObjectMapper objectMapper = getObjectMapper(); - return objectMapper.readValue(new ByteArrayInputStream(val.getBytes()), - clazz); - } catch (JsonMappingException mappingException) - { - throw new UserFailureException(mappingException.toString(), mappingException); - } catch (Exception e) - { - throw new UserFailureException("Could not read the parameters!", e); - } - } - - static String mapToJson(Map<String, ?> map) - { - try - { - ObjectMapper objectMapper = getObjectMapper(); - return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(map); - } catch (Exception e) - { - throw new UserFailureException("Could not serialize the input parameters!", e); - } - } - - - - static void archiveFiles(AbstractDataSetPackager packager, File rootFile, String rootFolderName, - Function<InputStream, Long> checksumFunction) - { - Deque<Map.Entry<String, File>> queue = new LinkedList<>(); - - queue.add(new AbstractMap.SimpleImmutableEntry<>(rootFolderName, rootFile)); - while (!queue.isEmpty()) - { - Map.Entry<String, File> element = queue.pollFirst(); - String prefixPath = element.getKey(); - File file = element.getValue(); - String path = Paths.get(prefixPath, file.getName()).toString(); - if (file.isDirectory()) - { - for (File f : file.listFiles()) - { - queue.add(new AbstractMap.SimpleImmutableEntry<>(path, f)); - } - packager.addDirectoryEntry(path); - } else - { - try - { - FileInputStream fileStream = new FileInputStream(file); - packager.addEntry(path, file.lastModified(), file.getTotalSpace(), - checksumFunction.apply(fileStream), new FileInputStream(file)); - } catch (IOException exc) - { - throw new UserFailureException("Failed during export!", exc); - } - } - } - - } - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/Validator.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/Validator.java deleted file mode 100644 index f9248caf9aac83c520671c849f7af9b3bbce2a1b..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/Validator.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging; - -import ch.systemsx.cisd.common.exceptions.UserFailureException; - -import java.io.Serializable; -import java.util.Map; - -class Validator -{ - private Validator() {} - - - static void validateInputParams(Map<String, Object> params) - { -// if (!params.containsKey("permId")) -// { -// throw new UserFailureException("Missing dataset permId!"); -// } - if (!params.containsKey("type")) - { - throw new UserFailureException("Missing type!"); - } -// if (!params.containsKey("index")) -// { -// throw new UserFailureException("Missing index!"); -// } - } - - - static void validateExportConfig(Map<String, Serializable> exportConfig) { - if(exportConfig == null) { - throw new UserFailureException("Export config can not be empty!"); - } - validateTag(exportConfig, "include", true); - validateTag(exportConfig, "image-format"); - validateTag(exportConfig, "archive-format"); - validateTag(exportConfig, "resolution"); - } - - private static void validateTag(Map<String, Serializable> config, String tagName) - { - validateTag(config, tagName, false); - } - - private static void validateTag(Map<String, Serializable> config, String tagName, boolean isMultiValue) - { - if(!config.containsKey(tagName)){ - throw new UserFailureException("Missing '"+tagName+"' in export config!"); - } - Serializable include = config.get(tagName); - if(include == null){ - throw new UserFailureException("'"+tagName+"' tag in export config can not be null!"); - } - if(isMultiValue) - { - if (!include.getClass().isArray()) - { - throw new UserFailureException("'include' tag in export config must be an array!"); - } - if (((Serializable[]) include).length == 0) - { - throw new UserFailureException("'include' tag in export config can not be empty!"); - } - } - } - - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/ImagingDataSetExampleAdaptor.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/ImagingDataSetExampleAdaptor.java deleted file mode 100644 index 536f083757128825e389b0966cf809fcc6c77305..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/ImagingDataSetExampleAdaptor.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging.adaptor; - -import ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.ImagingServiceContext; - -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.Serializable; -import java.util.Base64; -import java.util.Map; -import java.util.Properties; - -public final class ImagingDataSetExampleAdaptor implements IImagingDataSetAdaptor -{ - - private static final int WIDTH = 640; - private static final int HEIGHT = 640; - - public ImagingDataSetExampleAdaptor(Properties properties) { - } - - @Override - public Serializable process(ImagingServiceContext context, File rootFile, Map<String, Serializable> imageConfig, - Map<String, Serializable> previewConfig, Map<String, String> metaData, String format) - { - BufferedImage img = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB); - for(int y=0;y<HEIGHT; y++) - { - for (int x = 0; x < WIDTH; x++) - { - int a = (int)(Math.random()*256); - int r = (int)(Math.random()*256); - int g = (int)(Math.random()*256); - int b = (int)(Math.random()*256); - - //pixel - int p = (a<<24) | (r<<16) | (g<<8) | b; - - img.setRGB(x, y, p); - } - } - try - { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - ImageIO.write(img, "png", byteArrayOutputStream); - byteArrayOutputStream.flush(); - return Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray()); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/ImagingDataSetJythonAdaptor.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/ImagingDataSetJythonAdaptor.java deleted file mode 100644 index 1a53bcd5c649ef0262d5cb142e1321b7556f82ef..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/ImagingDataSetJythonAdaptor.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging.adaptor; - -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.service.CustomDSSServiceExecutionOptions; -import ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.ImagingServiceContext; -import ch.ethz.sis.openbis.generic.server.dssapi.v3.helper.IDssServiceScriptRunner; -import ch.ethz.sis.openbis.generic.server.dssapi.v3.helper.ScriptRunnerFactory; -import ch.systemsx.cisd.common.exceptions.UserFailureException; - -import java.io.File; -import java.io.Serializable; -import java.util.Map; -import java.util.Properties; - -public class ImagingDataSetJythonAdaptor implements IImagingDataSetAdaptor -{ - private final String scriptPath; - - - public ImagingDataSetJythonAdaptor(Properties properties) { - this.scriptPath = properties.getProperty("script-path", ""); - if(scriptPath.isBlank()) { - throw new UserFailureException("There is no script defined for this adaptor!"); - } - } - @Override - public Serializable process(ImagingServiceContext context, File rootFile, Map<String, Serializable> imageConfig, - Map<String, Serializable> previewConfig, Map<String, String> metaData, String format) - { - CustomDSSServiceExecutionOptions options = new CustomDSSServiceExecutionOptions(); - options.withParameter("sessionToken", context.getSessionToken()); - options.withParameter("asApi", context.getAsApi()); - options.withParameter("dssApi", context.getDssApi()); - options.withParameter("file", rootFile); - options.withParameter("imageConfig", imageConfig); - options.withParameter("config", previewConfig); - options.withParameter("metaData", metaData); - IDssServiceScriptRunner - runner = new ScriptRunnerFactory(scriptPath, context.getAsApi(), - context.getDssApi()) - .createServiceRunner(context.getSessionToken()); - return runner.process(options); - } -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/ImagingDataSetPythonAdaptor.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/ImagingDataSetPythonAdaptor.java deleted file mode 100644 index b616666b257ee6a3cae28f082b33c1f052cf1be6..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/ImagingDataSetPythonAdaptor.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging.adaptor; - -import ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.ImagingServiceContext; -import ch.ethz.sis.openbis.generic.server.sharedapi.v3.json.GenericObjectMapper; -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.File; -import java.io.IOException; -import java.io.Serializable; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; - -public abstract class ImagingDataSetPythonAdaptor implements IImagingDataSetAdaptor -{ - - protected String pythonPath; - - protected String scriptPath; - - @Override - public Serializable process(ImagingServiceContext context, File rootFile, Map<String, Serializable> imageConfig, - Map<String, Serializable> previewConfig, Map<String, String> metaData, String format) - { - - ProcessBuilder processBuilder = new ProcessBuilder(pythonPath, - scriptPath, rootFile.getAbsolutePath(), convertMapToJson(imageConfig), - convertMapToJson(previewConfig), convertMapToJson(metaData), format); - processBuilder.redirectErrorStream(false); - - String fullOutput; - try - { - Process process = processBuilder.start(); - fullOutput = - new String(process.getInputStream().readAllBytes(), StandardCharsets.UTF_8); - int exitCode = process.waitFor(); - if (exitCode != 0) - { - String error = - new String(process.getErrorStream().readAllBytes(), StandardCharsets.UTF_8); - throw new UserFailureException("Script evaluation failed: " + error); - } - } catch (IOException | InterruptedException e) - { - throw new RuntimeException(e); - } - - if (fullOutput.isBlank()) - { - throw new UserFailureException("Script produced no results!"); - } - - String[] resultSplit = fullOutput.split("\n"); - return resultSplit[resultSplit.length - 1]; - } - - private String convertMapToJson(Map<String, ?> map) - { - Map<String, ?> mapToConvert = map; - if(map == null) { - mapToConvert = new HashMap<>(); - } - try - { - ObjectMapper objectMapper = new GenericObjectMapper(); - return objectMapper.writeValueAsString(mapToConvert); - } catch (Exception e) - { - throw new UserFailureException("Couldn't convert map to string", e); - } - } - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/NanonisDatAdaptor.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/NanonisDatAdaptor.java deleted file mode 100644 index 4b66f8cf576f1211667c0de0f8c9d48459a3e30c..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/NanonisDatAdaptor.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging.adaptor; - -import ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.ImagingServiceContext; -import ch.systemsx.cisd.common.exceptions.UserFailureException; - -import java.io.File; -import java.io.Serializable; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Map; -import java.util.Properties; - -public class NanonisDatAdaptor extends ImagingDataSetPythonAdaptor -{ - private final String DAT_SCRIPT_PROPERTY = "nanonis-dat"; - - - public NanonisDatAdaptor(Properties properties) - { - - String scriptProperty = properties.getProperty(DAT_SCRIPT_PROPERTY, ""); - if (scriptProperty.isBlank()) - { - throw new UserFailureException( - "There is no script path property called '" + DAT_SCRIPT_PROPERTY + "' defined for this adaptor!"); - } - Path script = Paths.get(scriptProperty); - if (!Files.exists(script)) - { - throw new UserFailureException("Script file " + script + " does not exists!"); - } - this.scriptPath = script.toString(); - this.pythonPath = properties.getProperty("python3-path", "python3"); - } - - @Override - public Serializable process( - ImagingServiceContext context, File rootFile, Map<String, Serializable> imageConfig, - Map<String, Serializable> previewConfig, Map<String, String> metaData, String format) - { - Serializable result = super.process(context, rootFile, imageConfig, previewConfig, metaData, format); - if (result == null) - { - return result; - } - String str = result.toString(); - if (str.length() > 3) - { - return str.substring(2, str.length() - 1); - } else - { - return ""; - } - - } - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/NanonisSxmAdaptor.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/NanonisSxmAdaptor.java deleted file mode 100644 index 4f7601ec881634e0f4cb15aea41424c6d4f6e023..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/adaptor/NanonisSxmAdaptor.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging.adaptor; - -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.ImagingServiceContext; -import ch.ethz.sis.openbis.generic.server.sharedapi.v3.json.GenericObjectMapper; -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.File; -import java.io.IOException; -import java.io.Serializable; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Map; -import java.util.Properties; - -public final class NanonisSxmAdaptor extends ImagingDataSetPythonAdaptor -{ - private final String SXM_SCRIPT_PROPERTY = "nanonis-sxm"; - - public NanonisSxmAdaptor(Properties properties) - { - - String scriptProperty = properties.getProperty(SXM_SCRIPT_PROPERTY, ""); - if (scriptProperty.isBlank()) - { - throw new UserFailureException( - "There is no script path property called '" + SXM_SCRIPT_PROPERTY + "' defined for this adaptor!"); - } - Path script = Paths.get(scriptProperty); - if (!Files.exists(script)) - { - throw new UserFailureException("Script file " + script + " does not exists!"); - } - this.scriptPath = script.toString(); - this.pythonPath = properties.getProperty("python3-path", "python3"); - } - - @Override - public Serializable process(ImagingServiceContext context, File rootFile, Map<String, Serializable> imageConfig, - Map<String, Serializable> previewConfig, Map<String, String> metaData, String format) - { - Serializable result = super.process(context, rootFile, imageConfig, previewConfig, metaData, format); - if (result == null) - { - return result; - } - String str = result.toString(); - if (str.length() > 3) - { - return str.substring(2, str.length() - 1); - } else - { - return ""; - } - - } - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/container/ImagingDataContainer.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/container/ImagingDataContainer.java deleted file mode 100644 index 7c07d1c0b91e069e1ef724080a415d42e9d85731..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/container/ImagingDataContainer.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging.container; - -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.IDataSetId; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.io.Serializable; - -public abstract class ImagingDataContainer implements Serializable -{ - - @JsonProperty - private String type; - - @JsonProperty - private String error; - - @JsonIgnore - public String getType() - { - return type; - } - - public void setType(String type) { - this.type = type; - } - - @JsonIgnore - public String getError() - { - return error; - } - - public void setError(String error) - { - this.error = error; - } - - - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/container/ImagingExportContainer.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/container/ImagingExportContainer.java deleted file mode 100644 index c1e5fed445dd53bd0180b554737cffabddf1e5eb..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/container/ImagingExportContainer.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging.container; - -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.imaging.ImagingDataSetExport; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -public final class ImagingExportContainer extends ImagingDataContainer -{ - - @JsonProperty - private String permId; - @JsonProperty - private int index; - @JsonProperty - private String url; - @JsonProperty - private ImagingDataSetExport export = null; - - @JsonIgnore - public String getPermId() - { - return permId; - } - - public void setPermId(String permId) { - this.permId = permId; - } - - @JsonIgnore - public int getIndex() - { - return index; - } - - public void setIndex(int index) { - this.index = index; - } - - @JsonIgnore - public String getUrl() - { - return url; - } - - public void setUrl(String url) - { - this.url = url; - } - - @JsonIgnore - public ImagingDataSetExport getExport() - { - return export; - } - - public void setExport(ImagingDataSetExport export) - { - this.export = export; - } -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/container/ImagingMultiExportContainer.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/container/ImagingMultiExportContainer.java deleted file mode 100644 index 183cb54dfd5fb69afa6cd336000f53d1713dc9e7..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/container/ImagingMultiExportContainer.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging.container; - -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.imaging.ImagingDataSetMultiExport; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class ImagingMultiExportContainer extends ImagingDataContainer -{ - - @JsonProperty - private String url; - - @JsonProperty - private List<ImagingDataSetMultiExport> exports = null; - - @JsonIgnore - public String getUrl() - { - return url; - } - - public void setUrl(String url) - { - this.url = url; - } - - @JsonIgnore - public List<ImagingDataSetMultiExport> getExports() - { - return exports; - } - - public void setExports(List<ImagingDataSetMultiExport> exports) - { - this.exports = exports; - } -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/container/ImagingPreviewContainer.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/container/ImagingPreviewContainer.java deleted file mode 100644 index d5d5e23973d6b1a1c328a3a11c96cef27e0687bc..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/container/ImagingPreviewContainer.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging.container; - -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.imaging.ImagingDataSetPreview; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -public final class ImagingPreviewContainer extends ImagingDataContainer -{ - - @JsonProperty - private String permId; - @JsonProperty - private int index; - @JsonProperty - private ImagingDataSetPreview preview = null; - - @JsonIgnore - public String getPermId() - { - return permId; - } - - public void setPermId(String permId) { - this.permId = permId; - } - - @JsonIgnore - public int getIndex() - { - return index; - } - - public void setIndex(int index) { - this.index = index; - } - - @JsonIgnore - public ImagingDataSetPreview getPreview() - { - return preview; - } - - public void setPreview(ImagingDataSetPreview preview) - { - this.preview = preview; - } -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetConfig.js b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetConfig.js deleted file mode 100644 index c44fe0fac0f436f2cfd003518eb036709e0e4e08..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetConfig.js +++ /dev/null @@ -1,91 +0,0 @@ -define([ "stjs", "util/Exceptions" ], function(stjs, exceptions) { - var ImagingDataSetConfig = function() { - }; - stjs.extend(ImagingDataSetConfig, null, [], function(constructor, prototype) { - prototype['@type'] = 'dss.dto.imaging.ImagingDataSetConfig'; - constructor.serialVersionUID = 1; - prototype.adaptor = null; - prototype.version = null; - prototype.speeds = null; - prototype.resolutions = null; - prototype.playable = null; - prototype.exports = null; - prototype.inputs = null; - prototype.metaData = null; - - prototype.getAdaptor = function() { - return this.adaptor; - }; - prototype.setAdaptor = function(adaptor) { - this.adaptor = adaptor; - }; - prototype.getVersion = function() { - return this.version; - }; - prototype.setVersion = function(version) { - this.version = version; - }; - prototype.getSpeeds = function() { - return this.speeds; - }; - prototype.setSpeeds = function(speeds) { - this.speeds = speeds; - }; - prototype.getResolutions = function() { - return this.resolutions; - }; - prototype.setResolutions = function(resolutions) { - this.resolutions = resolutions; - }; - prototype.getPlayable = function() { - return this.playable; - }; - prototype.setPlayable = function(playable) { - this.playable = playable; - }; - prototype.getExports = function() { - return this.exports; - }; - prototype.setExports = function(exports) { - this.exports = exports; - }; - prototype.getInputs = function() { - return this.inputs; - }; - prototype.setInputs = function(inputs) { - this.inputs = inputs; - }; - prototype.getMetaData = function() { - return this.metaData; - }; - prototype.setMetaData = function(metaData) { - this.metaData = metaData; - }; - prototype.toString = function() { - return "ImagingDataSetConfig: " + this.adaptor; - }; - - }, { - resolutions : { - name : "List", - arguments : [ "String"] - }, - speeds : { - name : "List", - arguments : [ "Integer"] - }, - exports : { - name : "List", - arguments : [ "ImagingDataSetControl"] - }, - inputs : { - name : "List", - arguments : [ "ImagingDataSetControl"] - }, - metaData : { - name : "Map", - arguments : [ "String", "String" ] - } - }); - return ImagingDataSetConfig; -}) \ No newline at end of file diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetControl.js b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetControl.js deleted file mode 100644 index 30c9b6c9a3839bec4abcb37efcb50d2bb12f6e2b..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetControl.js +++ /dev/null @@ -1,112 +0,0 @@ -define([ "stjs", "util/Exceptions" ], function(stjs, exceptions) { - var ImagingDataSetControl = function() { - }; - stjs.extend(ImagingDataSetControl, null, [], function(constructor, prototype) { - prototype['@type'] = 'dss.dto.imaging.ImagingDataSetControl'; - constructor.serialVersionUID = 1; - prototype.label = null; - prototype.section = null; - prototype.type = null; - prototype.values = null; - prototype.unit = null; - prototype.range = null; - prototype.multiselect = null; - prototype.playable = null; - prototype.speeds = null; - prototype.visibility = null; - prototype.metaData = null; - - prototype.getLabel = function() { - return this.label; - }; - prototype.setLabel = function(label) { - this.label = label; - }; - prototype.getSection = function() { - return this.section; - }; - prototype.setSection = function(section) { - this.section = section; - }; - prototype.getType = function() { - return this.type; - }; - prototype.setType = function(type) { - this.type = type; - }; - prototype.getValues = function() { - return this.values; - }; - prototype.setValues = function(values) { - this.values = values; - }; - prototype.getUnit = function() { - return this.unit; - }; - prototype.setUnit = function(unit) { - this.unit = unit; - }; - prototype.getRange = function() { - return this.range; - }; - prototype.setRange = function(range) { - this.range = range; - }; - prototype.getMultiselect = function() { - return this.multiselect; - }; - prototype.setMultiselect = function(multiselect) { - this.multiselect = multiselect; - }; - prototype.getPlayable = function() { - return this.playable; - }; - prototype.setPlayable = function(playable) { - this.playable = playable; - }; - prototype.getSpeeds = function() { - return this.speeds; - }; - prototype.setSpeeds = function(speeds) { - this.speeds = speeds; - }; - prototype.getVisibility = function() { - return this.visibility; - }; - prototype.setVisibility = function(visibility) { - this.visibility = visibility; - }; - prototype.getMetaData = function() { - return this.metaData; - }; - prototype.setMetaData = function(metaData) { - this.metaData = metaData; - }; - prototype.toString = function() { - return "ImagingDataSetControl: " + this.label; - }; - - }, { - values : { - name : "List", - arguments : [ "String"] - }, - visibility: { - name : "List", - arguments : [ "ImagingDataSetControlVisibility"] - } - range : { - name : "List", - arguments : [ "String"] - }, - speeds : { - name : "List", - arguments : [ "Integer"] - }, - metaData : { - name : "Map", - arguments : [ "String", "String" ] - } - }); - return ImagingDataSetControl; -}) \ No newline at end of file diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetControlVisibility.js b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetControlVisibility.js deleted file mode 100644 index 5a0b2fc77113238ba19ca6f3f2caa8b2df23e1e2..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetControlVisibility.js +++ /dev/null @@ -1,51 +0,0 @@ -define([ "stjs", "util/Exceptions" ], function(stjs, exceptions) { - var ImagingDataSetControlVisibility = function() { - }; - stjs.extend(ImagingDataSetControlVisibility, null, [], function(constructor, prototype) { - prototype['@type'] = 'dss.dto.imaging.ImagingDataSetControlVisibility'; - constructor.serialVersionUID = 1; - prototype.label = null; - prototype.values = null; - prototype.range = null; - prototype.unit = null; - - prototype.getLabel = function() { - return this.label; - }; - prototype.setLabel = function(label) { - this.label = label; - }; - prototype.getValues = function() { - return this.values; - }; - prototype.setValues = function(values) { - this.values = values; - }; - prototype.getUnit = function() { - return this.unit; - }; - prototype.setUnit = function(unit) { - this.unit = unit; - }; - prototype.getRange = function() { - return this.range; - }; - prototype.setRange = function(range) { - this.range = range; - }; - prototype.toString = function() { - return "ImagingDataSetControlVisibility: " + this.label; - }; - - }, { - values : { - name : "List", - arguments : [ "String"] - }, - range : { - name : "List", - arguments : [ "String"] - } - }); - return ImagingDataSetControlVisibility; -}) \ No newline at end of file diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetExport.js b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetExport.js deleted file mode 100644 index a478e50fcc69dc9aa59d2fa96e4fb2cfb15223a2..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetExport.js +++ /dev/null @@ -1,58 +0,0 @@ -define([ "stjs", "util/Exceptions" ], function(stjs, exceptions) { - var ImagingDataSetExport = function() { - }; - stjs.extend(ImagingDataSetExport, null, [], function(constructor, prototype) { - prototype['@type'] = 'dss.dto.imaging.ImagingDataSetExport'; - constructor.serialVersionUID = 1; - prototype.config = null; - prototype.format = null; - prototype.bytes = null; - prototype.show = null; - prototype.metaData = null; - - prototype.getConfig = function() { - return this.config; - }; - prototype.setConfig = function(config) { - this.config = config; - }; - prototype.getFormat = function() { - return this.format; - }; - prototype.setFormat = function(format) { - this.format = format; - }; - prototype.getBytes = function() { - return this.bytes; - }; - prototype.setBytes = function(bytes) { - this.bytes = bytes; - }; - prototype.isShow = function() { - return this.show; - }; - prototype.setShow = function(show) { - this.show = show; - }; - prototype.getMetaData = function() { - return this.metaData; - }; - prototype.setMetaData = function(metaData) { - this.metaData = metaData; - }; - prototype.toString = function() { - return "ImagingDataSetExport: " + this.config; - }; - - }, { - config : { - name : "Map", - arguments : [ "String", "Serializable" ] - }, - metaData : { - name : "Map", - arguments : [ "String", "String" ] - } - }); - return ImagingDataSetExport; -}) \ No newline at end of file diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetImage.js b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetImage.js deleted file mode 100644 index cabcef4beca86e165149c8398864e4d340ce3826..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetImage.js +++ /dev/null @@ -1,37 +0,0 @@ -define([ "stjs", "util/Exceptions" ], function(stjs, exceptions) { - var ImagingDataSetImage = function() { - }; - stjs.extend(ImagingDataSetImage, null, [], function(constructor, prototype) { - prototype['@type'] = 'dss.dto.imaging.ImagingDataSetImage'; - constructor.serialVersionUID = 1; - prototype.previews = null; - prototype.metaData = null; - - prototype.getPreviews = function() { - return this.previews; - }; - prototype.setPreviews = function(previews) { - this.previews = previews; - }; - prototype.getMetaData = function() { - return this.metaData; - }; - prototype.setMetaData = function(metaData) { - this.metaData = metaData; - }; - prototype.toString = function() { - return "ImagingDataSetImage: " + this.previews; - }; - - }, { - previews : { - name : "List", - arguments : [ "ImagingDataSetPreview"] - }, - metaData : { - name : "Map", - arguments : [ "String", "String" ] - } - }); - return ImagingDataSetImage; -}) \ No newline at end of file diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetPreview.js b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetPreview.js deleted file mode 100644 index f119f0c2e32c9bad12c60203539ccf0e11fc55db..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetPreview.js +++ /dev/null @@ -1,58 +0,0 @@ -define([ "stjs", "util/Exceptions" ], function(stjs, exceptions) { - var ImagingDataSetPreview = function() { - }; - stjs.extend(ImagingDataSetPreview, null, [], function(constructor, prototype) { - prototype['@type'] = 'dss.dto.imaging.ImagingDataSetPreview'; - constructor.serialVersionUID = 1; - prototype.config = null; - prototype.format = null; - prototype.bytes = null; - prototype.show = null; - prototype.metaData = null; - - prototype.getConfig = function() { - return this.config; - }; - prototype.setConfig = function(config) { - this.config = config; - }; - prototype.getFormat = function() { - return this.format; - }; - prototype.setFormat = function(format) { - this.format = format; - }; - prototype.getBytes = function() { - return this.bytes; - }; - prototype.setBytes = function(bytes) { - this.bytes = bytes; - }; - prototype.isShow = function() { - return this.show; - }; - prototype.setShow = function(show) { - this.show = show; - }; - prototype.getMetaData = function() { - return this.metaData; - }; - prototype.setMetaData = function(metaData) { - this.metaData = metaData; - }; - prototype.toString = function() { - return "ImagingDataSetPreview: " + this.config; - }; - - }, { - config : { - name : "Map", - arguments : [ "String", "Serializable" ] - }, - metaData : { - name : "Map", - arguments : [ "String", "String" ] - } - }); - return ImagingDataSetPreview; -}) \ No newline at end of file diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetPropertyConfig.js b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetPropertyConfig.js deleted file mode 100644 index 3b0b820e8cc22a18c592b16ebab2c80c187eea92..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/js/src/v3/dss/dto/imaging/ImagingDataSetPropertyConfig.js +++ /dev/null @@ -1,34 +0,0 @@ -define([ "stjs", "util/Exceptions" ], function(stjs, exceptions) { - var ImagingDataSetPropertyConfig = function() { - }; - stjs.extend(ImagingDataSetPropertyConfig, null, [], function(constructor, prototype) { - prototype['@type'] = 'dss.dto.imaging.ImagingDataSetPropertyConfig'; - constructor.serialVersionUID = 1; - prototype.config = null; - prototype.images = null; - - prototype.getConfig = function() { - return this.config; - }; - prototype.setConfig = function(config) { - this.config = config; - }; - prototype.getImages = function() { - return this.images; - }; - prototype.setSection = function(images) { - this.images = images; - }; - - prototype.toString = function() { - return "ImagingDataSetPropertyConfig: " + this.label; - }; - - }, { - images : { - name : "List", - arguments : [ "ImagingDataSetImage"] - } - }); - return ImagingDataSetPropertyConfig; -}) \ No newline at end of file diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/python/imaging/__init__.py b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/python/imaging/__init__.py deleted file mode 100644 index ea4523e5b122686bfa54ed93a661088b4a834a54..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/python/imaging/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright ETH 2023 Zürich, Scientific IT Services -# -# 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. -# -from . import imaging - -name = "imaging" -__author__ = "ID SIS • ETH Zürich" -__email__ = "openbis-support@id.ethz.ch" -__version__ = "0.0.0" - - diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/python/imaging/imaging.py b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/python/imaging/imaging.py deleted file mode 100644 index fccc9d84387642b648ebfef379d1d824b80fe9ed..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/python/imaging/imaging.py +++ /dev/null @@ -1,448 +0,0 @@ -# Copyright ETH 2023 Zürich, Scientific IT Services -# -# 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. -# - -from pybis import Openbis -import abc -import json -import base64 -import requests -import os -from urllib.parse import urljoin - - -DEFAULT_SERVICE_NAME = "imaging" -IMAGING_CONFIG_PROP_NAME = "$IMAGING_DATA_CONFIG".lower() - - -def get_instance(url="http://localhost:8888/openbis"): - base_url = url - # base_url = "http://localhost:8888/openbis" - # base_url = "https://alaskowski:8443/openbis" - # base_url = "https://openbis-sis-ci-sprint.ethz.ch/" - openbis_instance = Openbis( - url=base_url, - verify_certificates=False, - allow_http_but_do_not_use_this_in_production_and_only_within_safe_networks=True - ) - token = openbis_instance.login('admin', 'changeit') - print(f'Connected to {base_url} -> token: {token}') - return openbis_instance - - -class AbstractImagingClass(metaclass=abc.ABCMeta): - def to_json(self): - return json.dumps(self, default=lambda x: x.__dict__, sort_keys=True, indent=4) - - def __str__(self): - return json.dumps(self.__dict__, default=lambda x: x.__dict__) - - def __repr__(self): - return json.dumps(self.__dict__, default=lambda x: x.__dict__) - - -class AbstractImagingRequest(AbstractImagingClass, metaclass=abc.ABCMeta): - @abc.abstractmethod - def _validate_data(self): - return - - -class ImagingDataSetPreview(AbstractImagingRequest): - config: dict - format: str - bytes: str | None - show: bool - metadata: dict - - def __init__(self, config, preview_format, metadata=None): - self.__dict__["@type"] = "dss.dto.imaging.ImagingDataSetPreview" - self.bytes = None - self.format = preview_format - self.config = config if config is not None else dict() - self.metadata = metadata if metadata is not None else dict() - self._validate_data() - - def _validate_data(self): - assert self.format is not None, "Format can not be null" - - def save_to_file(self, file_path): - assert self.bytes is not None, "There is no image information!" - img_data = bytearray(self.bytes, encoding='utf-8') - with open(file_path, "wb") as fh: - fh.write(base64.decodebytes(img_data)) - - @classmethod - def from_dict(cls, data): - if data is None: - return None - preview = cls(None, None, None) - for prop in cls.__annotations__.keys(): - attribute = data.get(prop) - preview.__dict__[prop] = attribute - return preview - - -class ImagingDataSetExport(AbstractImagingRequest): - config: dict - metadata: dict - - def __init__(self, config, metadata=None): - self.__dict__["@type"] = "dss.dto.imaging.ImagingDataSetExport" - self.config = config if config is not None else dict() - self.metadata = metadata if metadata is not None else dict() - self._validate_data() - - def _validate_data(self): - assert self.config is not None, "Config can not be null" - required_keys = {"include", "archive-format", "image-format", "resolution"} - for key in required_keys: - assert key in self.config and self.config[key] is not None, \ - f"export->config->{key}: Must not be None!" - - -class ImagingDataSetMultiExport(AbstractImagingRequest): - permId: str - index: int - config: dict - metadata: dict - - def __init__(self, permId, index, config, metadata=None): - self.__dict__["@type"] = "dss.dto.imaging.ImagingDataSetMultiExport" - self.permId = permId - self.index = index - self.config = config - self.metadata = metadata if metadata is not None else dict() - self._validate_data() - - def _validate_data(self): - assert self.permId is not None, "PermId can not be null" - assert self.index is not None, "Index can not be null" - assert self.config is not None, "Config can not be null" - required_keys = {"include", "archive-format", "image-format", "resolution"} - for key in required_keys: - assert key in self.config and self.config[key] is not None, \ - f"export->config->{key}: Must not be None!" - - -class ImagingDataSetControlVisibility(AbstractImagingClass): - label: str - values: list[str] - range: list[str] - unit: str - - def __init__(self, label: str, values: list[str], values_range: list[str], unit: str = None): - self.__dict__["@type"] = "dss.dto.imaging.ImagingDataSetControlVisibility" - self.label = label - self.values = values - self.range = values_range - self.unit = unit - - @classmethod - def from_dict(cls, data): - if data is None: - return None - control = cls(None, None, None, None) - for prop in cls.__annotations__.keys(): - attribute = data.get(prop) - control.__dict__[prop] = attribute - return control - - -class ImagingDataSetControl(AbstractImagingClass): - label: str - section: str - type: str - values: list[str] - unit: str - range: list[str] - multiselect: bool - playable: bool - speeds: list[int] - visibility: list[ImagingDataSetControlVisibility] - metaData: dict - - def __init__(self, label: str, control_type: str, values: list[str] = None, - values_range: list[str] = None, multiselect: bool = None): - self.__dict__["@type"] = "dss.dto.imaging.ImagingDataSetControl" - self.label = label - self.type = control_type - if control_type.lower() in ["slider", "range"]: - self.range = values_range - elif control_type.lower() == "dropdown": - self.values = values - self.multiselect = multiselect - - @classmethod - def from_dict(cls, data): - if data is None: - return None - control = cls(None, "", None, None) - for prop in cls.__annotations__.keys(): - attribute = data.get(prop) - if prop == 'visibility' and attribute is not None: - attribute = [ImagingDataSetControlVisibility.from_dict(visibility) for visibility in attribute] - control.__dict__[prop] = attribute - return control - - -class ImagingDataSetConfig(AbstractImagingClass): - adaptor: str - version: float - speeds: list[int] - resolutions: list[str] - playable: bool - exports: list[ImagingDataSetControl] - inputs: list[ImagingDataSetControl] - metadata: dict - - def __init__(self, adaptor: str, version: float, resolutions: list[str], playable: bool, - speeds: list[int] = None, exports: list[ImagingDataSetControl] = None, - inputs: list[ImagingDataSetControl] = None, metadata: dict = None): - self.__dict__["@type"] = "dss.dto.imaging.ImagingDataSetConfig" - self.adaptor = adaptor - self.version = version - self.resolutions = resolutions - self.playable = playable - if playable: - self.speeds = speeds - self.exports = exports - self.inputs = inputs - self.metadata = metadata - - @classmethod - def from_dict(cls, data): - if data is None: - return None - config = cls(None, None, None, None) - for prop in cls.__annotations__.keys(): - attribute = data.get(prop) - if prop in ['exports', 'inputs'] and attribute is not None: - attribute = [ImagingDataSetControl.from_dict(control) for control in attribute] - config.__dict__[prop] = attribute - return config - - -class ImagingDataSetImage(AbstractImagingClass): - previews: list[ImagingDataSetPreview] - config: dict - metadata: dict - - def __init__(self, config=None, previews=None, metadata=None): - self.__dict__["@type"] = "dss.dto.imaging.ImagingDataSetImage" - self.config = config if config is not None else dict() - self.previews = previews if previews is not None else [] - self.metadata = metadata if metadata is not None else dict() - - def add_preview(self, preview): - self.previews += [preview] - - @classmethod - def from_dict(cls, data): - if data is None: - return None - image = cls(None, None, None) - for prop in cls.__annotations__.keys(): - attribute = data.get(prop) - if prop == 'images' and attribute is not None: - attribute = [ImagingDataSetPreview.from_dict(image) for image in attribute] - image.__dict__[prop] = attribute - return image - - -class ImagingDataSetPropertyConfig(AbstractImagingClass): - config: ImagingDataSetConfig - images: list[ImagingDataSetImage] - - def __init__(self, config: ImagingDataSetConfig, images: list[ImagingDataSetImage]): - assert config is not None, "Config must not be None!" - self.__dict__["@type"] = "dss.dto.imaging.ImagingDataSetPropertyConfig" - self.config = config - self.images = images if images is not None else [] - - @classmethod - def from_dict(cls, data: dict): - assert data is not None and any(data), "There is no property config found!" - config = ImagingDataSetConfig.from_dict(data.get('config')) - attr = data.get('images') - images = [ImagingDataSetImage.from_dict(image) for image in attr] if attr is not None else None - return cls(config, images) - - def add_image(self, image: ImagingDataSetImage): - if self.images is None: - self.images = [] - self.images += [image] - - -class ImagingControl: - - def __init__(self, openbis_instance, service_name=DEFAULT_SERVICE_NAME): - self._openbis = openbis_instance - self._service_name = service_name - - def _execute_custom_dss_service(self, parameters): - service_id = { - "@type": "dss.dto.service.id.CustomDssServiceCode", - "permId": self._service_name - } - options = { - "@type": "dss.dto.service.CustomDSSServiceExecutionOptions", - "parameters": parameters - } - request = { - "method": "executeCustomDSSService", - "params": [ - self._openbis.token, - service_id, - options - ], - } - full_url = urljoin(self._openbis._get_dss_url(), self._openbis.dss_v3) - return self._openbis._post_request_full_url(full_url, request) - - def make_preview(self, perm_id: str, index: int, preview: ImagingDataSetPreview) -> ImagingDataSetPreview: - parameters = { - "type": "preview", - "permId": perm_id, - "index": index, - "error": None, - "preview": preview.__dict__ - } - service_response = self._execute_custom_dss_service(parameters) - if service_response['error'] is None: - preview.__dict__ = service_response["preview"] - return preview - else: - raise ValueError(service_response['error']) - - def get_export_url(self, perm_id: str, export: ImagingDataSetExport, image_index: int = 0) -> str: - parameters = { - "type": "export", - "permId": perm_id, - "index": image_index, - "error": None, - "url": None, - "export": export.__dict__ - } - service_response = self._execute_custom_dss_service(parameters) - if service_response['error'] is None: - return service_response['url'] - else: - raise ValueError(service_response['error']) - - def get_multi_export_url(self, exports: list[ImagingDataSetMultiExport]) -> str: - parameters = { - "type": "multi-export", - "error": None, - "url": None, - "exports": [export.__dict__ for export in exports] - } - service_response = self._execute_custom_dss_service(parameters) - if service_response['error'] is None: - return service_response['url'] - else: - raise ValueError(service_response['error']) - - def single_export_download(self, perm_id: str, export: ImagingDataSetExport, image_index: int = 0, directory_path=""): - export_url = self.get_export_url(perm_id, export, image_index) - self._download(export_url, directory_path) - - def multi_export_download(self, exports: list[ImagingDataSetMultiExport], directory_path=""): - export_url = self.get_multi_export_url(exports) - self._download(export_url, directory_path) - - def _download(self, url, directory_path=""): - get_response = requests.get(url, stream=True) - file_name = url.split("/")[-1] - with open(os.path.join(directory_path, file_name), 'wb') as f: - for chunk in get_response.iter_content(chunk_size=1024): - if chunk: - f.write(chunk) - - def get_property_config(self, perm_id: str) -> ImagingDataSetPropertyConfig: - dataset = self._openbis.get_dataset(perm_id) - imaging_property = json.loads(dataset.props[IMAGING_CONFIG_PROP_NAME]) - return ImagingDataSetPropertyConfig.from_dict(imaging_property) - - def update_property_config(self, perm_id: str, config: ImagingDataSetPropertyConfig): - dataset = self._openbis.get_dataset(perm_id) - dataset.props[IMAGING_CONFIG_PROP_NAME] = config.to_json() - dataset.save() - - -# o = get_instance() -# -# -# # imaging_preview = ImagingDataSetPreview(preview_format="png", config=config_sxm) -# # response = get_preview('20231110130838616-26', 0, imaging_preview) -# # print(response) -# -# config_export = { -# "include": ['image', 'raw data'], -# "image-format": 'original', -# "archive-format": "zip", -# "resolution": "original" -# } -# # imaging_export = ImagingDataSetExport(config_export) -# # export_response = get_export('20231110130838616-26', 0, imaging_export) -# # print(export_response) -# -# -# # imaging_export1 = ImagingDataSetMultiExport('20231110130838616-26', 0, config_export) -# # imaging_export2 = ImagingDataSetMultiExport('20231110134813653-27', 0, config_export) -# # multi_export_response = get_multi_export([imaging_export1, imaging_export2]) -# # print(multi_export_response) -# -# -# # imaging_property_config = get_property_config('20231110134813653-27') -# # print(imaging_property_config.to_json()) -# -# ic = ImagingControl(o) -# perm_id = '20231110130838616-26' -# pc = ic.get_property_config(perm_id) -# -# -# -# config_sxm_preview = { -# "channel": "z", # usually one of these: ['z', 'I', 'dIdV', 'dIdV_Y'] -# "x-axis": [1.2, 3.0], # file dependent -# "y-axis": [1.2, 3.0], # file dependent -# "color-scale": [-700.0, 700.0], # file dependend -# "colormap": "gray", # [gray, YlOrBr, viridis, cividis, inferno, rainbow, Spectral, RdBu, RdGy] -# "scaling": "linear", # ['linear', 'logarithmic'] -# # "mode": 3 # uncomment this if you want to generate random pixel image generation -# } -# -# # imaging_preview = ImagingDataSetPreview(preview_format="png", config=config_sxm_preview) -# # -# # preview = ic.make_preview(perm_id, 0, imaging_preview) -# # pc.images[0].add_preview(preview) -# # ic.update_property_config(perm_id, pc) -# # -# # print(ic.get_property_config(perm_id)) -# -# -# -# config_export = { -# "include": ['image', 'raw data'], -# "image-format": 'original', -# "archive-format": "zip", -# "resolution": "original" -# } -# imaging_export = ImagingDataSetExport(config_export) -# ic.single_export_download(perm_id, imaging_export, 0, '/home/alaskowski/PREMISE') - - - - - diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/python/tests/test_imaging.py b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/python/tests/test_imaging.py deleted file mode 100644 index 05b18b5f8343058bd3e75e620d00061693d3b297..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/source/python/tests/test_imaging.py +++ /dev/null @@ -1,119 +0,0 @@ -# Copyright ETH 2023 Zürich, Scientific IT Services -# -# 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. -# - -import unittest -import imaging.imaging as imaging -from unittest.mock import MagicMock -import json - -IMAGING_CONFIG_PROP_NAME = "$IMAGING_DATA_CONFIG".lower() - -PROPER_CONFIG = { - "config": { - "adaptor": "some.adaptor.class.MyAdaptorClass", - "version": 1.0, - "speeds": [1, 2, 5], - "resolutions": ["150dpi", "300dpi"], - "playable": True, - "exports": [{ - "label": "Archive", - "type": "Dropdown", - "values": ["zip", "tar.gz"], - "multiselect": False, - "metaData": {} - }], - "inputs": [{ - "label": "Option 1", - "section": "section", - "type": "Dropdown", - "values": ["a", "b", "c"], - "multiselect": True, - "playable": False, - "metaData": {} - }, { - "label": "Option 2", - "section": "section", - "type": "Slider", - "unit": "cm", - "range": ["1", "2", "0.1"], - "multiselect": False, - "playable": True, - "speeds": [1, 2, 5], - "metaData": {} - }, { - "label": "Option 2", - "section": "section", - "type": "Range", - "multiselect": False, - "playable": False, - "visibility": [{ - "label": "Option 1", - "values": ["a", "b"], - "range": ["1", "2", "0.1"], - "unit": "mm" - }, { - "label": "Option 1", - "values": ["c"], - "range": ["0", "100", "1"], - "unit": "px" - }], - "metaData": {} - }], - "metadata": {} - }, - "images": [{ - "previews": [{ - "config": {}, - "format": "png", - "bytes": "base64_encoded_bytes", - "show": False, - "metadata": {} - }], - "config": {}, - "metadata": {} - }] -} - - -class ImagingTestCase(unittest.TestCase): - - def setUp(self): - self.dataset_mock = MagicMock() - self.set_dataset_config(PROPER_CONFIG) - - self.openbis_mock = MagicMock() - self.openbis_mock.get_dataset.return_value = self.dataset_mock - - self.imaging_control = imaging.ImagingControl(self.openbis_mock) - - def set_dataset_config(self, config): - json_config = json.dumps(config) - self.dataset_mock.props = {IMAGING_CONFIG_PROP_NAME: json_config} - - def test_get_proper_config(self): - config = self.imaging_control.get_property_config('some_perm_id') - assert len(config.images) == 1 - assert len(config.images[0].previews) == 1 - - def test_get_empty_config(self): - self.set_dataset_config(None) - self.assertRaises(AssertionError, self.imaging_control.get_property_config, 'some_perm_id') - - #TODO expand tests - - - -if __name__ == '__main__': - unittest.main() diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/sourceTest/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/ImagingServiceTest.java b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/sourceTest/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/ImagingServiceTest.java deleted file mode 100644 index 9327e229c57d8619397e9f039f2ed07d6949bc55..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/sourceTest/java/ch/ethz/sis/openbis/generic/server/dss/plugins/imaging/ImagingServiceTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright ETH 2023 Zürich, Scientific IT Services - * - * 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.ethz.sis.openbis.generic.server.dss.plugins.imaging; - -import static org.junit.Assert.fail; - -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSetKind; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.create.DataSetCreation; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.create.PhysicalDataCreation; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.delete.DataSetDeletionOptions; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.DataSetPermId; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.FileFormatTypePermId; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.ProprietaryStorageFormatPermId; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.RelativeLocationLocatorTypePermId; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.datastore.id.DataStorePermId; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.EntityTypePermId; -import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.ExperimentIdentifier; -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.service.CustomDSSServiceExecutionOptions; -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.service.id.CustomDssServiceCode; -import ch.ethz.sis.openbis.generic.dssapi.v3.dto.service.id.ICustomDSSServiceId; -import ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.container.ImagingPreviewContainer; -import org.testng.annotations.Test; -import org.junit.Assert.*; - -import java.util.*; - - -public class ImagingServiceTest //extends AbstractFileTest -{ - - - @Test - public void testImagingService() throws Exception - { -// fail(); -// String sessionToken = as.login(TEST_USER, PASSWORD); -// -// DataSetPermId dataSetPermId = new DataSetPermId("TEST-IMAGING-" + UUID.randomUUID().toString()); -// createDirectories(workingDirectory, new HashSet<>(List.of("dss-root", "dss-root/store", "dss-root/store/1", -// "dss-root/store/1/" + dataSetPermId.getPermId()))); -// createFiles(workingDirectory, List.of("dss-root/store/1/" + dataSetPermId.getPermId() + "/file1.txt")); -// -// try -// { -// PhysicalDataCreation physicalCreation = new PhysicalDataCreation(); -// physicalCreation.setLocation(dataSetPermId.getPermId()); -// physicalCreation.setFileFormatTypeId(new FileFormatTypePermId("TIFF")); -// physicalCreation.setLocatorTypeId(new RelativeLocationLocatorTypePermId()); -// physicalCreation.setStorageFormatId(new ProprietaryStorageFormatPermId()); -// -// DataSetCreation creation = new DataSetCreation(); -// creation.setCode(dataSetPermId.getPermId()); -// creation.setDataSetKind(DataSetKind.PHYSICAL); -// creation.setTypeId(new EntityTypePermId("IMAGING_DATA")); -// creation.setExperimentId(new ExperimentIdentifier("/TEST-SPACE/TEST-PROJECT/EXP-SPACE-TEST")); -// creation.setDataStoreId(new DataStorePermId("STANDARD")); -// creation.setPhysicalData(physicalCreation); -// creation.setProperty("$IMAGING_DATA_CONFIG", "{\"config\" : { \"@type\" : \"dss.dto.imaging.ImagingDataSetConfig\", \"adaptor\" : \"ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.adaptor.ImagingDataSetExampleAdaptor\" } }"); -// -// -// List<DataSetPermId> ds = as.createDataSets(sessionToken, Arrays.asList(creation)); -// DataSetPermId pds = ds.get(0); -// -// ICustomDSSServiceId serviceId = new CustomDssServiceCode("imaging"); -// -// Map<String, Object> map = Map.of("@type", "dss.dto.imaging.ImagingDataSetPreview", -// "config", Map.of("Dimension 1", new Integer[] {1,2})); -// -// CustomDSSServiceExecutionOptions options = new CustomDSSServiceExecutionOptions(); -// options.withParameter("type", "preview"); -// options.withParameter("permId", pds.getPermId()); -// options.withParameter("index", 0); -// options.withParameter("preview", map); -// Object executionResult = dss.executeCustomDSSService(sessionToken, serviceId, options); -// -//// assertTrue(executionResult instanceof ImagingPreviewContainer); -//// ImagingPreviewContainer result = (ImagingPreviewContainer) executionResult; -//// -//// assertNotNull(result.getPreview().getBytes()); -// } -// finally -// { -// DataSetDeletionOptions options = new DataSetDeletionOptions(); -// options.setReason("cleanup"); -// as.deleteDataSets(sessionToken, Arrays.asList(dataSetPermId), options); -// as.logout(sessionToken); -// } - } - - - - - - - - - - - - -} diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/sourceTest/java/tests.xml b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/sourceTest/java/tests.xml deleted file mode 100644 index adca2f5bb61f4ab8b7dbd1fd9a9095959f9f7422..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/lib/premise-sources/sourceTest/java/tests.xml +++ /dev/null @@ -1,12 +0,0 @@ -<suite name="All" verbose="2"> - <test name="All" annotations="JDK"> - <groups> - <run> - <exclude name="broken" /> - </run> - </groups> - <packages> - <package name="ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.*" /> - </packages> - </test> -</suite> diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/nanonis_dat.py b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/nanonis_dat.py deleted file mode 100644 index 6b1c598587aa6ba994e31233e719ccbe49052e67..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/nanonis_dat.py +++ /dev/null @@ -1,119 +0,0 @@ -import numpy -from PIL import Image -import io -import base64 -import sys -import json -import os -import sys -from spmpy_terry import spm # <--- class spm defines objects of type spm with their attributes and class functions -import spmpy_terry as spmpy # <--- spmpy has other methods -from datetime import datetime - -import matplotlib.pyplot as plt -# %matplotlib inline - - -def load_image(path): - return spm(path) - - -def get_lock_in(img): - param_name = 'lock-in>lock-in status' - param = img.get_param(param_name) - return param - - -def get_channel(img, channel_name = 'z'): - # channel_name = 'z' - channel = img.get_channel(channel_name) - return channel - - -file = sys.argv[1] -image_params = json.loads(sys.argv[2]) -params = json.loads(sys.argv[3]) -meta_data = json.loads(sys.argv[4]) -format = sys.argv[5] - - -folder_dir = os.path.join(file, 'original') -file_path = os.path.join(folder_dir, os.listdir(folder_dir)[0]) -# print(file_path) - - -def generate_random_image(height, width): - imarray = numpy.random.rand(height,width,3) * 255 - im = Image.fromarray(imarray.astype('uint8')).convert('RGBA') - img_byte_arr = io.BytesIO() - im.save(img_byte_arr, format=format) - img_byte_arr = img_byte_arr.getvalue() - encoded = base64.b64encode(img_byte_arr) - return encoded - - -def get_dat_image(channel_x, channel_y, x_axis, y_axis, colormap, scaling, grouping, print_legend): - specs = spmpy.importall(folder_dir, '', 'spec') - - for spec in specs: - date_time = spec.get_param('Saved Date') - spec.date_time = datetime.strptime(date_time, "%d.%m.%Y %H:%M:%S") - - # sort measurements according to date - specs.sort(key=lambda d: d.date_time) - specs_sub = list(filter(lambda spec:spec.name in grouping, specs)) - - print_legend = print_legend - show = False - fig = spmpy.specs_plot(specs_sub, channelx=channel_x, channely=channel_y, direction='forward', - print_legend=print_legend, show=show, colormap=colormap, scaling=scaling, - x_axis=x_axis, y_axis=y_axis) - - img_byte_arr = io.BytesIO() - plt.savefig(img_byte_arr, format=format) - img_byte_arr = img_byte_arr.getvalue() - encoded = base64.b64encode(img_byte_arr) - return encoded - - - - - -print(params) -if 'mode' in params: - if params['mode'] == '1': - print(generate_random_image(640, 640)) - elif params['mode'] == '2': - parameters = dict( - channel_x=params['channel x'], - channel_y=params['channel y'], - x_axis=[float(x) for x in params['x-axis']], - y_axis=[float(x) for x in params['y-axis']], - colormap=params['colormap'], - scaling=params['scaling'], - grouping=params['grouping'] - ) - if "color" in params: - parameters['color'] = params['color'] - if "print_legend" in params: - parameters['print_legend'] = params['print_legend'].upper() == "TRUE" - else: - parameters['print_legend'] = True - print(get_dat_image(**parameters)) -else: - parameters = dict( - channel_x=params['channel x'], - channel_y=params['channel y'], - x_axis=[float(x) for x in params['x-axis']], - y_axis=[float(x) for x in params['y-axis']], - colormap=params['colormap'], - scaling=params['scaling'], - grouping=params['grouping'] - ) - if "color" in params: - parameters['color'] = params['color'] - if "print_legend" in params: - parameters['print_legend'] = params['print_legend'].upper() == "TRUE" - else: - parameters['print_legend'] = True - print(get_dat_image(**parameters)) diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/nanonis_sxm.py b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/nanonis_sxm.py deleted file mode 100644 index 476d27f5a0a1b8e2499b30121a5bbd2aaf7ecc5f..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/nanonis_sxm.py +++ /dev/null @@ -1,100 +0,0 @@ -import numpy -from PIL import Image -import io -import base64 -import sys -import json -import os -import sys -from spmpy_terry import spm # <--- class spm defines objects of type spm with their attributes and class functions -import spmpy_terry as spmpy # <--- spmpy has other methods - -import matplotlib.pyplot as plt -# %matplotlib inline - - -class NumpyEncoder(json.JSONEncoder): - def default(self, obj): - if isinstance(obj, numpy.ndarray): - return obj.tolist() - return json.JSONEncoder.default(self, obj) - -def load_image(path): - return spm(path) - - -def get_lock_in(img): - param_name = 'lock-in>lock-in status' - param = img.get_param(param_name) - return param - - -def get_channel(img, channel_name = 'z'): - # channel_name = 'z' - channel = img.get_channel(channel_name) - return channel - -print("SYS.ARGV:" + str(sys.argv)) -file = sys.argv[1] -image_params = json.loads(sys.argv[2]) -params = json.loads(sys.argv[3]) -meta_data = json.loads(sys.argv[4]) -format = sys.argv[5] - - -folder_dir = os.path.join(file, 'original') -file_path = os.path.join(folder_dir, os.listdir(folder_dir)[0]) - - -def generate_random_image(height, width): - imarray = numpy.random.rand(height,width,3) * 255 - im = Image.fromarray(imarray.astype('uint8')).convert('RGBA') - img_byte_arr = io.BytesIO() - im.save(img_byte_arr, format='PNG') - img_byte_arr = img_byte_arr.getvalue() - encoded = base64.b64encode(img_byte_arr) - return encoded - - -def get_sxm_image(channel_name, x_axis, y_axis, scaling, color_scale, colormap, colormap_scaling): - img = load_image(file_path) - img_byte_arr = io.BytesIO() - - log = False - if scaling == 'logarithmic': - log = True - fig = img.plot(show=False, show_params=False, channel=channel_name, log=log, cmap=colormap, - color_scale=color_scale, x_axis=x_axis, y_axis=y_axis, colormap_scaling=colormap_scaling) - plt.savefig(img_byte_arr, format=format) - - img_byte_arr = img_byte_arr.getvalue() - encoded = base64.b64encode(img_byte_arr) - print_params = img.print_params(show=False).split('\n') - print_params = {x: y for x, y in (s.split(':') for s in print_params)} - print_params = json.dumps(print_params) - print(f'PARAMS={print_params}') - header = json.dumps(img.header, cls=NumpyEncoder) - print(f'HEADER={header}') - - return encoded - -def sxm_mode(parameters): - channel = parameters['channel'] - x_axis = [float(x) for x in parameters['x-axis']] - y_axis = [float(x) for x in parameters['y-axis']] - color_scale = [float(x) for x in parameters['color-scale']] - colormap = parameters['colormap'] - scaling = parameters['scaling'] - colormap_scaling = False - if "colormap_scaling" in parameters: - colormap_scaling = parameters['colormap_scaling'].upper() == "TRUE" - print(f'{get_sxm_image(channel, x_axis, y_axis, scaling, color_scale, colormap, colormap_scaling)}') - -print(params) -if 'mode' in params: - if params['mode'] == '3': - print(f'{generate_random_image(256, 256)}') - elif params['mode'] == '5': - sxm_mode(params) -else: - sxm_mode(params) \ No newline at end of file diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/plugin.properties b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/plugin.properties deleted file mode 100644 index a669c47e3ac56fd9df98e0c6dfb85f0f2795071a..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/plugin.properties +++ /dev/null @@ -1,8 +0,0 @@ -label = PremiseImagingService - -class2 = ch.ethz.sis.openbis.generic.server.dss.plugins.PingPongService -class = ch.ethz.sis.openbis.generic.server.dss.plugins.imaging.ImagingService - -python3-path = /home/alaskowski/virtualenv_python/bin/python3 -nanonis-sxm = nanonis_sxm.py -nanonis-dat = nanonis_dat.py diff --git a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/spmpy_terry.py b/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/spmpy_terry.py deleted file mode 100644 index 57702f4aef451c718be269e712179144f2ec8499..0000000000000000000000000000000000000000 --- a/core-plugin-openbis/dist/core-plugins/imaging/1/dss/custom-services/imaging/spmpy_terry.py +++ /dev/null @@ -1,970 +0,0 @@ - # -*- coding: utf-8 -*- -""" -Created on Tue Jan 3 15:13:13 2017 - -@author: Bruno Schuler -""" - -############################################## -# spm_matrix class -############################################## - -# This module provides functions to load and display Nanonis files - -# requires packages: -# pip install numpy -# pip install six -# pip install nanonispy -# pip install spiepy - -import os as os -import numpy as np -import nanonispy as nap -import spiepy -import warnings -import matplotlib.pyplot as plt -import matplotlib.pylab as pl - -class spm: - - #Dictionary Channels - ChannelName = ['LI_Demod_1_X','LI_Demod_1_Y','Z','Current','Bias','Frequency_Shift','Amplitude','Excitation','Temperature_1', - 'Bias (V)','Bias calc (V)', 'Bias [bwd] (V)', 'Current (A)','Current [bwd] (A)','Amplitude (m)', - 'Amplitude [bwd] (m)', 'Excitation (V)', 'Excitation [bwd] (V)', 'Frequency Shift (Hz)', 'Frequency Shift [bwd] (Hz)', - 'LI Demod 1 X (A)','LI Demod 1 X (A) [bwd] (A)','PMT (V)','Counter 1 (Hz)','Counter_1', 'Z rel (m)', 'Z (m)','Time (s)', - 'Delay Sampling (s)','LI Demod 0 X (V)','LI Demod 0 Y (V)','LI Demod 3 X (A)','LI Demod 3 Y (A)', - 'Position Phase1 (m)','Rotation1 (deg)','Rotation2 (deg)','Rotation (deg)','Index'] - ChannelNickname = ['dIdV','dIdV_Y','z','I','V','df','A','exc','T1', - 'V', 'V', 'V_bw' ,'I','I_bw','A', - 'A_bw', 'exc','exc_bw','df','df_bw', - 'dIdV','dIdV_bw','PMT','counter','counter', 'zrel','zspec','t', - 'Delay','EOS','EOS_Y','I_THz','I_THz_Y', - 'Phase','Rot1','Rot2','Rot','Index'] - ChanneliScaling = [10**12,10**12,10**9,10**12,1,1,10**9,1,1, - 1,1,1,10**12,10**12,10**9, - 10**9,1,1,1,1,1, - 1,1,1,1,10**12,10**9,1, - 10**12,1,1,10**12,10**12, - 10**3,1,1,1,1] - ChannelUnit = ['pS','pS','nm','pA','V','Hz','nm','V','K', - 'V','V','V','pA','pA','nm', - 'nm','V','V','Hz','Hz','a.u.', - 'a.u.','V','Hz','Hz','pm','nm','s', - 'ps','V','V','pA','pA', - 'mm','deg','deg','deg','N'] - - global SignalsListReference - SignalsListReference = [] - - for (chName,chNickname,chScaling,chUnit) in zip(ChannelName,ChannelNickname,ChanneliScaling,ChannelUnit): - SignalsListReference.append({'ChannelName': chName, 'ChannelNickname': chNickname , 'ChannelScaling': chScaling, 'ChannelUnit': chUnit}) - - del ChannelName,ChanneliScaling,ChannelUnit - del chName,chNickname,chScaling,chUnit - - #Dictionary Parameters - ParamName = ['X (m)','Y (m)','Z (m)','bias','z-controller>setpoint','scan_angle','Comments','Comment01', - 'Lock-in>Amplitude','Lock-in>Reference phase D1 (deg)','Lock-in>Frequency (Hz)','Temperature 2>Temperature 2 (K)', - 'Current>Current (A)','Bias>Bias (V)','z-controller>tiplift (m)', - 'Parameter>Delay Sampling (s)','Parameter>Delay PP1 (s)','Parameter>Delay PP2 (s)','Parameter>Angle Rot1 (deg)','Parameter>Angle Rot2 (deg)','Parameter>Position Phase1 (m)','Parameter>Position_Phase1 (m)'] - ParamNickname = ['x','y','z','V','setpoint','angle','comment','comment_spec', - 'lockin_amplitude','lockin_phase','lockin_frequency','temperature', - 'setpoint_spec','V_spec','z_offset', - 'Sampling','PP1','PP2','Rot1','Rot2','Phase','Phase_depricated'] - ParamScaling = [10**9,10**9,10**9,1,10**12,1,'na','na', - 10**3,1,1,1, - 10**12,1,10**9, - 10**12,10**12,10**12,1,1,10**3,10**3] # na if not a numeric value - ParamUnit = ['nm','nm','nm','V','pA','°','','', - 'mV','°','Hz','K', - 'pA','V','nm', - 'ps','ps','ps','deg','deg','mm','mm'] - - - global ParamListReference - ParamListReference = [] - - for (paName,paNickname,paScaling,paUnit) in zip(ParamName,ParamNickname,ParamScaling,ParamUnit): - ParamListReference.append({'ParamName': paName, 'ParamNickname': paNickname, 'ParamScaling': paScaling, 'ParamUnit': paUnit}) - - del ParamName,ParamScaling,ParamUnit - del paName,paNickname,paScaling,paUnit - - # constructor - def __init__(self,path): - #import os as os - #import numpy as np - #import nanonispy as nap - - - # self.path = path.replace('//', '/') - abspath = os.path.abspath(path) - self.path = '/'.join(abspath.split('\\')[-4:]) - self.name = self.path.split('/')[-1] - file_extension = os.path.splitext(path)[1] - - if file_extension == '.sxm': - self.napImport = nap.read.Scan(path) - self.type = 'scan' - elif file_extension == '.dat': - self.napImport = nap.read.Spec(path) - self.type = 'spec' - else: - print('Datatype not supported.') - return; - - ch = [] - for key in self.napImport.signals: - try: - ch.append([d['ChannelName'] for d in SignalsListReference].index(key)) - except: - pass; - - self.SignalsList = [SignalsListReference[i] for i in ch] #List of all recorded channels - self.channels = [c['ChannelNickname'] for c in self.SignalsList] - self.header = self.napImport.header - - - def __repr__(self): - return self.path - - #get channel - def get_channel(self,channel,direction = 'forward', flatten = False, offset = False,zero = False): - - #import spiepy - #import numpy as np - - if self.type == 'scan': - chNum = [d['ChannelNickname'] for d in self.SignalsList].index(channel) - im = self.napImport.signals[self.SignalsList[chNum]['ChannelName']][direction] - im = im *self.SignalsList[chNum]['ChannelScaling'] - - if flatten: - if ~np.isnan(np.sum(im)): - im, _ = spiepy.flatten_xy(im) - else: - m,n = np.shape(im) - i = np.argwhere(np.isnan(im))[0,0] - im_cut = im[:i-1,:] - im, _ = spiepy.flatten_xy(im_cut) - empty = np.full((m-i,n),np.nan) - im = np.vstack((im,empty)) - - warnings.warn('NaN values in image') - #im-np.nanmean(im) - - if offset: - im = im-np.mean(im) - if zero: - im = im+abs(np.min(im)) - - unit = self.SignalsList[chNum]['ChannelUnit'] - - return (im,unit) - - elif self.type == 'spec': - - if direction == 'backward': - channel = channel + '_bw'; - #print(channel) - - chNum = [d['ChannelNickname'] for d in self.SignalsList].index(channel) - data = self.napImport.signals[self.SignalsList[chNum]['ChannelName']] - data = data*self.SignalsList[chNum]['ChannelScaling'] - unit = self.SignalsList[chNum]['ChannelUnit'] - - return (data,unit) - - return - - #get parameter - def get_param(self,param): - - if any(d['ParamNickname'] == param for d in ParamListReference): - paNum = [d['ParamNickname'] for d in ParamListReference].index(param) - - if ParamListReference[paNum]['ParamScaling'] == 'na': - return self.napImport.header[ParamListReference[paNum]['ParamName']] - else: - return (float(self.napImport.header[ParamListReference[paNum]['ParamName']])*ParamListReference[paNum]['ParamScaling'],ParamListReference[paNum]['ParamUnit']) - - - elif param == 'width' or param == 'height': - # height, width = self.get_param('scan_range') - # height, width = [height*10**9, width*10**9] - scanfield = self.get_param('scan>scanfield') - width, height = float(scanfield.split(';')[2])*10**9, float(scanfield.split(';')[3])*10**9 - - return (eval(param),'nm') - - - else: - if param in self.napImport.header.keys(): - return self.napImport.header[param] - else: - return - - - - # print essential parameters for plotting - def print_params(self, show = True): - - # import numpy as np - - label = [] - - if self.type == 'scan': - fb_enable = self.get_param('z-controller>controller status') - fb_ctrl = self.get_param('z-controller>controller name') - bias = self.get_param('V') - set_point = self.get_param('setpoint') - height = self.get_param('height') - width = self.get_param('width') - angle = self.get_param('angle') - z_offset = self.get_param('z_offset') - comment = self.get_param('comments') - - - - if fb_enable == 'OFF': - label.append('constant height') - label.append('z-offset: %.3f%s' % z_offset) - - if np.abs(bias[0])<0.1: - bias = list(bias) - bias[0] = bias[0]*1000 - bias[1] = 'mV' - bias = tuple(bias) - - label.append('I: %.0f%s' % set_point) - label.append('bias: %.2f%s' % bias) - label.append('size: %.1f%s x %.1f%s (%.0f%s)' % (width+height+angle)) - label.append('comment: %s' % comment) - - - elif self.type == 'spec': - - fb_enable = self.get_param('Z-Ctrl hold') - set_point = self.get_param('setpoint_spec') - bias = self.get_param('V_spec') - #lockin_status = self.get_param('Lock-in>Lock-in status') - lockin_amplitude = self.get_param('lockin_amplitude') - lockin_phase= self.get_param('lockin_phase') - lockin_frequency= self.get_param('lockin_frequency') - comment = self.get_param('comment_spec') - - - #if lockin_status == 'ON': - label.append('lockin: A = %.0f%s (θ = %.0f%s, f = %.0f%s)' % (lockin_amplitude+lockin_phase+lockin_frequency)) - - - if fb_enable == 'FALSE': - label.append('feedback: on') - - elif fb_enable == 'TRUE': - label.append('feedback: off') - - - label.append('setpoint: I = %.0f%s, V = %.1f%s' % (set_point+bias)) - - label.append('comment: %s' % comment) - - label.append('path: %s' % self.path) - label = '\n'.join(label) - - if show: - print(label) - - return label - - - - # plot - def plot(self, **params): - import numpy as np - #import matplotlib as ml - import matplotlib.pyplot as plt - from matplotlib.colors import LogNorm - - #cmaps = sorted(m for m in plt.cm.datad) - # ['Accent', 'Accent_r', 'Blues', 'Blues_r', 'BrBG', 'BrBG_r', 'BuGn', 'BuGn_r', 'BuPu', 'BuPu_r', 'CMRmap', 'CMRmap_r', 'Dark2', 'Dark2_r', 'GnBu', 'GnBu_r', 'Greens', 'Greens_r', 'Greys', 'Greys_r', 'OrRd', 'OrRd_r', 'Oranges', 'Oranges_r', 'PRGn', 'PRGn_r', 'Paired', 'Paired_r', 'Pastel1', 'Pastel1_r', 'Pastel2', 'Pastel2_r', 'PiYG', 'PiYG_r', 'PuBu', 'PuBuGn', 'PuBuGn_r', 'PuBu_r', 'PuOr', 'PuOr_r', 'PuRd', 'PuRd_r', 'Purples', 'Purples_r', 'RdBu', 'RdBu_r', 'RdGy', 'RdGy_r', 'RdPu', 'RdPu_r', 'RdYlBu', 'RdYlBu_r', 'RdYlGn', 'RdYlGn_r', 'Reds', 'Reds_r', 'Set1', 'Set1_r', 'Set2', 'Set2_r', 'Set3', 'Set3_r', 'Spectral', 'Spectral_r', 'Wistia', 'Wistia_r', 'YlGn', 'YlGnBu', 'YlGnBu_r', 'YlGn_r', 'YlOrBr', 'YlOrBr_r', 'YlOrRd', 'YlOrRd_r', 'afmhot', 'afmhot_r', 'autumn', 'autumn_r', 'binary', 'binary_r', 'bone', 'bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r', 'cool', 'cool_r', 'coolwarm', 'coolwarm_r', 'copper', 'copper_r', 'cubehelix', 'cubehelix_r', 'flag', 'flag_r', 'gist_earth', 'gist_earth_r', 'gist_gray', 'gist_gray_r', 'gist_heat', 'gist_heat_r', 'gist_ncar', 'gist_ncar_r', 'gist_rainbow', 'gist_rainbow_r', 'gist_stern', 'gist_stern_r', 'gist_yarg', 'gist_yarg_r', 'gnuplot', 'gnuplot2', 'gnuplot2_r', 'gnuplot_r', 'gray', 'gray_r', 'hot', 'hot_r', 'hsv', 'hsv_r', 'jet', 'jet_r', 'nipy_spectral', 'nipy_spectral_r', 'ocean', 'ocean_r', 'pink', 'pink_r', 'prism', 'prism_r', 'rainbow', 'rainbow_r', 'seismic', 'seismic_r', 'spectral', 'spectral_r', 'spring', 'spring_r', 'summer', 'summer_r', 'terrain', 'terrain_r', 'winter', 'winter_r'] - - #ml.interactive(0) - - if self.type == 'scan': - - if 'channel' in params: - channel = params['channel'] - else: - channel = self.channels[0] - - if 'direction' in params: - direction = params['direction'] - else: - direction = 'forward' - - if 'flatten' in params: - flatten = params['flatten'] - else: - flatten = False - - if 'offset' in params: - offset = params['offset'] - else: - offset = False - - if 'cmap' in params: - cmap = params['cmap'] - else: - cmap = 'gray' - - if 'clim' in params: - clim = params['clim'] - else: - clim = False - - if 'log' in params: - log = params['log'] - else: - log = False - - if 'show_params' in params: - show_params = params['show_params'] - else: - show_params = False - - if 'show' in params: - show = params['show'] - else: - show = True - - # PREMISE - specific params - - if 'hide' in params: - hide = params['hide'] - else: - hide = False - - if 'color_scale' in params: - color_scale = params['color_scale'] - else: - color_scale = False - - if 'x_axis' in params: - x_axis = params['x_axis'] - else: - x_axis = False - - if 'y_axis' in params: - y_axis = params['y_axis'] - else: - y_axis = False - - if 'colormap_scaling' in params: - colormap_scaling = params['colormap_scaling'] - else: - colormap_scaling = False - - - - (chData,chUnit) = self.get_channel(channel, direction = direction, flatten=flatten, offset=offset); - - if direction == 'backward': - chData = np.fliplr(chData) - - width = self.get_param('width') - height = self.get_param('height') - pix_y,pix_x = np.shape(chData) - - # fig = plt.figure(figsize=(6, 4)) - fig = plt.figure()#figsize=(6,4)) - - - ImgOrigin = 'lower' - if self.get_param('scan_dir') == 'down': - ImgOrigin = 'upper' - - if color_scale: - chData = np.clip(chData, color_scale[0], color_scale[1]) - - if x_axis and y_axis: - plt.ylim(y_axis[0], y_axis[1]) - plt.xlim(x_axis[0], x_axis[1]) - # plt.axis([x_axis[0], x_axis[1], y_axis[0], y_axis[1]]) - - plot_params = dict( - X = np.abs(chData) if log else chData, - aspect = 'equal', - extent = [0,width[0],0,height[0]], - cmap = cmap, - origin = ImgOrigin, - interpolation = 'none' - ) - if log: - plot_params['norm'] = LogNorm() - - if colormap_scaling: - min_x = x_axis[0] - max_x = x_axis[1] - min_y = y_axis[0] - max_y = y_axis[1] - - shape = chData.shape - minx = int(np.floor(shape[0] * min_x / width[0])) - maxx = int(np.ceil(shape[0] * max_x / width[0])) - miny = int(np.floor(shape[1] * min_y / height[0])) - maxy = int(np.ceil(shape[1] * max_y / height[0])) - - mini = np.min(chData[minx:maxx, miny:maxy]) - maxi = np.max(chData[minx:maxx, miny:maxy]) - - mini = int(mini*100)/100 - maxi = int(maxi*100)/100 - plot_params['vmin'] = mini - plot_params['vmax'] = maxi - - im = plt.imshow(**plot_params) - - # if log: - # im = plt.imshow(np.abs(chData), aspect = 'equal', extent = [0,width[0],0,height[0]], cmap = cmap, norm=LogNorm(), origin = ImgOrigin) - # else: - # im = plt.imshow(chData, aspect = 'equal',extent = [0,width[0],0,height[0]], cmap = cmap, origin = ImgOrigin) - - - if clim: - plt.clim(clim) - - - # im.axes.set_xticks([0,width[0]]) - # im.axes.set_xticklabels([0,np.round(width[0],2)]) - # im.axes.set_yticks([0,height[0]]) - # im.axes.set_yticklabels([0,np.round(height[0],2)]) - - if show_params: - title = self.print_params(show = False); - else: - title = self.path - - if not hide: - # plt.title(title + '\n', loc='left') - plt.xlabel('x (%s)' % width[1]) - plt.ylabel('y (%s)' % height[1]) - print(f'AXES={im.axes}') - cbar = plt.colorbar(im)#,fraction=0.046, pad=0.02, format='%.2g',shrink = 0.5,aspect=10) - cbar.set_label('channel:%s (%s)' % (channel,chUnit)) - - if show: - plt.show() - # else: - # plt.close(fig) - - return fig - - - - elif self.type == 'spec': - - - if 'channelx' in params: - channelx = params['channelx'] - else: - channelx = self.channels[0] - - if 'channely' in params: - channely = params['channely'] - else: - channely = self.channels[1] - - if 'direction' in params: - direction = params['direction'] - else: - direction = direction = 'forward' - - if 'log' in params: - log = params['log'] - else: - log = False - - if 'loglog' in params: - loglog = params['loglog'] - else: - loglog = False - - - if 'show_params' in params: - show_params = params['show_params'] - else: - show_params = False - - if 'show' in params: - show = params['show'] - else: - show = True - - - (x_data,x_unit) = self.get_channel(channelx,direction=direction) - (y_data,y_unit) = self.get_channel(channely,direction=direction) - - - fig = plt.figure(figsize=(6,4)) - - if log: - plt.semilogy(x_data,np.abs(y_data)) - - elif loglog: - plt.loglog(np.abs(x_data),np.abs(y_data)) - - else: - plt.plot(x_data,y_data) - - - if show_params: - title = self.print_params(show = False); - else: - title = self.path - - plt.title(title + '\n', loc='left') - - plt.xlabel('%s (%s)' % (channelx,x_unit)) - plt.ylabel('%s (%s)' % (channely,y_unit)) - - if show: - plt.show() - else: - plt.close(fig) - - return fig - - - - - -############################################## -# functions for spm class -############################################## - - -# import all files in folder as list of spm objects -def importall(FilePath,FilePrefix = '',ImportOnly = '' ): - - from os import walk - - files = [] - NumSpec = 0 - NumScan = 0 - - - for root, dirs, filenames in walk(FilePath): - for file in filenames: - if file.endswith(".sxm") and file.startswith(FilePrefix): - if not(ImportOnly == 'spec'): - files.append(spm(root + '/' + file)) - NumScan = NumScan + 1 - elif file.endswith(".dat") and file.startswith(FilePrefix): - if not(ImportOnly == 'scan'): - files.append(spm(root + '/' + file)) - NumSpec = NumSpec + 1 - - print(str(len(files)) + ' files imported; ' + str(NumScan) + ' scan(s) and ' + str(NumSpec) + ' spectra') - - return files - -# def importspecific(FilePath,FileList,FilePrefix = '',ImportOnly = '' ): - -# from os import walk - -# files = [] -# NumSpec = 0 -# NumScan = 0 - - -# for root, dirs, filenames in walk(FilePath): -# for file in filenames: -# if (file in FileList): -# if file.endswith(".sxm") and file.startswith(FilePrefix): -# if not(ImportOnly == 'spec'): -# files.append(spm(root + '/' + file)) -# NumScan = NumScan + 1 -# elif file.endswith(".dat") and file.startswith(FilePrefix): -# if not(ImportOnly == 'scan'): -# files.append(spm(root + '/' + file)) -# NumSpec = NumSpec + 1 - -# print(str(len(files)) + ' files imported; ' + str(NumScan) + ' scan(s) and ' + str(NumSpec) + ' spectra') - -# return files - - - - -def specs_plot(specs,**params): -# plot spectra in list - - #import matplotlib.pyplot as plt - - if 'channelx' in params: - channelx = params['channelx'] - else: - channelx = specs[0].channels[0] - - if 'channely' in params: - channely = params['channely'] - else: - channely = specs[0].channels[1] - - if 'direction' in params: - direction = params['direction'] - else: - direction = list(specs[0].data.keys())[0] - - if 'color' in params: - color = params['color'] - else: - color = pl.cm.rainbow(np.linspace(0,1,len(specs))) - if 'print_legend' in params: - print_legend = params['print_legend'] - else: - print_legend = False - if 'offset' in params: - offset = params['offset'] - else: - offset = 0 - - # PREMISE specific - if 'show' in params: - show = params['show'] - else: - show = True - - if 'colormap' in params: - colormap = params['colormap'] - cmap = plt.get_cmap(colormap) - color = cmap(np.linspace(0,1,len(specs))) - else: - colormap = False - - if 'scaling' in params: - scaling = params['scaling'] - else: - scaling = False - - if 'x_axis' in params: - x_axis = params['x_axis'] - else: - x_axis = False - - if 'y_axis' in params: - y_axis = params['y_axis'] - else: - y_axis = False - ####### - - fig = plt.figure(figsize=(6,4)) - - counter = 0 - for (s, c) in zip(specs, color): - - (x_data, x_unit) = s.get_channel(channelx, direction=direction) - if x_axis: - x_data = np.clip(x_data, x_axis[0], x_axis[1]) - - (y_data, y_unit) = s.get_channel(channely, direction=direction) - if y_axis: - y_data = np.clip(y_data, y_axis[0], y_axis[1]) - - if scaling: - if scaling == 'lin-lin': - plt.plot(x_data, y_data, color=c, label=s.name) - elif scaling == "lin-log": - plt.semilogy(x_data, np.abs(y_data), color=c, label=s.name) - elif scaling == 'log-lin': - plt.semilogx(np.abs(x_data), y_data, color=c, label=s.name) - elif scaling == 'log-log': - plt.loglog(np.abs(x_data), np.abs(y_data), color=c, label=s.name) - else: - plt.plot(x_data, y_data, color=c, label=s.name) - else: - plt.plot(x_data,y_data+counter*offset,color = c,label = s.name) - counter = counter + 1 - - plt.xlabel('%s (%s)' % (channelx,x_unit)) - plt.ylabel('%s (%s)' % (channely,y_unit)) - - if print_legend: - plt.legend() - - if show: - plt.show() - - return fig - - -def relative_position(img,spec,**params): - - #width = ref.get_param('width') - #height = ref.get_param('height') - #[px_x,px_y] = ref.get_param('scan_pixels') - - [o_x,o_y] = img.get_param('scan_offset') - width = img.get_param('width')[0] - height = img.get_param('height')[0] - [o_x,o_y] = [o_x*10**9,o_y*10**9] - - angle = float(img.get_param('scan_angle'))*-1* np.pi/180 - - - x_spec = spec.get_param('x')[0] - y_spec = spec.get_param('y')[0] - - if angle != 0: - #Transforming to relative coordinates with angle - x_rel = (x_spec-o_x)*np.cos(angle) + (y_spec-o_y)*np.sin(angle)+width/2 - y_rel = -(x_spec-o_x)*np.sin(angle) + (y_spec-o_y)*np.cos(angle)+height/2 - else: - x_rel = x_spec-o_x+width/2 - y_rel = y_spec-o_y+height/2 - return [x_rel,y_rel] - - - -def ref_spec_plotting(ref_file,spec_files,fname_ref,fname_specs,**params): - """ - Plots sxm reference image with spectra locations and multiple dat spectra - - Input: - ref_file: filename of reference sxm image - spec_files: list of filenames of dat spectra - fname_ref: filename of saved reference image - fname_specs: filename of saved spectra image - - Optional input: - channelx_plot: channel to plot on x-axis of dat spectra (default: V) - channely_plot: channel to plot on y-axis of dat spectra (default: dIdV) - offset: offset between spectra (default: 0) - annotate_spec: annotate spectra with numbers - - Output: - specs_fig: figure of spectra - """ - - - # Load modules - import os - - # Optional input - if 'channelx_plot' in params: - channelx_plot = params['channelx_plot'] - else: - channelx_plot = 'V' - - if 'channely_plot' in params: - channely_plot = params['channely_plot'] - else: - channely_plot = 'dIdV' - - if 'print_legend' not in params: - params['print_legend'] = True - - if 'annotate_spec' in params: - annotate_spec = params['annotate_spec'] - else: - annotate_spec = False - - - ## Import - # Importing reference image - ref = spm(ref_file) - - # Importing spec - sp = [] - for s in spec_files: - sp.append(spm(s)) - - # Defining color scale - col = pl.cm.rainbow(np.linspace(0,1,len(sp))) - - ## Plotting reference image with spec locations - ref.plot(show_params = True, offset = False, show = False,channel = 'z',close_fig = False); - - # plot circle for each location - for (s,c) in zip(sp,col): - (x,y) = relative_position(ref,s) - plt.plot(x,y,'o',color = c) - if annotate_spec: - plt.annotate(s.name, (x,y)) - - plt.xlabel('x (nm)') - plt.ylabel('y (nm)') - - figDir = os.path.abspath(os.path.join(fname_ref, os.pardir)) - if not os.path.exists(figDir): - os.makedirs(figDir) - - - plt.savefig(fname_ref+'.png', dpi=500) - plt.savefig(fname_ref+'.svg', dpi=500) - - # Plotting specs - specs_fig = specs_plot(sp,channelx=channelx_plot,channely=channely_plot, direction = 'forward', color = col,**params); - - figDir = os.path.abspath(os.path.join(fname_specs, os.pardir)) - if not os.path.exists(figDir): - os.makedirs(figDir) - - specs_fig.savefig(fname_specs+'.png', dpi=500) - specs_fig.savefig(fname_specs+'.svg', dpi=500) - - plt.show() - - return specs_fig - - - -# returns dict list of fitted kpfm parabolas for list of spm objects -def kpfm(files,**params): - - if 'range' in params: - range = params['range']; - else: - range = [0,len(files[0].get_channel('V')[0])-1] - - import numpy as np - #sys.path.append('../') - #import analyze as an - - data = {'V': [], 'df': [], 'V_max': [], 'df_max': [], 'p_fit': [], 'err_p': [], 'V_fit': [], 'df_fit': [], 'err_V_max': [], 'err_df_max': [], 'position': []} - - for f in files: - if f.type == 'spec': - if any(d['ChannelNickname'] == 'df' for d in f.SignalsList): - - data['V'].append(f.get_channel('V')[0]) - data['df'].append(f.get_channel('df')[0]) - - if any(d['ChannelNickname'] == 'df_bw' for d in f.SignalsList): - - if not('df_bw' in data.keys()): - data['V_bw'] = []; - data['df_bw'] = []; - - else: - data['V_bw'].append(f.get_channel('V_bw')[0]) - data['df_bw'].append(f.get_channel('df_bw')[0]) - - x = f.get_param('x')[0] - y = f.get_param('y')[0] - - data['position'].append([x,y]) - - - (p_fit,err_p,df_fit,V_max,err_V_max,df_max,err_df_max) = fit_parabola(np.array(data['V'])[:,range[0]:range[1]].tolist(),np.array(data['df'])[:,range[0]:range[1]].tolist(),single_spectrum=False,fitMin=False,fitMax=False) - - data['p_fit'] = p_fit; - data['err_p'] = err_p; - data['V_fit'] = np.array(data['V'])[:,range[0]:range[1]].tolist(); - data['df_fit'] = df_fit; - data['V_max'] = V_max; - data['err_V_max'] = err_V_max; - data['df_max'] = df_max; - data['err_df_max'] = err_df_max; - - if 'df_bw' in data.keys(): - - (p_fit_bw,err_p_bw,df_fit_bw,V_max_bw,err_V_max_bw,df_max_bw,err_df_max_bw) = fit_parabola(np.array(data['V_bw'])[:,range[0]:range[1]].tolist(),np.array(data['df_bw'])[:,range[0]:range[1]].tolist(),single_spectrum=False,fitMin=False,fitMax=False) - - data['p_fit_bw'] = p_fit_bw; - data['err_p_bw'] = err_p_bw; - data['V_fit_bw'] = np.array(data['V_bw'])[:,range[0]:range[1]].tolist() - data['df_fit_bw'] = df_fit_bw; - data['V_max_bw'] = V_max_bw; - data['err_V_max_bw'] = err_V_max_bw; - data['df_max_bw'] = df_max_bw; - data['err_df_max_bw'] = err_df_max_bw; - - return data - - - - - -############################################## -# help functions -############################################## - -def fit_parabola( - bias, - df, - single_spectrum=False, - fitMin=False, - fitMax=False, - ): - - #import numpy as np - - if single_spectrum: - bias = np.array([bias]) - df = np.array([df]) - p_fit = np.zeros((len(bias), 3)) - df_fit = np.zeros((len(bias), len(bias[0]))) - err_p = np.zeros((len(bias), 3)) - bias_max = np.zeros(len(bias)) - err_bias_max = np.zeros(len(bias)) - df_max = np.zeros(len(bias)) - err_df_max = np.zeros(len(bias)) - - for i in range(len(bias)): - if not fitMin and not fitMax: - (p, cov) = np.polyfit(bias[i], df[i], 2, cov=True) - elif fitMin and not fitMax: - - fit_i = np.where(bias[i] > fitMin[i])[0] - (p, cov) = np.polyfit(bias[i, fit_i], df[i, fit_i], 2, - cov=True) - p_fit[i] = p - err1 = np.sqrt(abs(cov)) - err_p[i] = np.array([err1[0, 0], err1[1, 1], err1[2, 2]]) - - df_fit[i] = np.polyval(p, bias[i]) - - bias_max[i] = -p[1] / (2 * p[0]) - - # if errors independent - - #err_bias_max[i] = abs(bias_max[i]) * np.sqrt((err1[1, 1] - # / p[1]) ** 2 + (err1[0, 0] / p[0]) ** 2) - err_bias_max[i] = np.sqrt((err1[1, 1]/ (2*p[0]))** 2 + (err1[0, 0]*p[1] /(2*p[0]**2)) ** 2) - - # maximum error in any case (John Tayler Error analysis book) - - #err_bias_max[i] = abs(bias_max[i]) * (err1[1, 1] + err1[0, 0]) - - df_max[i] = np.polyval(p, bias_max[i]) - err_df_max[i] = p[0] * bias_max[i] ** 2 * (err1[0, 0] + 2 - * err_bias_max[i] / abs(bias_max[i])) + p[1] \ - * bias_max[i] * (err1[1, 1] + err_bias_max[i] - / abs(bias_max[i])) + p[2] * err1[2, 2] - return ( - p_fit, - err_p, - df_fit, - bias_max, - err_bias_max, - df_max, - err_df_max, - ) - -# this function returns a rgb color code according to standard matlab colors -def matlab_color(num): - if num > 6: - num = np.mod(num,7) - - colors = [[0,0.4470,0.7410], - [0.8500,0.3250,0.0980], - [0.9290,0.6940,0.1250], - [0.4940,0.1840,0.5560], - [0.4660,0.6740,0.1880], - [0.3010,0.7450,0.9330], - [0.6350,0.0780,0.1840]] - - return colors[np.round(num)] -