diff --git a/openbis_knime.feature/.project b/openbis_knime.feature/.project deleted file mode 100644 index bd91633c3b933612c510cb314f20dca91737cfe2..0000000000000000000000000000000000000000 --- a/openbis_knime.feature/.project +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>openbis_knime.feature</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.pde.FeatureBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.FeatureNature</nature> - </natures> -</projectDescription> diff --git a/openbis_knime.feature/build.properties b/openbis_knime.feature/build.properties deleted file mode 100644 index 64f93a9f0b7328eb563aa5ad6cec7f828020e124..0000000000000000000000000000000000000000 --- a/openbis_knime.feature/build.properties +++ /dev/null @@ -1 +0,0 @@ -bin.includes = feature.xml diff --git a/openbis_knime.feature/feature.xml b/openbis_knime.feature/feature.xml deleted file mode 100644 index 07144c3ad968320fe5ef20398fe1b2545840304b..0000000000000000000000000000000000000000 --- a/openbis_knime.feature/feature.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<feature - id="ch.systemsx.cisd.openbis.knime.feature" - label="openBIS Knime Nodes" - version="13.6.2.qualifier" - provider-name="ID Scientific IT Services ETH Zürich"> - - <description url="https://wiki-bsse.ethz.ch/display/openBISDoc1304/openBIS+KNIME+Nodes"> - KNIME Nodes to access openBIS - </description> - - <copyright> - Copyright 2013-2014 ETH Zuerich, CISD - </copyright> - - <license url="http://www.apache.org/licenses/LICENSE-2.0"> - 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. - </license> - - <requires> - <import plugin="org.eclipse.core.runtime"/> - <import plugin="org.knime.workbench.core"/> - <import plugin="org.knime.workbench.repository"/> - <import plugin="org.knime.base"/> - <import plugin="org.knime.core.data.uritype"/> - </requires> - - <plugin - id="ch.systemsx.cisd.openbis.knime" - download-size="0" - install-size="0" - version="0.0.0"/> - -</feature> diff --git a/openbis_knime.update-site/site.xml b/openbis_knime.update-site/site.xml deleted file mode 100644 index c43fed55e393fd914e97e35393c7f06ca13cc57f..0000000000000000000000000000000000000000 --- a/openbis_knime.update-site/site.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<site> - <category-def name="openBIS KNIME Nodes" label="openBIS KNIME Nodes"> - <description> - Nodes for integreting openBIS into a KNIME workflow. - </description> - </category-def> -</site> diff --git a/openbis_knime/.classpath b/openbis_knime/.classpath deleted file mode 100644 index 871772584a61fc4721dc524b1decf877a5535072..0000000000000000000000000000000000000000 --- a/openbis_knime/.classpath +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="source/java"/> - <classpathentry kind="src" path="sourceTest/java"/> - <classpathentry kind="src" path="sourceEclipse/java"/> - <classpathentry exported="true" kind="lib" path="lib/dss_client-S224.0-r35783.jar"/> - <classpathentry exported="true" kind="lib" path="lib/openBIS-query-API-S224.0-r35783.jar"/> - <classpathentry exported="true" kind="lib" path="lib/aopalliance-1.0.jar"/> - <classpathentry exported="true" kind="lib" path="lib/aspectjweaver-1.8.4.jar"/> - <classpathentry exported="true" kind="lib" path="lib/commons-codec-1.3.jar"/> - <classpathentry exported="true" kind="lib" path="lib/commons-io-1.4.jar"/> - <classpathentry exported="true" kind="lib" path="lib/commons-lang-2.4.jar"/> - <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.2.jar"/> - <classpathentry exported="true" kind="lib" path="lib/httpclient-4.3.6.jar"/> - <classpathentry exported="true" kind="lib" path="lib/httpcore-4.3.3.jar"/> - <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.15.jar"/> - <classpathentry exported="true" kind="lib" path="lib/spring-aop-4.1.4.RELEASE.jar"/> - <classpathentry exported="true" kind="lib" path="lib/spring-beans-4.1.4.RELEASE.jar"/> - <classpathentry exported="true" kind="lib" path="lib/spring-context-4.1.4.RELEASE.jar"/> - <classpathentry exported="true" kind="lib" path="lib/spring-core-4.1.4.RELEASE.jar"/> - <classpathentry exported="true" kind="lib" path="lib/spring-expression-4.1.4.RELEASE.jar"/> - <classpathentry exported="true" kind="lib" path="lib/spring-webmvc-4.1.4.RELEASE.jar"/> - <classpathentry exported="true" kind="lib" path="lib/spring-web-4.1.4.RELEASE.jar"/> - <classpathentry exported="true" kind="lib" path="lib/marathon-spring-util-1.2.5.jar"/> - <classpathentry exported="true" kind="lib" path="lib/sis-base-14.12.0.jar"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="lib" path="/libraries/commons-logging/commons-logging.jar" sourcepath="/libraries/commons-logging/src.zip"/> - <classpathentry kind="lib" path="/libraries/commons-lang/commons-lang.jar" sourcepath="/libraries/commons-lang/src.zip"/> - <classpathentry kind="lib" path="/libraries/commons-io/commons-io.jar" sourcepath="/libraries/commons-io/src.zip"/> - <classpathentry kind="lib" path="/libraries/log4j/log4j.jar" sourcepath="/libraries/log4j/src.zip"/> - <classpathentry kind="lib" path="/libraries/knime/knime-core-util.jar"/> - <classpathentry kind="lib" path="/libraries/knime/knime-base.jar"/> - <classpathentry kind="lib" path="/libraries/knime/knime-core.jar"/> - <classpathentry kind="lib" path="/libraries/knime/knime-core-data-uritype.jar"/> - <classpathentry kind="lib" path="/libraries/testng/testng-jdk15.jar" sourcepath="/libraries/testng/src.zip"/> - <classpathentry kind="lib" path="/libraries/jmock/hamcrest/hamcrest-core.jar"/> - <classpathentry kind="lib" path="/libraries/jmock/hamcrest/hamcrest-library.jar"/> - <classpathentry kind="lib" path="/libraries/jmock/jmock.jar"/> - <classpathentry kind="lib" path="/libraries/sis-base/sis-base.jar" sourcepath="/libraries/sis-base/sis-base-src.zip"/> - <classpathentry kind="lib" path="/libraries/openbis-apis/dss/dss_client.jar"/> - <classpathentry kind="lib" path="/libraries/openbis-apis/query/openbis-query-api.jar" sourcepath="/libraries/openbis-apis/query/src.zip"/> - <classpathentry kind="lib" path="/libraries/activation/activation.jar"/> - <classpathentry kind="output" path="targets/classes"/> -</classpath> diff --git a/openbis_knime/.gitignore b/openbis_knime/.gitignore deleted file mode 100644 index 9bb9bd28649c26afb3ac9dcdfc59738701ab4dbb..0000000000000000000000000000000000000000 --- a/openbis_knime/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/targets -/.settings -/test-output -/.idea/ -*.iml -*.eml \ No newline at end of file diff --git a/openbis_knime/.project b/openbis_knime/.project deleted file mode 100644 index 35a88dba01f7267159259327ead4c965deda9be9..0000000000000000000000000000000000000000 --- a/openbis_knime/.project +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>openbis_knime</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.springsource.ide.eclipse.gradle.core.nature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> - <filteredResources> - <filter> - <id>1332321366607</id> - <name></name> - <type>26</type> - <matcher> - <id>org.eclipse.ui.ide.multiFilter</id> - <arguments>1.0-name-matches-true-false-.git</arguments> - </matcher> - </filter> - </filteredResources> -</projectDescription> diff --git a/openbis_knime/META-INF/MANIFEST.MF b/openbis_knime/META-INF/MANIFEST.MF deleted file mode 100644 index 135c740cc5451c045987b09a4a04731c5bde6f91..0000000000000000000000000000000000000000 --- a/openbis_knime/META-INF/MANIFEST.MF +++ /dev/null @@ -1,40 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: openBIS KNIME Nodes -Bundle-SymbolicName: ch.systemsx.cisd.openbis.knime;singleton:=true -Bundle-Version: 13.6.2.qualifier -Bundle-Vendor: ID Scientific IT Services ETH Zürich -Require-Bundle: org.knime.workbench.core, - org.knime.base, - org.knime.core.data.uritype, - org.apache.commons.codec, - org.apache.commons.httpclient, - org.apache.commons.lang, - org.apache.commons.io, - org.apache.commons.logging, - org.apache.log4j -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Bundle-ActivationPolicy: lazy -Export-Package: ch.systemsx.cisd.openbis.knime.file, - ch.systemsx.cisd.openbis.knime.query -Bundle-ClassPath: lib/dss_client-S224.0-r35783.jar, - lib/openBIS-query-API-S224.0-r35783.jar, - openbis-knime.jar, - lib/sis-base-14.12.0.jar, - lib/aspectjweaver-1.8.4.jar, - lib/commons-codec-1.3.jar, - lib/commons-io-1.4.jar, - lib/commons-lang-2.4.jar, - lib/commons-logging-1.2.jar, - lib/httpclient-4.3.6.jar, - lib/httpcore-4.3.3.jar, - lib/log4j-1.2.15.jar, - lib/spring-aop-4.1.4.RELEASE.jar, - lib/spring-beans-4.1.4.RELEASE.jar, - lib/spring-context-4.1.4.RELEASE.jar, - lib/spring-core-4.1.4.RELEASE.jar, - lib/spring-expression-4.1.4.RELEASE.jar, - lib/spring-web-4.1.4.RELEASE.jar, - lib/spring-webmvc-4.1.4.RELEASE.jar, - lib/marathon-spring-util-1.2.5.jar, - lib/aopalliance-1.0.jar diff --git a/openbis_knime/build.gradle b/openbis_knime/build.gradle deleted file mode 100644 index 1f0cce8aeaf84bcdc505869274e3f229d81a16db..0000000000000000000000000000000000000000 --- a/openbis_knime/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ -apply from: '../gradle/javaproject.gradle' - -dependencies { - api 'cisd:cisd-base:r31435', - 'apache:log4j:1.2.15', - 'knime:knime:2.7.2', - 'openbis:dss:13.04.2', - 'openbis:query:13.04.2', - 'rinn:restrictions:1.0.2', - 'javax.activation:activation:1.1.1' - - testImplementation 'testng:testng:6.8-CISD', - 'hamcrest:hamcrest-integration:1.3', - 'hamcrest:hamcrest-library:1.3' - - testImplementation ('jmock:jmock:2.5.1') { - exclude group: 'hamcrest', module: 'hamcrest-core' - } -} - -jar { - baseName = 'openbis-knime-server' - from ('targets/dist') { - include 'BUILD*INFO' - } - exclude 'ch/systemsx/cisd/openbis/knime/query' - exclude 'ch/systemsx/cisd/openbis/knime/common' - exclude 'ch/systemsx/cisd/openbis/knime/file' -} diff --git a/openbis_knime/build.properties b/openbis_knime/build.properties deleted file mode 100644 index f803f8c964ca799f59d8b07e0314cdff86622bcd..0000000000000000000000000000000000000000 --- a/openbis_knime/build.properties +++ /dev/null @@ -1,29 +0,0 @@ -output.. = targets/classes/ -bin.includes = META-INF/,\ - plugin.xml,\ - icons/,\ - openbis-knime.jar,\ - lib/marathon-spring-util-1.2.5.jar,\ - lib/sis-base-14.12.0.jar,\ - lib/spring-web-4.1.4.RELEASE.jar,\ - lib/aspectjweaver-1.8.4.jar,\ - lib/commons-codec-1.3.jar,\ - lib/commons-io-1.4.jar,\ - lib/commons-lang-2.4.jar,\ - lib/commons-logging-1.2.jar,\ - lib/httpclient-4.3.6.jar,\ - lib/httpcore-4.3.3.jar,\ - lib/log4j-1.2.15.jar,\ - lib/spring-aop-4.1.4.RELEASE.jar,\ - lib/spring-beans-4.1.4.RELEASE.jar,\ - lib/spring-context-4.1.4.RELEASE.jar,\ - lib/spring-core-4.1.4.RELEASE.jar,\ - lib/spring-expression-4.1.4.RELEASE.jar,\ - lib/spring-webmvc-4.1.4.RELEASE.jar,\ - lib/aopalliance-1.0.jar,\ - lib/openBIS-query-API-S224.0-r35783.jar,\ - lib/dss_client-S224.0-r35783.jar -source.openbis-knime.jar = source/java/,\ - sourceEclipse/java/ -src.includes = source/java/,\ - sourceEclipse/java/ diff --git a/openbis_knime/build/build.xml b/openbis_knime/build/build.xml deleted file mode 100644 index 29ec1e15752182e6f1d81bf19f82f89cc38b6501..0000000000000000000000000000000000000000 --- a/openbis_knime/build/build.xml +++ /dev/null @@ -1,60 +0,0 @@ -<project name="openbis_knime" default="ci" basedir=".."> - <import file="../../build_resources/ant/build-common.xml" /> - <project-classpath name="ecp" classes="${classes}" /> - <property name="mainfolder" value="openbis_knime"/> - <property name="original.dist" value="../${ant.project.name}/dist" /> - <loadproperties srcfile="META-INF/MANIFEST.MF"> - <filterchain> - <tokenfilter> - <replacestring from=".qualifier" to=""/> - </tokenfilter> - </filterchain> - </loadproperties> - <property name="version" value="${Bundle-Version}"/> - <property name="jar.file" value="${dist}/openbis-knime-server-${version}.jar"/> - - <!-- - // Cleans distribution directory. - --> - <target name="clean" description="Cleans distribution directory."> - <delete dir="${dist}" failonerror="true" /> - <mkdir dir="${dist}" /> - </target> - - <!-- - // Runs tests. - --> - <target name="run-tests"> - <antcall target="build-common.run-tests"> - <param name="test.suite" value="tests.xml" /> - </antcall> - </target> - - <!-- - // Creates build information. - --> - <target name="build-info" description="Creates build information."> - <build-info revision="revision.number" version="version.number" clean="clean.flag" /> - <echo file="${build.info.file}">${version}:${revision.number}:${clean.flag}</echo> - </target> - - <!-- - // Creates server JAR file. - --> - <target name="server-jar" depends="compile, build-info" description="Creates project jar file."> - <delete file="${jar.file}" /> - <recursive-jar destfile="${jar.file}"> - <fileset dir="${classes}"> - <include name="**/server/*.class" /> - <include name="${build.info.filename}" /> - </fileset> - </recursive-jar> - </target> - - <!-- - // Task for continuous integration server. - --> - <target name="ci" depends="build-common.ci, check-dependencies, server-jar" - description="Task for continuous integration server." /> - -</project> \ No newline at end of file diff --git a/openbis_knime/developer-readme.txt b/openbis_knime/developer-readme.txt deleted file mode 100644 index 783bfc23f1653863b08938f7232cffc3fb35ddf3..0000000000000000000000000000000000000000 --- a/openbis_knime/developer-readme.txt +++ /dev/null @@ -1,49 +0,0 @@ -This short text explain how to do development, build and deployment of openBIS KNIME nodes. -Here some important remarks because this is not a project like the other ones: -* Build has to be done manually as described below. -* The gradle build script creates only openbis-knime-server.jar which has helper classes for DSS aggregation plugins. -* The 3th party libraries for the actual plugin are in the lib folder. - -Prerequisites for developing -============================ - -1. There are three Eclipse projects which belong together: - openbis_knime, openbis_knime.feature and openbis_knime.update-site - All three have to be checked out (they won't compile properly until KNIME plug-in is installed). -2. In addition the KNIME Node Development Tools plug-in has to be installed. - The update site is http://www.knime.org/update/3.1/ - -Developing and Testing -====================== - -Just develop as normal. - -For unit testing do not run a test class directly but execute the eclipse launch configuration -'openbis knime all tests'. The reason for this is that the normal default class path doesn't work. - -For manual integration test with KNIME do the following: -1. Open site.xml in project openbis_knime.update-site. -2. Click on category 'openBIS KNIME Nodes'. -3. Click on 'Add Feature...' and choose in the pop-up dialog the feature - ch.systemsx.cisd.openbis.knime -4. Click on the 'Build' button. This creates/update artifacts.jar, content.jar, - features/ and plugins/ folder of project openbis_knime.update-site -5. Install/update openBIS KNIME Nodes of the KNIME application from the local update site - file:/<absolut path to your Eclipse workspace>/openbis_knime.update-site - Be sure that update site http://update.knime.org/community-contributions/3.1/ is defined for - the KNIME application. - -Build and deploy a new version -============================== - -1. Open plugin.xml and change the version on the overview tab. For example from - 13.04.02.qualifier -> 13.04.03.qualifier -2. Does the same for feature.xml in project openbis_knime.feature. -3. Open site.xml in project openbis_knime.update-site. -4. Click on category 'openBIS KNIME Nodes'. -5. Click on 'Add Feature...' and choose in the pop-up dialog the feature - ch.systemsx.cisd.openbis.knime -6. Click on the 'Build' button. This creates/update artifacts.jar, content.jar, - features/ and plugins/ folder of project openbis_knime.update-site -7. Copy these two JARs and folders to openbis@lascar:/links/groups/sis/doc/openbis/knime-update-site - diff --git a/openbis_knime/dist/icons/openbis.png b/openbis_knime/dist/icons/openbis.png deleted file mode 100644 index a5b30672e374063ad0b36c4469a028e9e61090d7..0000000000000000000000000000000000000000 Binary files a/openbis_knime/dist/icons/openbis.png and /dev/null differ diff --git a/openbis_knime/etc/log.xml b/openbis_knime/etc/log.xml deleted file mode 100644 index c437339ded6a0516430f8b148c172fccb4ec73f3..0000000000000000000000000000000000000000 --- a/openbis_knime/etc/log.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> - -<!-- - // This configuration file is suitable for testing purposes. ---> -<log4j:configuration debug="true" xmlns:log4j='http://jakarta.apache.org/log4j/'> - - <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender"> - <layout class="org.apache.log4j.PatternLayout"> - <!-- - // %d: outputs the date of the logging event. - // %-5p: priority (i.e. level) of the logging event should be left justified to - // a width of five characters. - // %t: outputs the name of the thread that generated the logging event. - // %c: outputs the category of the logging event. - // %m: outputs the application supplied message associated with the logging event. - // %n: outputs the platform dependent line separator character or characters. - // %X: outputs the MDC (mapped diagnostic context) associated with the thread that generated the logging event. - --> - <param name="ConversionPattern" - value="%d %-5p [%t]%X{sessionInfo} %c - %m%n" /> - </layout> - </appender> - - <!-- - // Defined but not used right now. - --> - <appender name="NULL" class="org.apache.log4j.varia.NullAppender" /> - - <!-- - // Enable full wire (header and content) + context logging - // For more information look at http://jakarta.apache.org/commons/httpclient/logging.html. - // We do not need to set a level value here as loggers inherit their level from the root logger. - --> - - <!-- - // Do not use log level debug otherwise plain passwords are readable. - --> - <logger name="httpclient.wire"> - <level value="ERROR" /> - </logger> - - <!-- - // Uncomment this for debugging value binding in Hibernate - <category name="org.hibernate.type"> - <priority value="TRACE"/> - </category> - --> - - <!-- - <logger name="org.apache.commons.httpclient"> - <level value="DEBUG" /> - </logger> - --> - - <root> - <priority value="info" /> - <appender-ref ref="STDOUT" /> - </root> - -</log4j:configuration> diff --git a/openbis_knime/gradle/wrapper/gradle-wrapper.jar b/openbis_knime/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 5c2d1cf016b3885f6930543d57b744ea8c220a1a..0000000000000000000000000000000000000000 Binary files a/openbis_knime/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/openbis_knime/gradle/wrapper/gradle-wrapper.properties b/openbis_knime/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 7745c4ec463c7bb1c4ff6a5e58db239890345152..0000000000000000000000000000000000000000 --- a/openbis_knime/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/openbis_knime/gradlew b/openbis_knime/gradlew deleted file mode 100755 index 83f2acfdc319a24e8766cca78f32474ad7a22dd6..0000000000000000000000000000000000000000 --- a/openbis_knime/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/openbis_knime/gradlew.bat b/openbis_knime/gradlew.bat deleted file mode 100644 index 24467a141f791695fc1009c78d913b2c849d1412..0000000000000000000000000000000000000000 --- a/openbis_knime/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/openbis_knime/icons/openBIS_logo.png b/openbis_knime/icons/openBIS_logo.png deleted file mode 100644 index ce6b826a93b0bcf08f86a8ee8db8995de3bc96e8..0000000000000000000000000000000000000000 Binary files a/openbis_knime/icons/openBIS_logo.png and /dev/null differ diff --git a/openbis_knime/icons/openbis.png b/openbis_knime/icons/openbis.png deleted file mode 100644 index a5b30672e374063ad0b36c4469a028e9e61090d7..0000000000000000000000000000000000000000 Binary files a/openbis_knime/icons/openbis.png and /dev/null differ diff --git a/openbis_knime/lib/aopalliance-1.0.jar b/openbis_knime/lib/aopalliance-1.0.jar deleted file mode 100644 index 578b1a0c359ef88a84461bdb91d9d0041afd54de..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/aopalliance-1.0.jar and /dev/null differ diff --git a/openbis_knime/lib/aspectjweaver-1.8.4.jar b/openbis_knime/lib/aspectjweaver-1.8.4.jar deleted file mode 100644 index 4458ba45c367b09f840968b35d00ac0bd7658545..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/aspectjweaver-1.8.4.jar and /dev/null differ diff --git a/openbis_knime/lib/commons-codec-1.3.jar b/openbis_knime/lib/commons-codec-1.3.jar deleted file mode 100644 index 957b6752af9a60c1bb2a4f65db0e90e5ce00f521..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/commons-codec-1.3.jar and /dev/null differ diff --git a/openbis_knime/lib/commons-io-1.4.jar b/openbis_knime/lib/commons-io-1.4.jar deleted file mode 100644 index 133dc6cb35f5ca2c5920fd0933a557c2def88680..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/commons-io-1.4.jar and /dev/null differ diff --git a/openbis_knime/lib/commons-lang-2.4.jar b/openbis_knime/lib/commons-lang-2.4.jar deleted file mode 100644 index 532939ecab6b77ccb77af3635c55ff9752b70ab7..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/commons-lang-2.4.jar and /dev/null differ diff --git a/openbis_knime/lib/commons-logging-1.2.jar b/openbis_knime/lib/commons-logging-1.2.jar deleted file mode 100644 index 93a3b9f6db406c84e270e19b9a5e70f2e27ca513..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/commons-logging-1.2.jar and /dev/null differ diff --git a/openbis_knime/lib/dss_client-S224.0-r35783.jar b/openbis_knime/lib/dss_client-S224.0-r35783.jar deleted file mode 100644 index 63c1d7c403f157b697f9dac444f00beab99e0864..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/dss_client-S224.0-r35783.jar and /dev/null differ diff --git a/openbis_knime/lib/httpclient-4.3.6.jar b/openbis_knime/lib/httpclient-4.3.6.jar deleted file mode 100644 index 00e98110dfb60487ab8a4368c035bfac54ef8f8f..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/httpclient-4.3.6.jar and /dev/null differ diff --git a/openbis_knime/lib/httpcore-4.3.3.jar b/openbis_knime/lib/httpcore-4.3.3.jar deleted file mode 100644 index a8747b0cf91cd89d4b2785e86fcfb057e7260154..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/httpcore-4.3.3.jar and /dev/null differ diff --git a/openbis_knime/lib/log4j-1.2.15.jar b/openbis_knime/lib/log4j-1.2.15.jar deleted file mode 100644 index c930a6ab4d4b73c1a6feb9e929091205664bb340..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/log4j-1.2.15.jar and /dev/null differ diff --git a/openbis_knime/lib/marathon-spring-util-1.2.5.jar b/openbis_knime/lib/marathon-spring-util-1.2.5.jar deleted file mode 100644 index 8ad63485b88f3e8bc66346216c4ecd3c29cbee60..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/marathon-spring-util-1.2.5.jar and /dev/null differ diff --git a/openbis_knime/lib/openBIS-query-API-S224.0-r35783.jar b/openbis_knime/lib/openBIS-query-API-S224.0-r35783.jar deleted file mode 100644 index ee29b7c840b4a7558e5c0c87dcc52db8dce1ccaa..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/openBIS-query-API-S224.0-r35783.jar and /dev/null differ diff --git a/openbis_knime/lib/sis-base-14.12.0.jar b/openbis_knime/lib/sis-base-14.12.0.jar deleted file mode 100644 index ddcf2b97d0ed674650ac6dba7c8317aea59976a4..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/sis-base-14.12.0.jar and /dev/null differ diff --git a/openbis_knime/lib/spring-aop-4.1.4.RELEASE.jar b/openbis_knime/lib/spring-aop-4.1.4.RELEASE.jar deleted file mode 100644 index 43d00d201e9d1471194834370f362a09579e2866..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/spring-aop-4.1.4.RELEASE.jar and /dev/null differ diff --git a/openbis_knime/lib/spring-beans-4.1.4.RELEASE.jar b/openbis_knime/lib/spring-beans-4.1.4.RELEASE.jar deleted file mode 100644 index aa5b9d434904466d68f59daf97132b940aea5429..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/spring-beans-4.1.4.RELEASE.jar and /dev/null differ diff --git a/openbis_knime/lib/spring-context-4.1.4.RELEASE.jar b/openbis_knime/lib/spring-context-4.1.4.RELEASE.jar deleted file mode 100644 index 654720805d16c41b8ef958d8630ce7e12ea77621..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/spring-context-4.1.4.RELEASE.jar and /dev/null differ diff --git a/openbis_knime/lib/spring-core-4.1.4.RELEASE.jar b/openbis_knime/lib/spring-core-4.1.4.RELEASE.jar deleted file mode 100644 index e4867cb0c9eb99a2c57487bb60d775cabc829b96..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/spring-core-4.1.4.RELEASE.jar and /dev/null differ diff --git a/openbis_knime/lib/spring-expression-4.1.4.RELEASE.jar b/openbis_knime/lib/spring-expression-4.1.4.RELEASE.jar deleted file mode 100644 index c7896e945d342ba16a0c9f395448a6652e4f93be..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/spring-expression-4.1.4.RELEASE.jar and /dev/null differ diff --git a/openbis_knime/lib/spring-web-4.1.4.RELEASE.jar b/openbis_knime/lib/spring-web-4.1.4.RELEASE.jar deleted file mode 100644 index 38baa28c15ff43daf8c19d5d92af126677b95334..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/spring-web-4.1.4.RELEASE.jar and /dev/null differ diff --git a/openbis_knime/lib/spring-webmvc-4.1.4.RELEASE.jar b/openbis_knime/lib/spring-webmvc-4.1.4.RELEASE.jar deleted file mode 100644 index 0215e7ba64313d234c27ef083bc6755a398bd3c9..0000000000000000000000000000000000000000 Binary files a/openbis_knime/lib/spring-webmvc-4.1.4.RELEASE.jar and /dev/null differ diff --git a/openbis_knime/plugin.xml b/openbis_knime/plugin.xml deleted file mode 100644 index 8af28de2a56f89d5ad03d5d6a9d722b80d63f31b..0000000000000000000000000000000000000000 --- a/openbis_knime/plugin.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<?eclipse version="3.0"?> - -<plugin> - <extension point="org.knime.workbench.repository.nodes"> - <node category-path="/community/openbis" factory-class="ch.systemsx.cisd.openbis.knime.query.QueryNodeFactory" - id="ch.systemsx.cisd.openbis.knime.query.QueryNodeFactory"/> - <node category-path="/community/openbis" factory-class="ch.systemsx.cisd.openbis.knime.query.ReportNodeFactory" - id="ch.systemsx.cisd.openbis.knime.query.ReportNodeFactory"/> - <node category-path="/community/openbis" factory-class="ch.systemsx.cisd.openbis.knime.query.AggregatedDataTableImportNodeFactory" - id="ch.systemsx.cisd.openbis.knime.query.AggregatedDataTableImportNodeFactory"/> - <node category-path="/community/openbis" factory-class="ch.systemsx.cisd.openbis.knime.file.DataSetFileImportNodeFactory" - id="ch.systemsx.cisd.openbis.knime.file.DataSetImportNodeFactory"/> - <node category-path="/community/openbis" factory-class="ch.systemsx.cisd.openbis.knime.file.DataSetRegistrationNodeFactory" - id="ch.systemsx.cisd.openbis.knime.file.DataSetRegistrationNodeFactory"/> - <node category-path="/community/openbis" factory-class="ch.systemsx.cisd.openbis.knime.file.DataSetRegistrationViaFlowNodeFactory" - id="ch.systemsx.cisd.openbis.knime.file.DataSetRegistrationNode2Factory"/> - <node category-path="/community/openbis" factory-class="ch.systemsx.cisd.openbis.knime.file.AggregatedDataFileImportNodeFactory" - id="ch.systemsx.cisd.openbis.knime.file.AggregatedDataFileImportNodeFactory"/> - </extension> - - <extension point="org.knime.workbench.repository.categories"> - <category - description="Nodes for accessing openBIS" - icon="icons/openbis.png" - level-id="openbis" - name="openBIS" - path="/community/"/> - </extension> - - <extension point="org.knime.product.splashExtension"> - <splashExtension icon="icons/openBIS_logo.png" id="openBIS" tooltip="openBIS Nodes for KNIME"/> - </extension> - <extension - point="org.eclipse.ui.preferencePages"> - <page - category="org.knime.workbench.ui.preferences" - class="ch.systemsx.cisd.openbis.knime.common.OpenBisPreferencePage" - id="openbis" - name="openBIS"> - </page> - </extension> -</plugin> - - diff --git a/openbis_knime/resource/dependency-structure.ddf b/openbis_knime/resource/dependency-structure.ddf deleted file mode 100644 index cf920f2f3a829bfe5a9dfce2bc05f87862cfaac2..0000000000000000000000000000000000000000 --- a/openbis_knime/resource/dependency-structure.ddf +++ /dev/null @@ -1,17 +0,0 @@ -#show allResults - -{project} = ch.systemsx.cisd.openbis.knime - -[server] = ${project}.server.* -[common] = ${project}.common.* -[file] = ${project}.file.* -[query] = ${project}.query.* - -check sets [server] [common] [file] [query] - -layer layer-server = [server] -layer layer-common = [common] -layer layer-nodes = [file] [query] - -check layeringOf layer-server layer-common layer-nodes - diff --git a/openbis_knime/resource/eclipse/TestAggregatedDataImportNodeDialog.launch b/openbis_knime/resource/eclipse/TestAggregatedDataImportNodeDialog.launch deleted file mode 100644 index 09d8daeaced60aca5bae8b78bc95cc93d2ffaad3..0000000000000000000000000000000000000000 --- a/openbis_knime/resource/eclipse/TestAggregatedDataImportNodeDialog.launch +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/TestAggregatedDataImportNodeDialog.java"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="1"/> -</listAttribute> -<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" javaProject="openbis_knime" path="1" type="4"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="openbis_knime" type="1"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-io/commons-io.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-lang/commons-lang.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-logging/commons-logging.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/cisd-base/cisd-base.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/openbis-apis/dss/dss_client.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/openbis-apis/query/openbis-query-api.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/log4j/log4j.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-base.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core-data-uritype.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core-util.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-codec/commons-codec.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-httpclient/commons-httpclient.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/spring/third-party/stream-supporting-httpinvoker.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/spring/spring.jar" path="3" type="2"/> "/> -</listAttribute> -<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="ch.systemsx.cisd.openbis.knime.file.TestAggregatedDataImportNodeDialog"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="openbis_knime"/> -</launchConfiguration> diff --git a/openbis_knime/resource/eclipse/TestAggregatedDataTableImportNodeDialog.launch b/openbis_knime/resource/eclipse/TestAggregatedDataTableImportNodeDialog.launch deleted file mode 100644 index 6a90b2d0cfcf50cffe9a28ee9777cc2eaa3a9caa..0000000000000000000000000000000000000000 --- a/openbis_knime/resource/eclipse/TestAggregatedDataTableImportNodeDialog.launch +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/TestAggregatedDataTableImportNodeDialog.java"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="1"/> -</listAttribute> -<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" javaProject="openbis_knime" path="1" type="4"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="openbis_knime" type="1"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-io/commons-io.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-lang/commons-lang.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-logging/commons-logging.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/cisd-base/cisd-base.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/openbis-apis/dss/dss_client.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/openbis-apis/query/openbis-query-api.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/log4j/log4j.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-base.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core-data-uritype.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core-util.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-codec/commons-codec.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-httpclient/commons-httpclient.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/spring/third-party/stream-supporting-httpinvoker.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/spring/spring.jar" path="3" type="2"/> "/> -</listAttribute> -<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="ch.systemsx.cisd.openbis.knime.query.TestAggregatedDataTableImportNodeDialog"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="openbis_knime"/> -</launchConfiguration> diff --git a/openbis_knime/resource/eclipse/TestDataSetFileImportNodeDialog.launch b/openbis_knime/resource/eclipse/TestDataSetFileImportNodeDialog.launch deleted file mode 100644 index 7f83f0c60a2661bff1d93bf58dd88890dff2fdb4..0000000000000000000000000000000000000000 --- a/openbis_knime/resource/eclipse/TestDataSetFileImportNodeDialog.launch +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/TestDataSetFileImportNodeDialog.java"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="1"/> -</listAttribute> -<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" javaProject="openbis_knime" path="1" type="4"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="openbis_knime" type="1"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-io/commons-io.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-lang/commons-lang.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-logging/commons-logging.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/cisd-base/cisd-base.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/openbis-apis/dss/dss_client.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/openbis-apis/query/openbis-query-api.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/log4j/log4j.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-base.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core-data-uritype.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core-util.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-codec/commons-codec.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-httpclient/commons-httpclient.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/spring/third-party/stream-supporting-httpinvoker.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/spring/spring.jar" path="3" type="2"/> "/> -</listAttribute> -<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="ch.systemsx.cisd.openbis.knime.file.TestDataSetFileImportNodeDialog"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="openbis_knime"/> -</launchConfiguration> diff --git a/openbis_knime/resource/eclipse/TestDataSetRegistrationNodeDialog.launch b/openbis_knime/resource/eclipse/TestDataSetRegistrationNodeDialog.launch deleted file mode 100644 index 9161c10848300d610632e7a1f6ae36d8878bfce0..0000000000000000000000000000000000000000 --- a/openbis_knime/resource/eclipse/TestDataSetRegistrationNodeDialog.launch +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/TestDataSetRegistrationNodeDialog.java"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="1"/> -</listAttribute> -<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" javaProject="openbis_knime" path="1" type="4"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="openbis_knime" type="1"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-io/commons-io.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-lang/commons-lang.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-logging/commons-logging.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/cisd-base/cisd-base.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/openbis-apis/dss/dss_client.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/openbis-apis/query/openbis-query-api.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/log4j/log4j.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-base.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core-data-uritype.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core-util.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-codec/commons-codec.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-httpclient/commons-httpclient.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/spring/third-party/stream-supporting-httpinvoker.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/spring/spring.jar" path="3" type="2"/> "/> -</listAttribute> -<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="ch.systemsx.cisd.openbis.knime.file.TestDataSetRegistrationNodeDialog"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="openbis_knime"/> -</launchConfiguration> diff --git a/openbis_knime/resource/eclipse/TestReportNodeDialog.launch b/openbis_knime/resource/eclipse/TestReportNodeDialog.launch deleted file mode 100644 index e3ce0bd8ddef51fc0499ffbcdd174868ce1dab83..0000000000000000000000000000000000000000 --- a/openbis_knime/resource/eclipse/TestReportNodeDialog.launch +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/TestReportNodeDialog.java"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="1"/> -</listAttribute> -<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" javaProject="openbis_knime" path="1" type="4"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="openbis_knime" type="1"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-io/commons-io.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-lang/commons-lang.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-logging/commons-logging.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/cisd-base/cisd-base.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/openbis-apis/dss/dss_client.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/openbis-apis/query/openbis-query-api.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/log4j/log4j.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-base.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core-data-uritype.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core-util.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-codec/commons-codec.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-httpclient/commons-httpclient.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/spring/third-party/stream-supporting-httpinvoker.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/spring/spring.jar" path="3" type="2"/> "/> -</listAttribute> -<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="ch.systemsx.cisd.openbis.knime.query.TestReportNodeDialog"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="openbis_knime"/> -</launchConfiguration> diff --git a/openbis_knime/resource/eclipse/openbis knime all tests.launch b/openbis_knime/resource/eclipse/openbis knime all tests.launch deleted file mode 100644 index 4fb8d87b73375b5a04711b5178f5e31e568bb1ff..0000000000000000000000000000000000000000 --- a/openbis_knime/resource/eclipse/openbis knime all tests.launch +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.testng.eclipse.launchconfig"> -<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/> -<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" javaProject="openbis_knime" path="1" type="4"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="openbis_knime" type="1"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-io/commons-io.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-lang/commons-lang.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-logging/commons-logging.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/cisd-base/cisd-base.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/openbis-apis/dss/dss_client.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/openbis-apis/query/openbis-query-api.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/log4j/log4j.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-base.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core-data-uritype.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core-util.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/knime/knime-core.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-codec/commons-codec.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/commons-httpclient/commons-httpclient.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/spring/third-party/stream-supporting-httpinvoker.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/spring/spring.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/jmock/hamcrest/hamcrest-core.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/jmock/objenesis/objenesis-1.0.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/jmock/jmock.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/jmock/hamcrest/hamcrest-integration.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/jmock/hamcrest/hamcrest-library.jar" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/libraries/jmock/jmock-legacy.jar" path="3" type="2"/> "/> -</listAttribute> -<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Java SE 7 [1.7.0_51]"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.testng.remote.RemoteTestNG"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="openbis_knime"/> -<mapAttribute key="org.testng.eclipse.ALL_CLASS_METHODS"/> -<listAttribute key="org.testng.eclipse.CLASS_TEST_LIST"/> -<booleanAttribute key="org.testng.eclipse.DEBUG" value="false"/> -<listAttribute key="org.testng.eclipse.GROUP_LIST"/> -<listAttribute key="org.testng.eclipse.GROUP_LIST_CLASS"/> -<stringAttribute key="org.testng.eclipse.LOG_LEVEL" value="2"/> -<listAttribute key="org.testng.eclipse.PACKAGE_TEST_LIST"/> -<stringAttribute key="org.testng.eclipse.PROTOCOL" value="object"/> -<listAttribute key="org.testng.eclipse.SUITE_TEST_LIST"> -<listEntry value="/Users/felmer/dev/eclipse-workspace/openbis_knime/sourceTest/java/tests.xml"/> -</listAttribute> -<intAttribute key="org.testng.eclipse.TYPE" value="3"/> -<booleanAttribute key="org.testng.eclipse.VERBOSE" value="false"/> -</launchConfiguration> diff --git a/openbis_knime/settings.gradle b/openbis_knime/settings.gradle deleted file mode 100644 index 8062ac25691000178f94b7d9fc1091ef3700f632..0000000000000000000000000000000000000000 --- a/openbis_knime/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -// Don't delete it eventough it is empty! diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/AbstractOpenBisNodeModel.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/AbstractOpenBisNodeModel.java deleted file mode 100644 index 391e8b3c21e3050c99ac11a502d5c70dde932c71..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/AbstractOpenBisNodeModel.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2012 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.io.File; -import java.io.IOException; - -import org.apache.commons.lang.StringUtils; -import org.knime.core.node.CanceledExecutionException; -import org.knime.core.node.ExecutionMonitor; -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeLogger; -import org.knime.core.node.NodeModel; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; -import org.knime.core.node.port.PortType; -import org.knime.core.node.workflow.ICredentials; - -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.FacadeFactory; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; - -/** - * Abstract super class of start nodes getting some data from openBIS. - * - * @author Franz-Josef Elmer - */ -public abstract class AbstractOpenBisNodeModel extends NodeModel -{ - public static final String URL_KEY = "url"; - - public static final String CREDENTIALS_KEY = "credentials"; - - public static final String USER_KEY = "user"; - - public static final String PASSWORD_KEY = "password"; - - protected NodeLogger logger; - - protected String url; - - protected String userID; - - protected String password; - - private String credentialsName; - - protected AbstractOpenBisNodeModel() - { - super(0, 1); - logger = NodeLogger.getLogger(getClass()); - } - - protected AbstractOpenBisNodeModel(PortType[] inPortTypes, PortType[] outPortTypes) - { - super(inPortTypes, outPortTypes); - logger = NodeLogger.getLogger(getClass()); - } - - protected abstract void loadAdditionalValidatedSettingsFrom(NodeSettingsRO settings) - throws InvalidSettingsException; - - protected abstract void saveAdditionalSettingsTo(NodeSettingsWO settings); - - @Override - protected void loadValidatedSettingsFrom(NodeSettingsRO settings) throws InvalidSettingsException - { - url = settings.getString(URL_KEY); - credentialsName = settings.getString(CREDENTIALS_KEY, ""); - if (StringUtils.isNotBlank(credentialsName)) - { - ICredentials credentials = getCredentials(credentialsName); - if (credentials == null) - { - throw new InvalidSettingsException("Unknown credentials '" + credentialsName + "'."); - } - userID = credentials.getLogin(); - password = credentials.getPassword(); - } else - { - userID = settings.getString(USER_KEY); - password = Util.getDecryptedPassword(settings); - } - loadAdditionalValidatedSettingsFrom(settings); - } - - protected ICredentials getCredentials(String name) - { - return getCredentialsProvider().get(name); - } - - @Override - protected void saveSettingsTo(NodeSettingsWO settings) - { - settings.addString(URL_KEY, url); - settings.addString(CREDENTIALS_KEY, credentialsName); - if (StringUtils.isBlank(credentialsName)) - { - settings.addString(USER_KEY, userID); - settings.addString(PASSWORD_KEY, - password == null ? null : Util.getEncryptedPassword(password.toCharArray())); - } - saveAdditionalSettingsTo(settings); - } - - @Override - protected void validateSettings(NodeSettingsRO settings) throws InvalidSettingsException - { - } - - @Override - protected void reset() - { - } - - @Override - protected void saveInternals(File arg0, ExecutionMonitor arg1) throws IOException, - CanceledExecutionException - { - } - - @Override - protected void loadInternals(File arg0, ExecutionMonitor arg1) throws IOException, - CanceledExecutionException - { - } - - protected IQueryApiFacade createQueryFacade() - { - return FacadeFactory.create(url, userID, password); - } - - protected String getStringFlowVariable(String variableName) - { - return peekFlowVariableString(variableName); - } - - protected void addFlowVariable(String name, String value) - { - pushFlowVariableString(name, value); - } - -} \ No newline at end of file diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/AbstractOpenBisNodeTableModel.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/AbstractOpenBisNodeTableModel.java deleted file mode 100644 index f2ec503f57f4f0a8c262619cdcae4a310ed5ad7a..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/AbstractOpenBisNodeTableModel.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2011 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.knime.core.data.DataCell; -import org.knime.core.data.DataTableSpec; -import org.knime.core.data.DataType; -import org.knime.core.data.def.DefaultRow; -import org.knime.core.node.BufferedDataContainer; -import org.knime.core.node.BufferedDataTable; -import org.knime.core.node.ExecutionContext; -import org.knime.core.node.InvalidSettingsException; - -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableColumn; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableModel; - -/** - * Abstract super class of node models based on {@link QueryTableModel} objects returned by {@link IQueryApiFacade}. - * - * @author Franz-Josef Elmer - */ -public abstract class AbstractOpenBisNodeTableModel extends AbstractOpenBisNodeModel -{ - protected abstract QueryTableModel getData(IQueryApiFacade facade); - - @Override - protected BufferedDataTable[] execute(BufferedDataTable[] inData, ExecutionContext exec) - throws Exception - { - IQueryApiFacade facade = createQueryFacade(); - try - { - QueryTableModel result = getData(facade); - List<QueryTableColumn> columns = result.getColumns(); - String[] columnTitles = new String[columns.size()]; - DataType[] dataTypes = new DataType[columns.size()]; - ColumnType[] columnTypes = new ColumnType[columns.size()]; - Map<String, Integer> columnNames = new HashMap<String, Integer>(); - for (int i = 0, n = columns.size(); i < n; i++) - { - QueryTableColumn column = columns.get(i); - String title = column.getTitle(); - Integer count = columnNames.get(title); - if (count == null) - { - count = 0; - } - count++; - columnNames.put(title, count); - columnTitles[i] = count == 1 ? title : title + "[" + count + "]"; - columnTypes[i] = Util.getColumnType(column.getDataType()); - dataTypes[i] = columnTypes[i].getDataType(); - } - DataTableSpec dataTableSpec = new DataTableSpec(columnTitles, dataTypes); - BufferedDataContainer container = exec.createDataContainer(dataTableSpec); - List<Serializable[]> rows = result.getRows(); - for (int i = 0, n = rows.size(); i < n; i++) - { - Serializable[] row = rows.get(i); - DataCell[] cells = new DataCell[row.length]; - for (int c = 0; c < row.length; c++) - { - cells[c] = columnTypes[c].createCell(row[c]); - } - container.addRowToTable(new DefaultRow(Integer.toString(i), cells)); - } - container.close(); - return new BufferedDataTable[] { container.getTable() }; - } finally - { - facade.logout(); - } - } - - @Override - protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) - throws InvalidSettingsException - { - return new DataTableSpec[1]; - } -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ActionExecutor.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ActionExecutor.java deleted file mode 100644 index 7a8aa3417625f0936db552e8a974b67c14844800..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ActionExecutor.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -/** - * @author Franz-Josef Elmer - */ -public class ActionExecutor -{ - public <T> void executeAsync(final ILoadingBuildingAction<T> loadingBuildingAction, - final IAsyncNodeAction action) - { - execute(new Runnable() - { - @Override - public void run() - { - try - { - final T data = loadingBuildingAction.load(); - action.execute(new Runnable() - { - @Override - public void run() - { - loadingBuildingAction.build(data); - } - }); - } catch (Throwable ex) - { - action.handleException(ex); - } - } - }); - } - - protected void execute(Runnable runnable) - { - new Thread(runnable).start(); - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/AggregatedDataImportDescription.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/AggregatedDataImportDescription.java deleted file mode 100644 index dc55fc2c2e977d06a7824e7d367fc37a9a58774e..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/AggregatedDataImportDescription.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.io.Serializable; -import java.util.List; - -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.AggregationServiceDescription; - -/** - * Wrapper of {@link AggregationServiceDescription}. - * - * @author Franz-Josef Elmer - */ -public class AggregatedDataImportDescription implements Serializable -{ - public static final String PREFIX = "knime-"; - - public static final String FILE_PREFIX = PREFIX + "file-"; - - public static final String AGGREGATION_DESCRIPTION_KEY = "aggregation-description"; - - private static final long serialVersionUID = 1L; - - /** - * Adds specified description to descriptions list if its service key starts with 'knime-'. - */ - public static void addDescriptionIfDataTable( - List<AggregatedDataImportDescription> descriptions, - AggregationServiceDescription description) - { - addDescription(descriptions, description, PREFIX); - } - - /** - * Adds specified description to descriptions list if its service key starts with 'knime-file-'. - */ - public static void addDescriptionIfDataFile(List<AggregatedDataImportDescription> descriptions, - AggregationServiceDescription description) - { - addDescription(descriptions, description, FILE_PREFIX); - } - - private static void addDescription(List<AggregatedDataImportDescription> descriptions, - AggregationServiceDescription description, String keyPrefix) - { - String serviceKey = description.getServiceKey(); - if (serviceKey.startsWith(keyPrefix)) - { - descriptions.add(new AggregatedDataImportDescription(description, keyPrefix)); - } - } - - private final AggregationServiceDescription aggregationServiceDescription; - - private final String name; - - private final String dataStoreCode; - - private boolean showFullDescription; - - private AggregatedDataImportDescription( - AggregationServiceDescription aggregationServiceDescription, String keyPrefix) - { - this.aggregationServiceDescription = aggregationServiceDescription; - name = aggregationServiceDescription.getServiceKey().substring(keyPrefix.length()); - dataStoreCode = aggregationServiceDescription.getDataStoreCode(); - } - - public AggregationServiceDescription getAggregationServiceDescription() - { - return aggregationServiceDescription; - } - - public boolean isShowFullDescription() - { - return showFullDescription; - } - - public void setShowFullDescription(boolean showFullDescription) - { - this.showFullDescription = showFullDescription; - } - - /** - * Returns the service key with the prefix used for filtering. - */ - @Override - public String toString() - { - if (isShowFullDescription()) - { - return name + " (" + dataStoreCode + ")"; - } else - { - return name; - } - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ChooserTreeModel.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ChooserTreeModel.java deleted file mode 100644 index 9a3e3c2ecf61a2bee237d7aad7679b98bc3bd2d3..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ChooserTreeModel.java +++ /dev/null @@ -1,678 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.EnumSet; -import java.util.List; -import java.util.Map.Entry; -import java.util.TreeMap; - -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreePath; - -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwnerType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleFetchOption; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClauseAttribute; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.SearchOperator; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria; - -/** - * The tree model for {@link EntityChooser}. - * - * @author Franz-Josef Elmer - */ -public class ChooserTreeModel extends DefaultTreeModel -{ - static final String LOADING_TEXT = "Loading data..."; - - private static final long serialVersionUID = 1L; - - private static final class RootNode implements IChooserTreeNode<String> - { - static final RootNode ROOT = new RootNode(); - - @Override - public ChooserTreeNodeType getNodeType() - { - return ChooserTreeNodeType.ROOT; - } - - @Override - public String getNodeObject() - { - return "root"; - } - - @Override - public String toString() - { - return getNodeObject(); - } - } - - private static final class SpaceNode implements IChooserTreeNode<String> - { - private final String spaceCode; - - SpaceNode(String spaceCode) - { - this.spaceCode = spaceCode; - } - - @Override - public ChooserTreeNodeType getNodeType() - { - return ChooserTreeNodeType.SPACE; - } - - @Override - public String getNodeObject() - { - return spaceCode; - } - - @Override - public String toString() - { - return getNodeObject(); - } - } - - private static final class ProjectNode implements IChooserTreeNode<Project> - { - private final Project project; - - ProjectNode(Project project) - { - this.project = project; - } - - @Override - public ChooserTreeNodeType getNodeType() - { - return ChooserTreeNodeType.PROJECT; - } - - @Override - public Project getNodeObject() - { - return project; - } - - @Override - public String toString() - { - return project.getCode(); - } - } - - private static final class ExperimentNode implements IChooserTreeNode<Experiment> - { - private final Experiment experiment; - - ExperimentNode(Experiment experiment) - { - this.experiment = experiment; - } - - @Override - public ChooserTreeNodeType getNodeType() - { - return ChooserTreeNodeType.EXPERIMENT; - } - - @Override - public Experiment getNodeObject() - { - return experiment; - } - - @Override - public String toString() - { - return experiment.getCode(); - } - } - - private static final class SampleNode implements IChooserTreeNode<Sample> - { - private final Sample sample; - - SampleNode(Sample sample) - { - this.sample = sample; - } - - @Override - public ChooserTreeNodeType getNodeType() - { - return ChooserTreeNodeType.SAMPLE; - } - - @Override - public Sample getNodeObject() - { - return sample; - } - - @Override - public String toString() - { - return sample.getIdentifier(); - } - } - - private static final class DataSetNode implements IChooserTreeNode<DataSet> - { - private final DataSet dataSet; - - DataSetNode(DataSet dataSet) - { - this.dataSet = dataSet; - } - - @Override - public ChooserTreeNodeType getNodeType() - { - return ChooserTreeNodeType.DATA_SET; - } - - @Override - public DataSet getNodeObject() - { - return dataSet; - } - - @Override - public String toString() - { - return dataSet.getCode(); - } - } - - private static final class SamplesAndProjects - { - private final List<Sample> samples; - - private final List<Project> projects; - - SamplesAndProjects(List<Sample> samples, List<Project> projects) - { - this.samples = samples; - this.projects = projects; - } - - public List<Sample> getSamples() - { - return samples; - } - - public List<Project> getProjects() - { - return projects; - } - } - - private static final class SamplesAndDataSets - { - private final List<Sample> samples; - - private final List<DataSet> dataSets; - - SamplesAndDataSets(List<Sample> samples, List<DataSet> dataSets) - { - this.samples = samples; - this.dataSets = dataSets; - } - - public List<Sample> getSamples() - { - return samples; - } - - public List<DataSet> getDataSets() - { - return dataSets; - } - } - - private static final Comparator<Project> PROJECT_COMPARATOR = new Comparator<Project>() - { - @Override - public int compare(Project p1, Project p2) - { - return p1.getIdentifier().compareTo(p2.getIdentifier()); - } - }; - - private static final Comparator<Experiment> EXPERIMENT_COMPARATOR = - new Comparator<Experiment>() - { - @Override - public int compare(Experiment e1, Experiment e2) - { - return e1.getCode().compareTo(e2.getCode()); - } - }; - - private static final Comparator<Sample> SAMPLE_COMPARATOR = new Comparator<Sample>() - { - @Override - public int compare(Sample s1, Sample s2) - { - return s1.getIdentifier().compareTo(s2.getIdentifier()); - } - }; - - private static final Comparator<DataSet> DATA_SET_COMPARATOR = new Comparator<DataSet>() - { - @Override - public int compare(DataSet ds1, DataSet ds2) - { - return ds1.getCode().compareTo(ds2.getCode()); - } - }; - - private final IGeneralInformationService service; - - private final DataSetOwnerType entityType; - - private final boolean ownerEntity; - - private final String sessionToken; - - private List<SampleType> sampleTypes; - - private TreeMap<String, List<Project>> spaceToProjectsMap; - - ChooserTreeModel(DataSetOwnerType entityType, boolean ownerEntity, String sessionToken, - IGeneralInformationService service) - { - super(new DefaultMutableTreeNode()); - this.entityType = entityType; - this.ownerEntity = ownerEntity; - this.sessionToken = sessionToken; - this.service = service; - addTopLevelNodes(); - sampleTypes = service.listSampleTypes(sessionToken); - } - - private void addTopLevelNodes() - { - DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) getRoot(); - rootNode.setUserObject(RootNode.ROOT); - spaceToProjectsMap = new TreeMap<String, List<Project>>(); - List<Project> projects = service.listProjects(sessionToken); - Collections.sort(projects, PROJECT_COMPARATOR); - for (Project project : projects) - { - List<Project> list = spaceToProjectsMap.get(project.getSpaceCode()); - if (list == null) - { - list = new ArrayList<Project>(); - spaceToProjectsMap.put(project.getSpaceCode(), list); - } - list.add(project); - } - for (Entry<String, List<Project>> entry : spaceToProjectsMap.entrySet()) - { - String spaceCode = entry.getKey(); - DefaultMutableTreeNode spaceNode = new DefaultMutableTreeNode(new SpaceNode(spaceCode)); - rootNode.add(spaceNode); - spaceNode.add(createLoadingNode()); - } - } - - public boolean isSelectable(TreePath path) - { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); - Object userObject = node.getUserObject(); - if (userObject instanceof IChooserTreeNode == false) - { - return false; - } - IChooserTreeNode<?> treeNode = (IChooserTreeNode<?>) userObject; - ChooserTreeNodeType nodeType = treeNode.getNodeType(); - switch (entityType) - { - case EXPERIMENT: - return nodeType == ChooserTreeNodeType.EXPERIMENT; - case SAMPLE: - return nodeType == ChooserTreeNodeType.SAMPLE; - case DATA_SET: - return nodeType == ChooserTreeNodeType.DATA_SET; - } - return false; - } - - public void collapsNode(TreePath path) - { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); - Object userObject = node.getUserObject(); - if (userObject instanceof IChooserTreeNode) - { - IChooserTreeNode<?> treeNode = (IChooserTreeNode<?>) userObject; - if (EnumSet.of(ChooserTreeNodeType.PROJECT, ChooserTreeNodeType.EXPERIMENT, - ChooserTreeNodeType.SAMPLE).contains(treeNode.getNodeType())) - { - node.removeAllChildren(); - node.add(createLoadingNode()); - nodeStructureChanged(node); - } - } - } - - public void expandNode(TreePath path, IAsyncNodeAction action) - { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); - Object userObject = node.getUserObject(); - String space = tryGetWrappedObject(String.class, userObject); - if (space != null) - { - expandSpaceNode(node, space, action); - return; - } - Project project = tryGetWrappedObject(Project.class, userObject); - if (project != null) - { - expandProjectNode(node, project, action); - return; - } - Experiment experiment = tryGetWrappedObject(Experiment.class, userObject); - if (experiment != null) - { - expandExperimentNode(node, experiment, action); - return; - } - Sample sample = tryGetWrappedObject(Sample.class, userObject); - if (sample != null) - { - expandSampleNode(node, sample, action); - } - } - - private void expandSpaceNode(final DefaultMutableTreeNode node, final String space, IAsyncNodeAction action) - { - executeAsync(new ILoadingBuildingAction<SamplesAndProjects>() - { - @Override - public SamplesAndProjects load() - { - List<Sample> samples = new ArrayList<Sample>(); - if (isSampleTypeButNotOwner()) - { - gatherListableSamples(samples, space, null); - Collections.sort(samples, SAMPLE_COMPARATOR); - } - List<Project> projects = spaceToProjectsMap.get(space); - if (projects == null) - { - projects = Collections.emptyList(); - } - return new SamplesAndProjects(samples, projects); - } - - @Override - public void build(SamplesAndProjects data) - { - node.removeAllChildren(); - List<Sample> samples = data.getSamples(); - for (Sample sample : samples) - { - DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(new SampleNode(sample)); - node.add(childNode); - childNode.add(createLoadingNode()); - } - for (Project project : data.getProjects()) - { - DefaultMutableTreeNode projectNode = - new DefaultMutableTreeNode(new ProjectNode(project)); - node.add(projectNode); - projectNode.add(createLoadingNode()); - } - nodeStructureChanged(node); - } - }, action); - } - - private void expandProjectNode(final DefaultMutableTreeNode node, final Project project, - IAsyncNodeAction action) - { - executeAsync(new ILoadingBuildingAction<List<Experiment>>() - { - @Override - public List<Experiment> load() - { - List<Experiment> experiments = - service.listExperiments(sessionToken, Arrays.asList(project), null); - Collections.sort(experiments, EXPERIMENT_COMPARATOR); - return experiments; - } - - @Override - public void build(List<Experiment> data) - { - node.removeAllChildren(); - for (Experiment experiment : data) - { - DefaultMutableTreeNode childNode = - new DefaultMutableTreeNode(new ExperimentNode(experiment)); - node.add(childNode); - if (entityType != DataSetOwnerType.EXPERIMENT) - { - childNode.add(createLoadingNode()); - } - } - ChooserTreeModel.this.nodeStructureChanged(node); - } - }, action); - } - - private void expandExperimentNode(final DefaultMutableTreeNode node, final Experiment experiment, - IAsyncNodeAction action) - { - final String experimentPermId = experiment.getPermId(); - executeAsync(new ILoadingBuildingAction<SamplesAndDataSets>() - { - @Override - public SamplesAndDataSets load() - { - List<Sample> samples = new ArrayList<Sample>(); - gatherListableSamples(samples, null, experimentPermId); - Collections.sort(samples, SAMPLE_COMPARATOR); - List<DataSet> dataSets = new ArrayList<DataSet>(); - if (entityType == DataSetOwnerType.DATA_SET) - { - SearchCriteria searchCriteria = new SearchCriteria(); - SearchCriteria experimentCriteria = new SearchCriteria(); - experimentCriteria.addMatchClause(MatchClause.createAttributeMatch( - MatchClauseAttribute.PERM_ID, experimentPermId)); - searchCriteria.addSubCriteria(SearchSubCriteria - .createExperimentCriteria(experimentCriteria)); - dataSets = service.searchForDataSets(sessionToken, searchCriteria); - Collections.sort(dataSets, DATA_SET_COMPARATOR); - } - return new SamplesAndDataSets(samples, dataSets); - } - - @Override - public void build(SamplesAndDataSets data) - { - addSampleAndDataSetNodes(node, data); - } - }, action); - } - - private void gatherListableSamples(List<Sample> samples, String spaceOrNull, String experimentPermIdOrNull) - { - for (SampleType sampleType : sampleTypes) - { - if (sampleType.isListable()) - { - SearchCriteria searchCriteria = new SearchCriteria(); - searchCriteria.setOperator(SearchOperator.MATCH_ALL_CLAUSES); - searchCriteria.addMatchClause(MatchClause.createAttributeMatch( - MatchClauseAttribute.TYPE, - sampleType.getCode())); - if (spaceOrNull != null) - { - searchCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.SPACE, spaceOrNull)); - } - if (experimentPermIdOrNull != null) - { - SearchCriteria experimentCriteria = new SearchCriteria(); - experimentCriteria.addMatchClause(MatchClause.createAttributeMatch( - MatchClauseAttribute.PERM_ID, experimentPermIdOrNull)); - searchCriteria.addSubCriteria(SearchSubCriteria - .createExperimentCriteria(experimentCriteria)); - } - samples.addAll(service.searchForSamples(sessionToken, searchCriteria, - null)); - } - } - } - - private void expandSampleNode(final DefaultMutableTreeNode node, final Sample sample, - IAsyncNodeAction action) - { - final String samplePermId = sample.getPermId(); - executeAsync(new ILoadingBuildingAction<SamplesAndDataSets>() - { - @Override - public SamplesAndDataSets load() - { - List<Sample> samples = new ArrayList<Sample>(); - SearchCriteria sampleCriteria = new SearchCriteria(); - sampleCriteria.addMatchClause(MatchClause.createAttributeMatch( - MatchClauseAttribute.PERM_ID, samplePermId)); - List<Sample> sampleWithChildren = - service.searchForSamples(sessionToken, sampleCriteria, - EnumSet.of(SampleFetchOption.CHILDREN)); - if (sampleWithChildren.isEmpty() == false) - { - addFilteredSamples(samples, sampleWithChildren.get(0).getChildren()); - } - SearchCriteria searchCriteria = new SearchCriteria(); - searchCriteria.addSubCriteria(SearchSubCriteria - .createSampleContainerCriteria(sampleCriteria)); - addFilteredSamples(samples, - service.searchForSamples(sessionToken, searchCriteria, null)); - Collections.sort(samples, SAMPLE_COMPARATOR); - List<DataSet> dataSets = new ArrayList<DataSet>(); - if (entityType == DataSetOwnerType.DATA_SET) - { - searchCriteria = new SearchCriteria(); - sampleCriteria = new SearchCriteria(); - sampleCriteria.addMatchClause(MatchClause.createAttributeMatch( - MatchClauseAttribute.PERM_ID, samplePermId)); - searchCriteria.addSubCriteria(SearchSubCriteria - .createSampleCriteria(sampleCriteria)); - dataSets = service.searchForDataSets(sessionToken, searchCriteria); - Collections.sort(dataSets, DATA_SET_COMPARATOR); - } - return new SamplesAndDataSets(samples, dataSets); - } - - @Override - public void build(SamplesAndDataSets data) - { - addSampleAndDataSetNodes(node, data); - } - }, action); - } - - private void addFilteredSamples(List<Sample> samples, List<Sample> samplesToAdd) - { - boolean isNotSample = entityType != DataSetOwnerType.SAMPLE; - for (Sample sample : samplesToAdd) - { - if (isSampleTypeButNotOwner() || isNotSample || sample.getExperimentIdentifierOrNull() != null) - { - samples.add(sample); - } - } - } - - private boolean isSampleTypeButNotOwner() - { - return ownerEntity == false && entityType == DataSetOwnerType.SAMPLE; - } - - private void addSampleAndDataSetNodes(DefaultMutableTreeNode node, SamplesAndDataSets data) - { - node.removeAllChildren(); - for (DataSet dataSet : data.getDataSets()) - { - node.add(new DefaultMutableTreeNode(new DataSetNode(dataSet))); - } - for (Sample sample : data.getSamples()) - { - DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(new SampleNode(sample)); - node.add(childNode); - childNode.add(createLoadingNode()); - } - nodeStructureChanged(node); - } - - @SuppressWarnings("unchecked") - private <T> T tryGetWrappedObject(Class<T> clazz, Object nodeObject) - { - if (nodeObject instanceof IChooserTreeNode == false) - { - return null; - } - Object treeNode = ((IChooserTreeNode<?>) nodeObject).getNodeObject(); - return clazz.isInstance(treeNode) ? (T) treeNode : null; - } - - private DefaultMutableTreeNode createLoadingNode() - { - return new DefaultMutableTreeNode(LOADING_TEXT); - } - - private <T> void executeAsync(final ILoadingBuildingAction<T> loadingBuildingAction, - final IAsyncNodeAction action) - { - new ActionExecutor() - { - @Override - protected void execute(Runnable runnable) - { - ChooserTreeModel.this.execute(runnable); - } - }.executeAsync(loadingBuildingAction, action); - } - - void execute(Runnable runnable) - { - new Thread(runnable).start(); - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ChooserTreeNodeType.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ChooserTreeNodeType.java deleted file mode 100644 index af712ee54578076b3e0dd84e83494c7b08bc1a3b..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ChooserTreeNodeType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -/** - * Enum of different types of nodes in {@link ChooserTreeModel} - * - * @author Franz-Josef Elmer - */ -public enum ChooserTreeNodeType -{ - ROOT(""), SPACE(""), PROJECT("P"), EXPERIMENT("E"), SAMPLE("S"), DATA_SET("DS"); - - private final String label; - - private ChooserTreeNodeType(String label) - { - this.label = label; - } - - public String getLabel() - { - return label; - } -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ColumnType.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ColumnType.java deleted file mode 100644 index 3d5dcb4bee0b6f6ef04dd388e0933325d6128317..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ColumnType.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2010 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.io.Serializable; - -import org.knime.core.data.DataCell; -import org.knime.core.data.DataType; -import org.knime.core.data.def.DoubleCell; -import org.knime.core.data.def.LongCell; -import org.knime.core.data.def.StringCell; - -enum ColumnType -{ - DOUBLE(DoubleCell.TYPE) - { - @Override - public DataCell createCell(Serializable valueOrNull) - { - if (valueOrNull instanceof Double) - { - return new DoubleCell((Double) valueOrNull); - } - return DataType.getMissingCell(); - } - }, - LONG(LongCell.TYPE) - { - @Override - public DataCell createCell(Serializable valueOrNull) - { - if (valueOrNull instanceof Long) - { - return new LongCell((Long) valueOrNull); - } - return DataType.getMissingCell(); - } - }, - STRING(StringCell.TYPE) - { - - @Override - public DataCell createCell(Serializable valueOrNull) - { - return new StringCell(valueOrNull == null ? "" : valueOrNull.toString()); - } - }; - - private final DataType dataType; - - private ColumnType(DataType dataType) - { - this.dataType = dataType; - } - - public DataType getDataType() - { - return dataType; - } - - public abstract DataCell createCell(Serializable valueOrNull); -} \ No newline at end of file diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/DefaultAsyncNodeAction.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/DefaultAsyncNodeAction.java deleted file mode 100644 index 89070746d21f248c44a6ea823ca2a2dafe957bd4..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/DefaultAsyncNodeAction.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.awt.EventQueue; -import java.awt.Window; - -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; - -/** - * @author Franz-Josef Elmer - */ -public class DefaultAsyncNodeAction implements IAsyncNodeAction -{ - private final IOpenBisNode node; - - public DefaultAsyncNodeAction(IOpenBisNode node) - { - this.node = node; - } - - @Override - public void execute(Runnable runnable) - { - EventQueue.invokeLater(runnable); - } - - @Override - public void handleException(Throwable throwable) - { - node.logError(throwable); - JPanel panel = node.getPanel(); - Window windowAncestor = SwingUtilities.getWindowAncestor(panel); - if (windowAncestor != null && windowAncestor.isVisible()) - { - JOptionPane.showMessageDialog(panel, throwable.toString()); - } - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/EntityChooser.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/EntityChooser.java deleted file mode 100644 index ed14dfdec52a31edf0a118781bfce3e4a677a610..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/EntityChooser.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Window; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import javax.swing.Icon; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTree; -import javax.swing.SwingUtilities; -import javax.swing.event.TreeExpansionEvent; -import javax.swing.event.TreeExpansionListener; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreeCellRenderer; -import javax.swing.tree.TreePath; - -import org.apache.commons.lang.StringUtils; - -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwnerType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; - -/** - * Helper class showing a dialog for choosing a data set owner. - * - * @author Franz-Josef Elmer - */ -public class EntityChooser -{ - private static final class DecoratingTreeCellRenderer implements TreeCellRenderer - { - private static final class DecoratedIcon implements Icon - { - private final Icon icon; - - private final String text; - - DecoratedIcon(Icon icon, ChooserTreeNodeType type) - { - this.icon = icon; - this.text = type.getLabel(); - } - - @Override - public int getIconHeight() - { - return icon.getIconHeight(); - } - - @Override - public int getIconWidth() - { - return icon.getIconWidth(); - } - - @Override - public void paintIcon(Component c, Graphics g, int x, int y) - { - icon.paintIcon(c, g, x, y); - Color color = g.getColor(); - Font font = g.getFont(); - g.setColor(Color.BLACK); - g.setFont(new Font("SansSerif", Font.BOLD, 10)); - FontMetrics fontMetrics = g.getFontMetrics(); - int stringWidth = fontMetrics.stringWidth(text); - g.drawString(text, x + getIconWidth() - stringWidth, y + getIconHeight()); - g.setColor(color); - g.setFont(font); - } - } - - private final TreeCellRenderer cellRenderer; - - private DecoratingTreeCellRenderer(TreeCellRenderer cellRenderer) - { - this.cellRenderer = cellRenderer; - } - - @Override - public Component getTreeCellRendererComponent(JTree t, Object value, - boolean selected, boolean expanded, - boolean leaf, int row, boolean hasFocus) - { - Component component = - cellRenderer.getTreeCellRendererComponent(t, value, selected, expanded, leaf, - row, hasFocus); - Object userObject = ((DefaultMutableTreeNode) value).getUserObject(); - if (component instanceof JLabel && userObject instanceof IChooserTreeNode) - { - JLabel label = (JLabel) component; - Icon icon = label.getIcon(); - ChooserTreeNodeType nodeType = ((IChooserTreeNode<?>) userObject).getNodeType(); - label.setIcon(new DecoratedIcon(icon, nodeType)); - } - return component; - } - } - - private final DataSetOwnerType entityType; - - private final boolean ownerEntity; - - private final IGeneralInformationService service; - - private final Component component; - - private final String sessionToken; - - private final IAsyncNodeAction asyncNodeAction; - - private String entityIdentifier; - - public EntityChooser(Component component, DataSetOwnerType entityType, boolean ownerEntity, String sessionToken, - IGeneralInformationService service, IAsyncNodeAction asyncNodeAction) - { - this.component = component; - this.entityType = entityType; - this.ownerEntity = ownerEntity; - this.sessionToken = sessionToken; - this.service = service; - this.asyncNodeAction = asyncNodeAction; - } - - public String getOwnerOrNull() - { - final JTree tree = new JTree(); - final ChooserTreeModel chooserTreeModel = new ChooserTreeModel(entityType, ownerEntity, sessionToken, service); - tree.setModel(chooserTreeModel); - tree.setRootVisible(false); - tree.setEditable(false); - tree.setShowsRootHandles(true); - tree.setCellRenderer(new DecoratingTreeCellRenderer(tree.getCellRenderer())); - tree.addTreeExpansionListener(createTreeExpansionListener(tree, chooserTreeModel)); - JPanel treePanel = new JPanel(new BorderLayout()); - treePanel.add(new JScrollPane(tree), BorderLayout.CENTER); - final JOptionPane optionPane = new JOptionPane(treePanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); - optionPane.setSize(800, 800); - tree.addMouseListener(new MouseAdapter() - { - @Override - public void mousePressed(MouseEvent e) - { - if (e.getClickCount() > 1) - { - TreePath closestPathForLocation = - tree.getClosestPathForLocation(e.getX(), e.getY()); - if (chooserTreeModel.isSelectable(closestPathForLocation)) - { - Window window = SwingUtilities.getWindowAncestor(tree); - if (window != null) - { - optionPane.setValue(JOptionPane.OK_OPTION); - window.setVisible(false); - } - } - } - } - }); - String title = StringUtils.capitalize(entityType.toString().toLowerCase()) + " Chooser"; - final JDialog dialog = optionPane.createDialog(component, title); - dialog.setResizable(true); - optionPane.addPropertyChangeListener(new PropertyChangeListener() - { - @Override - public void propertyChange(PropertyChangeEvent evt) - { - if (evt.getSource() == optionPane - && JOptionPane.VALUE_PROPERTY.equals(evt.getPropertyName()) - && new Integer(JOptionPane.OK_OPTION).equals(evt.getNewValue())) - { - TreePath selectionPath = tree.getSelectionPath(); - if (selectionPath != null && chooserTreeModel.isSelectable(selectionPath) == false) - { - dialog.setVisible(true); - } - } - } - }); - dialog.setVisible(true); - Object value = optionPane.getValue(); - if (new Integer(JOptionPane.OK_OPTION).equals(value)) - { - setEntityIdentifier(tree); - } - return entityIdentifier; - } - - private TreeExpansionListener createTreeExpansionListener(final JTree tree, - final ChooserTreeModel chooserTreeModel) - { - return new TreeExpansionListener() - { - @Override - public void treeExpanded(TreeExpansionEvent event) - { - chooserTreeModel.expandNode(event.getPath(), asyncNodeAction); - } - - @Override - public void treeCollapsed(TreeExpansionEvent event) - { - chooserTreeModel.collapsNode(event.getPath()); - } - }; - } - - private void setEntityIdentifier(JTree tree) - { - TreePath selectionPath = tree.getSelectionPath(); - if (selectionPath == null) - { - return; - } - Object selectedItem = - ((DefaultMutableTreeNode) selectionPath.getLastPathComponent()).getUserObject(); - if (selectedItem instanceof IChooserTreeNode == false) - { - return; - } - entityIdentifier = selectedItem.toString(); - Object nodeObject = ((IChooserTreeNode<?>) selectedItem).getNodeObject(); - if (nodeObject instanceof Experiment) - { - entityIdentifier = ((Experiment) nodeObject).getIdentifier(); - } - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/EntityField.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/EntityField.java deleted file mode 100644 index 66355619affbdd1ff88af9d4cd3c3a2bcc1f08c9..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/EntityField.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JTextField; - -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwnerType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; - -/** - * One-line text field for an identifier for an entity of type Experiment, Sample or Data Set. An additional button allows to use - * {@link EntityChooser}. - * - * @author Franz-Josef Elmer - */ -class EntityField implements IField -{ - private final DataSetOwnerType ownerType; - - private final IQueryApiFacadeProvider facadeProvider; - - private final JPanel textFieldWithButton; - - private final JTextField ownerField; - - private final IAsyncNodeAction asyncNodeAction; - - EntityField(DataSetOwnerType entityType, IQueryApiFacadeProvider facadeProvider, IAsyncNodeAction asyncNodeAction) - { - this.ownerType = entityType; - this.facadeProvider = facadeProvider; - this.asyncNodeAction = asyncNodeAction; - textFieldWithButton = new JPanel(new BorderLayout()); - ownerField = new JTextField(20); - textFieldWithButton.add(ownerField, BorderLayout.CENTER); - JButton button = new JButton("..."); - button.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - chooseOwner(); - } - }); - textFieldWithButton.add(button, BorderLayout.EAST); - } - - @Override - public JComponent getComponent() - { - return textFieldWithButton; - } - - @Override - public String getValue() - { - return ownerField.getText(); - } - - @Override - public void setValue(String value) - { - ownerField.setText(value); - } - - private void chooseOwner() - { - IQueryApiFacade facade = facadeProvider.getQueryFacade(); - String sessionToken = facade.getSessionToken(); - IGeneralInformationService service = facade.getGeneralInformationService(); - String ownerOrNull = - new EntityChooser(ownerField, ownerType, false, sessionToken, service, asyncNodeAction).getOwnerOrNull(); - if (ownerOrNull != null) - { - ownerField.setText(ownerOrNull); - } - - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/FieldDescription.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/FieldDescription.java deleted file mode 100644 index 6d5444cb86cb2b287270930f9519526dc3ce7119..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/FieldDescription.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import org.apache.commons.lang.StringUtils; - -import ch.systemsx.cisd.openbis.knime.server.FieldType; - -/** - * Description necessary to create a {@link IField}. - * - * @author Franz-Josef Elmer - */ -public class FieldDescription -{ - private final String name; - - private final FieldType fieldType; - - private final String fieldParameters; - - public FieldDescription(String name, FieldType fieldType, String fieldParameters) - { - this.name = name; - this.fieldType = fieldType; - this.fieldParameters = fieldParameters; - } - - public String getName() - { - return name; - } - - public FieldType getFieldType() - { - return fieldType; - } - - public String getFieldParameters() - { - return fieldParameters; - } - - @Override - public String toString() - { - return name + ":" + fieldType + (StringUtils.isBlank(fieldParameters) ? "" : "[" + fieldParameters + "]"); - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/GUIUtil.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/GUIUtil.java deleted file mode 100644 index d9ab81c367b8c2121552e215e6621a265cb59b8d..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/GUIUtil.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JTextField; -import javax.swing.ListSelectionModel; -import javax.swing.RowFilter; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumnModel; -import javax.swing.table.TableModel; -import javax.swing.table.TableRowSorter; - -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; - -/** - * GUI utility functions. - * - * @author Franz-Josef Elmer - */ -public class GUIUtil -{ - public static List<DataSet> getSelectedDataSets(Component parentComponent, Cursor oldCursor, - List<DataSet> dataSets, boolean singleSelection) - { - JTable table = new JTable(createTableModel(dataSets)); - table.setPreferredScrollableViewportSize(new Dimension(900, 500)); - JTableHeader tableHeader = table.getTableHeader(); - final TableColumnModel columnModel = tableHeader.getColumnModel(); - final TableCellRenderer renderer = tableHeader.getDefaultRenderer(); - tableHeader.setDefaultRenderer(new TableCellRenderer() - { - @Override - public Component getTableCellRendererComponent(JTable t, Object value, boolean isSelected, - boolean hasFocus, int row, int column) - { - Component component = renderer.getTableCellRendererComponent(t, value, isSelected, hasFocus, row, column); - if (component instanceof JComponent) - { - String title = columnModel.getColumn(column).getHeaderValue().toString(); - ((JComponent) component).setToolTipText(title); - } - return component; - } - }); - TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(table.getModel()); - table.setRowSorter(sorter); - ListSelectionModel selectionModel = table.getSelectionModel(); - if (singleSelection) - { - selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - } else - { - selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - } - JScrollPane scrollPane = new JScrollPane(table); - JPanel panel = new JPanel(new BorderLayout()); - panel.add(new JLabel("Choose a data set:"), BorderLayout.NORTH); - panel.add(scrollPane, BorderLayout.CENTER); - JPanel filterPanel = new JPanel(new BorderLayout()); - filterPanel.add(new JLabel("Filter:"), BorderLayout.WEST); - JTextField filterField = createFilterField(sorter); - filterPanel.add(filterField, BorderLayout.CENTER); - panel.add(filterPanel, BorderLayout.SOUTH); - JOptionPane optionPane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); - parentComponent.setCursor(oldCursor); - JDialog dialog = optionPane.createDialog(parentComponent, "Data Sets"); - dialog.setResizable(true); - dialog.setVisible(true); - List<DataSet> result = new ArrayList<DataSet>(); - Object value = optionPane.getValue(); - if (new Integer(JOptionPane.OK_OPTION).equals(value)) - { - int[] selectedRows = table.getSelectedRows(); - for (int rowIndex : selectedRows) - { - result.add(dataSets.get(sorter.convertRowIndexToModel(rowIndex))); - } - } - return result; - } - - private static TableModel createTableModel(final List<DataSet> dataSets) - { - TableModelBuilder builder = new TableModelBuilder(); - for (DataSet dataSet : dataSets) - { - builder.add(dataSet); - } - return builder.getTableModel(); - } - - private static JTextField createFilterField(final TableRowSorter<TableModel> sorter) - { - final JTextField filterField = new JTextField(); - filterField.getDocument().addDocumentListener(new DocumentListener() - { - @Override - public void changedUpdate(DocumentEvent e) - { - newFilter(); - } - - @Override - public void insertUpdate(DocumentEvent e) - { - newFilter(); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - newFilter(); - } - - private void newFilter() - { - final String text = filterField.getText().toLowerCase(); - RowFilter<TableModel, Object> rf = new RowFilter<TableModel, Object>() - { - @Override - public boolean include( - Entry<? extends TableModel, ? extends Object> entry) - { - for (int i = 0, n = entry.getValueCount(); i < n; i++) - { - if (entry.getStringValue(i).toLowerCase().indexOf(text) >= 0) - { - return true; - } - } - return false; - } - }; - sorter.setRowFilter(rf); - } - }); - return filterField; - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IAsyncNodeAction.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IAsyncNodeAction.java deleted file mode 100644 index 545960183966b4bb3dae1298469966cb7f8c1369..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IAsyncNodeAction.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -/** - * Action performed asynchronously. - * - * @author Franz-Josef Elmer - */ -public interface IAsyncNodeAction -{ - public void execute(Runnable runnable); - - public void handleException(Throwable throwable); -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IChooserTreeNode.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IChooserTreeNode.java deleted file mode 100644 index aebf8963b04bda828a9fb03521bd20de35738076..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IChooserTreeNode.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -/** - * Common interface of all nodes in a {@link ChooserTreeModel}. - * - * @author Franz-Josef Elmer - */ -public interface IChooserTreeNode<T> -{ - public ChooserTreeNodeType getNodeType(); - - public T getNodeObject(); -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IField.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IField.java deleted file mode 100644 index 6994d526560c25376bdceafb1e00c49a2e65373f..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IField.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import javax.swing.JComponent; - -/** - * Abstraction a GUI field with a String value. It is represented by a {@link JComponent}. - * - * @author Franz-Josef Elmer - */ -public interface IField -{ - public JComponent getComponent(); - - public String getValue(); - - public void setValue(String value); -} \ No newline at end of file diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ILoadingBuildingAction.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ILoadingBuildingAction.java deleted file mode 100644 index fab5406dd5e098e761177d01a62e54eaa28fbc39..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ILoadingBuildingAction.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -/** - * Two step action (done in different threads): an expensive load action and a fast build action. - * - * @author Franz-Josef Elmer - */ -public interface ILoadingBuildingAction<T> -{ - public T load(); - - public void build(T data); -} \ No newline at end of file diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IOpenBisNode.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IOpenBisNode.java deleted file mode 100644 index 1fa05d1944bbabf70256a907de617f73ef496f5b..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IOpenBisNode.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import javax.swing.JPanel; - -/** - * Interface all openBIS nodes have to implement. - * - * @author Franz-Josef Elmer - */ -public interface IOpenBisNode -{ - public void logError(Throwable throwable); - - public JPanel getPanel(); -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IOpenbisServiceFacadeFactory.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IOpenbisServiceFacadeFactory.java deleted file mode 100644 index 1d68193d8de15ce6d534a89582cd416c00e5a3ad..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IOpenbisServiceFacadeFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import ch.systemsx.cisd.openbis.dss.client.api.v1.IOpenbisServiceFacade; - -/** - * Factory of a {@link IOpenbisServiceFacade}. - * - * @author Franz-Josef Elmer - */ -public interface IOpenbisServiceFacadeFactory -{ - public IOpenbisServiceFacade createFacade(String url, String userID, String password); - - public IOpenbisServiceFacade createFacade(String url, String sessionToken); -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IQueryApiFacadeProvider.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IQueryApiFacadeProvider.java deleted file mode 100644 index c1fed990c15558c8d638537e464753be5506352b..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IQueryApiFacadeProvider.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; - -/** - * Provider of an {@link IQueryApiFacade}. - * - * @author Franz-Josef Elmer - */ -public interface IQueryApiFacadeProvider -{ - public IQueryApiFacade getQueryFacade(); -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IQueryFacadeAction.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IQueryFacadeAction.java deleted file mode 100644 index 0a5e0840167294c882881885b7ef241b45eadc86..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/IQueryFacadeAction.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; - -/** - * An action which uses {@link IQueryApiFacade}. - * - * @author Franz-Josef Elmer - */ -public interface IQueryFacadeAction -{ - public void execute(IQueryApiFacade queryFacade); -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/OpenbisServiceFacadeFactory.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/OpenbisServiceFacadeFactory.java deleted file mode 100644 index dede6fa8de06d42c24cc345b17f672aca2feecd2..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/OpenbisServiceFacadeFactory.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import ch.systemsx.cisd.openbis.dss.client.api.v1.IOpenbisServiceFacade; - -/** - * Standard implementation for {@link IOpenbisServiceFacadeFactory}. - * - * @author Franz-Josef Elmer - */ -public class OpenbisServiceFacadeFactory implements IOpenbisServiceFacadeFactory -{ - private static final int TIME_OUT = 10000; - - @Override - public IOpenbisServiceFacade createFacade(String url, String userID, String password) - { - IOpenbisServiceFacade facade = - ch.systemsx.cisd.openbis.dss.client.api.v1.OpenbisServiceFacadeFactory.tryCreate( - userID, password, url, TIME_OUT); - return check(facade, url); - } - - @Override - public IOpenbisServiceFacade createFacade(String url, String sessionToken) - { - IOpenbisServiceFacade facade = - ch.systemsx.cisd.openbis.dss.client.api.v1.OpenbisServiceFacadeFactory.tryCreate(sessionToken, url, TIME_OUT); - return check(facade, url); - } - - private IOpenbisServiceFacade check(IOpenbisServiceFacade facade, String url) - { - if (facade == null) - { - throw new IllegalArgumentException("Couldn't connect to openBIS at " + url); - } - return facade; - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ParameterBindings.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ParameterBindings.java deleted file mode 100644 index b89c0fe80c7c206df3a00c05ed37d962a7f08b00..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/ParameterBindings.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2010 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Map.Entry; - -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; - -import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; - -/** - * Helper class for handling parameter bindings. - * - * @author Franz-Josef Elmer - */ -public class ParameterBindings -{ - public static final String PARAMETER_KEYS_KEY = "query-parameter-keys"; - - public static final String PARAMETER_VALUES_KEY = "query-parameter-values"; - - private Map<String, String> bindings = new LinkedHashMap<String, String>(); - - public void removeAllBindings() - { - bindings.clear(); - } - - public void bind(String parameter, String value) - { - bindings.put(parameter, value); - } - - public Map<String, String> getBindings() - { - return bindings; - } - - public String tryToGetBinding(String parameter) - { - return bindings.get(parameter); - } - - public void loadValidatedSettingsFrom(NodeSettingsRO settings) - { - String[] parameterKeys; - String[] parameterValues; - try - { - parameterKeys = settings.getStringArray(PARAMETER_KEYS_KEY); - parameterValues = settings.getStringArray(PARAMETER_VALUES_KEY); - } catch (InvalidSettingsException ex) - { - throw CheckedExceptionTunnel.wrapIfNecessary(ex); - } - bindings.clear(); - for (int i = 0, n = Math.min(parameterKeys.length, parameterValues.length); i < n; i++) - { - bindings.put(parameterKeys[i], parameterValues[i]); - } - } - - public void saveSettingsTo(NodeSettingsWO settings) - { - List<String> parameterKeys = new ArrayList<String>(bindings.size()); - List<String> parameterValues = new ArrayList<String>(bindings.size()); - Set<Entry<String, String>> entrySet = bindings.entrySet(); - for (Entry<String, String> entry : entrySet) - { - parameterKeys.add(entry.getKey()); - parameterValues.add(entry.getValue()); - } - settings.addStringArray(PARAMETER_KEYS_KEY, parameterKeys.toArray(new String[0])); - settings.addStringArray(PARAMETER_VALUES_KEY, parameterValues.toArray(new String[0])); - } -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/TableModelBuilder.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/TableModelBuilder.java deleted file mode 100644 index f8ef1ed24be1e1be1ec6b0b2c4bd34cb71754166..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/TableModelBuilder.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright 2011 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableModel; - -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; - -/** - * Builder for a {@link DataSet} based {@link TableModel}. - * - * @author Franz-Josef Elmer - */ -public class TableModelBuilder -{ - private static final class Column - { - private final String name; - - private final List<String> values = new ArrayList<String>(); - - Column(String name) - { - this.name = name; - } - - String getName() - { - return name; - } - - int getSize() - { - return values.size(); - } - - String getValue(int rowIndex) - { - return rowIndex < getSize() ? values.get(rowIndex) : ""; - } - - void addValueAt(int rowIndex, String value) - { - while (values.size() < rowIndex) - { - values.add(""); - } - values.add(value == null ? "" : value); - } - - boolean isEmpty() - { - for (String value : values) - { - if (value.length() > 0) - { - return false; - } - } - return true; - } - - boolean hasOnlyOneDistinctValue() - { - String distinctValue = null; - for (String value : values) - { - if (distinctValue == null) - { - distinctValue = value; - } else if (distinctValue.equals(value) == false) - { - return false; - } - } - return true; - } - } - - private static final class DataSetTableModel extends AbstractTableModel - { - private static final long serialVersionUID = 1L; - - private final List<Column> columns; - - private DataSetTableModel(List<Column> columns) - { - this.columns = columns; - } - - @Override - public boolean isCellEditable(int row, int column) - { - return false; - } - - @Override - public int getRowCount() - { - int rowCount = 0; - for (Column column : columns) - { - rowCount = Math.max(rowCount, column.getSize()); - } - return rowCount; - } - - @Override - public int getColumnCount() - { - return columns.size(); - } - - @Override - public String getColumnName(int columnIndex) - { - return columns.get(columnIndex).getName(); - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) - { - return columns.get(columnIndex).getValue(rowIndex); - } - } - - private final Column codeColumn = new Column("Code"); - - private final Column typeColumn = new Column("Type"); - - private final Column experimentColumn = new Column("Experiment"); - - private final Column sampleColumn = new Column("Sample"); - - private final Map<String, Column> propertyColumns = new HashMap<String, Column>(); - - private int numberOfAddedDataSets; - - public TableModel getTableModel() - { - final List<Column> columns = new ArrayList<Column>(propertyColumns.values()); - Collections.sort(columns, new Comparator<Column>() - { - @Override - public int compare(Column c1, Column c2) - { - return c1.getName().compareTo(c2.getName()); - } - }); - columns.add(0, experimentColumn); - if (sampleColumn.isEmpty() == false) - { - columns.add(0, sampleColumn); - } - if (typeColumn.hasOnlyOneDistinctValue() == false) - { - columns.add(0, typeColumn); - } - columns.add(0, codeColumn); - return new DataSetTableModel(columns); - } - - public void add(DataSet dataSet) - { - codeColumn.addValueAt(numberOfAddedDataSets, dataSet.getCode()); - typeColumn.addValueAt(numberOfAddedDataSets, dataSet.getDataSetTypeCode()); - experimentColumn.addValueAt(numberOfAddedDataSets, dataSet.getExperimentIdentifier()); - sampleColumn.addValueAt(numberOfAddedDataSets, dataSet.getSampleIdentifierOrNull()); - HashMap<String, String> properties = dataSet.getProperties(); - Set<java.util.Map.Entry<String, String>> entrySet = properties.entrySet(); - for (Entry<String, String> entry : entrySet) - { - String key = entry.getKey(); - Column column = propertyColumns.get(key); - if (column == null) - { - column = new Column(key); - propertyColumns.put(key, column); - } - column.addValueAt(numberOfAddedDataSets, entry.getValue()); - } - numberOfAddedDataSets++; - } - -} \ No newline at end of file diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/TextField.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/TextField.java deleted file mode 100644 index 4acceb6f96798b5ea3509b7cdc496b6dffa89e94..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/TextField.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import javax.swing.JComponent; -import javax.swing.JTextField; - -/** - * One line text field. - * - * @author Franz-Josef Elmer - */ -class TextField implements IField -{ - private JTextField textField; - - TextField() - { - textField = new JTextField(20); - } - - @Override - public JComponent getComponent() - { - return textField; - } - - @Override - public String getValue() - { - return textField.getText(); - } - - @Override - public void setValue(String value) - { - textField.setText(value); - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/Util.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/Util.java deleted file mode 100644 index dfe58318372a958532cc51b8366eb0cbde2c69cd..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/Util.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Copyright 2010 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import static ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeModel.PASSWORD_KEY; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.commons.lang.StringUtils; -import org.knime.core.node.NodeLogger; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.util.KnimeEncryption; - -import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; -import ch.systemsx.cisd.openbis.knime.server.Constants; -import ch.systemsx.cisd.openbis.knime.server.FieldType; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableColumn; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableColumnDataType; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableModel; - -/** - * Utility methods. - * - * @author Franz-Josef Elmer - */ -public class Util -{ - public static final String VARIABLE_PREFIX = "openbis."; - - private static final String[] EXPECTED_COLUMNS = { Constants.PARAMETER_DESCRIPTION_NAME_COLUMN, - Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN }; - - public static <D extends Serializable> byte[] serializeDescription(D descriptionOrNull) - { - if (descriptionOrNull == null) - { - return null; - } - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try - { - new ObjectOutputStream(baos).writeObject(descriptionOrNull); - return baos.toByteArray(); - } catch (IOException ex) - { - return null; - } - } - - @SuppressWarnings("unchecked") - public static <D extends Serializable> D deserializeDescription(byte[] serializeDescriptionOrNull) - { - if (serializeDescriptionOrNull == null) - { - return null; - } - ByteArrayInputStream bais = new ByteArrayInputStream(serializeDescriptionOrNull); - try - { - return (D) new ObjectInputStream(bais).readObject(); - } catch (Exception ex) - { - return null; - } - } - - public static List<FieldDescription> getFieldDescriptions(IQueryApiFacade facade, - AggregatedDataImportDescription description, NodeLogger logger) - { - List<FieldDescription> fieldDescriptions = new ArrayList<FieldDescription>(); - Map<String, Object> serviceParameters = new HashMap<String, Object>(); - serviceParameters.put(Constants.REQUEST_KEY, Constants.GET_PARAMETER_DESCRIPTIONS_REQUEST); - QueryTableModel report = - createReportFromAggregationService(facade, description, serviceParameters); - List<QueryTableColumn> columns = report.getColumns(); - if (columns.size() != EXPECTED_COLUMNS.length) - { - throw createException(description, columns.size() + " columns instead of " + EXPECTED_COLUMNS.length); - } - for (int i = 0; i < EXPECTED_COLUMNS.length; i++) - { - String expectedColumn = EXPECTED_COLUMNS[i]; - String column = columns.get(i).getTitle(); - if (expectedColumn.equals(column) == false) - { - throw createException(description, (i + 1) + ". column is '" + column - + "' instead of '" + expectedColumn + "'."); - } - } - List<Serializable[]> rows = report.getRows(); - for (Serializable[] row : rows) - { - if (row == null || row.length == 0 || row[0] == null) - { - throw createException(description, "Empty row."); - } - String name = String.valueOf(row[0]); - if (StringUtils.isBlank(name)) - { - throw createException(description, "Unspecified parameter name."); - } - FieldType fieldType = FieldType.VARCHAR; - String fieldParameters = ""; - if (row.length > 1) - { - Serializable parameter = row[1]; - if (parameter != null) - { - String type = String.valueOf(parameter); - int indexOfSeparator = type.indexOf(':'); - if (indexOfSeparator >= 0) - { - fieldParameters = type.substring(indexOfSeparator + 1); - type = type.substring(0, indexOfSeparator); - } - try - { - fieldType = FieldType.valueOf(type.trim().toUpperCase()); - } catch (IllegalArgumentException ex) - { - logger.warn("Unknown field type '" + type + "' using " + fieldType + " instead."); - } - } - } - fieldDescriptions.add(new FieldDescription(name, fieldType, fieldParameters)); - } - return fieldDescriptions; - } - - private static RuntimeException createException(AggregatedDataImportDescription description, String msg) - { - String service = description.getAggregationServiceDescription().getServiceKey(); - return new IllegalArgumentException("Invalid response of aggregation service '" + service + "' when invoked with parameter " - + Constants.REQUEST_KEY + " = " + Constants.GET_PARAMETER_DESCRIPTIONS_REQUEST + ":\n" + msg); - } - - public static ColumnType getColumnType(QueryTableColumnDataType dataType) - { - switch (dataType) - { - case DOUBLE: - return ColumnType.DOUBLE; - case LONG: - return ColumnType.LONG; - default: - return ColumnType.STRING; - } - } - - public static String getDecryptedPassword(NodeSettingsRO settings) - { - try - { - String encryptedPassword = settings.getString(PASSWORD_KEY, ""); - return StringUtils.isBlank(encryptedPassword) ? "" : KnimeEncryption.decrypt(encryptedPassword); - } catch (Exception ex) - { - throw CheckedExceptionTunnel.wrapIfNecessary(ex); - } - } - - public static String getEncryptedPassword(char[] bytes) - { - try - { - return KnimeEncryption.encrypt(bytes); - } catch (Exception ex) - { - throw CheckedExceptionTunnel.wrapIfNecessary(ex); - } - } - - public static QueryTableModel createReportFromAggregationService(IQueryApiFacade facade, - ParameterBindings parameterBindings, AggregatedDataImportDescription description) - { - Map<String, Object> serviceParameters = new HashMap<String, Object>(); - for (Entry<String, String> entry : parameterBindings.getBindings().entrySet()) - { - serviceParameters.put(entry.getKey(), entry.getValue()); - } - return createReportFromAggregationService(facade, description, serviceParameters); - } - - public static QueryTableModel createReportFromAggregationService(IQueryApiFacade facade, - AggregatedDataImportDescription description, Map<String, Object> serviceParameters) - { - QueryTableModel result = facade.createReportFromAggregationService( - description.getAggregationServiceDescription(), serviceParameters); - assertNoError(result, description); - return result; - } - - private static void assertNoError(QueryTableModel result, AggregatedDataImportDescription description) - { - List<QueryTableColumn> columns = result.getColumns(); - if (columns.size() != 5 || columns.get(0).getTitle().equals(Constants.EXCEPTION_COLUMN) == false) - { - return; - } - ExceptionReplicate rootException = null; - ExceptionReplicate previousException = null; - ExceptionReplicate currentExecption = null; - List<Serializable[]> rows = result.getRows(); - List<StackTraceElement> stackTrace = new ArrayList<StackTraceElement>(); - for (Serializable[] row : rows) - { - Serializable exception = row[0]; - if ("".equals(exception) == false) - { - currentExecption = new ExceptionReplicate(String.valueOf(row[0])); - if (previousException != null) - { - previousException.setStackTrace(stackTrace.toArray(new StackTraceElement[0])); - previousException.setCause(currentExecption); - stackTrace.clear(); - } else - { - rootException = currentExecption; - } - previousException = currentExecption; - } else if (currentExecption != null) - { - int lineNumber; - try - { - lineNumber = Integer.parseInt(String.valueOf(row[4])); - } catch (NumberFormatException ex) - { - lineNumber = 0; - } - StackTraceElement stackTraceElement = new StackTraceElement(String.valueOf(row[1]), - String.valueOf(row[2]), String.valueOf(row[3]), - lineNumber); - stackTrace.add(stackTraceElement); - } - } - if (currentExecption != null && stackTrace.isEmpty() == false) - { - currentExecption.setStackTrace(stackTrace.toArray(new StackTraceElement[0])); - } - if (rootException != null) - { - throw new RuntimeException(rootException); - } - } - - private static final class ExceptionReplicate extends RuntimeException - { - private static final long serialVersionUID = 1L; - - private static String extractMessage(String toStringText) - { - int indexOfColon = toStringText.indexOf(":"); - return indexOfColon < 0 ? "" : toStringText.substring(indexOfColon + 1).trim(); - } - - private final String toStringText; - - private ExceptionReplicate cause; - - ExceptionReplicate(String toStringText) - { - super(extractMessage(toStringText)); - this.toStringText = toStringText; - } - - public void setCause(ExceptionReplicate cause) - { - this.cause = cause; - } - - @Override - public Throwable getCause() - { - return cause; - } - - @Override - public String toString() - { - return toStringText; - } - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/VocabularyField.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/VocabularyField.java deleted file mode 100644 index 26cd1d9fd3ba4264a36a9c212c490146a8860727..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/VocabularyField.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JComboBox; -import javax.swing.JComponent; - -import org.apache.commons.lang.StringUtils; - -/** - * Combo box with a list of String terms. - * - * @author Franz-Josef Elmer - */ -class VocabularyField implements IField -{ - private JComboBox comboBox; - - public VocabularyField(String fieldParameters) - { - String[] splittedParameters = fieldParameters.split(","); - List<String> terms = new ArrayList<String>(); - for (String term : splittedParameters) - { - if (StringUtils.isNotBlank(term)) - { - terms.add(term.trim()); - } - } - comboBox = new JComboBox(terms.toArray()); - comboBox.setEditable(false); - } - - @Override - public JComponent getComponent() - { - return comboBox; - } - - @Override - public String getValue() - { - return (String) comboBox.getSelectedItem(); - } - - @Override - public void setValue(String value) - { - comboBox.setSelectedItem(value); - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/openbis.png b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/openbis.png deleted file mode 100644 index a5b30672e374063ad0b36c4469a028e9e61090d7..0000000000000000000000000000000000000000 Binary files a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/common/openbis.png and /dev/null differ diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeFactory.xml b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeFactory.xml deleted file mode 100644 index 91e12e4538ad5ecfe997a626b380d623d9efa3e8..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeFactory.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE knimeNode PUBLIC "-//UNIKN//DTD KNIME Node 2.0//EN" "http://www.knime.org/Node.dtd"> -<knimeNode icon="../common/openbis.png" type="Source"> - <name>openBIS Aggregated Data File Importer</name> - - <shortDescription>Imports a data file from special openBIS aggregation services.</shortDescription> - - <fullDescription> - <intro>This data source node invokes a special openBIS aggregation services which creates from some input - parameters a file which is delivered to the node at execution time. - <p> - For more details see <a href="https://wiki-bsse.ethz.ch/display/openBISDoc1304/openBIS+KNIME+Nodes">openBIS KNIME Nodes</a>. - </p> - </intro> - </fullDescription> - - <ports> - <outPort index="0" name="Result Set">URI of the imported data file.</outPort> - </ports> -</knimeNode> diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeModel.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeModel.java deleted file mode 100644 index 177c92a42e8f72016487e6abfea9589235c0e8ea..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeModel.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.net.URLEncoder; -import java.util.Arrays; -import java.util.List; - -import javax.activation.MimetypesFileTypeMap; - -import org.apache.commons.io.IOUtils; -import org.knime.core.data.uri.URIContent; -import org.knime.core.data.uri.URIPortObject; -import org.knime.core.data.uri.URIPortObjectSpec; -import org.knime.core.node.ExecutionContext; -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; -import org.knime.core.node.port.PortObject; -import org.knime.core.node.port.PortObjectSpec; -import org.knime.core.node.port.PortType; - -import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataStore; -import ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeModel; -import ch.systemsx.cisd.openbis.knime.common.AggregatedDataImportDescription; -import ch.systemsx.cisd.openbis.knime.common.ParameterBindings; -import ch.systemsx.cisd.openbis.knime.common.Util; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableModel; - -/** - * Model which requests a data file created by an aggregation service. - * - * @author Franz-Josef Elmer - */ -public class AggregatedDataFileImportNodeModel extends AbstractOpenBisNodeModel -{ - static final String FILE_PATH_FLOW_VARIABLE = "absolute-file-path"; - - private AggregatedDataImportDescription description; - - private ParameterBindings parameterBindings = new ParameterBindings(); - - public AggregatedDataFileImportNodeModel() - { - super(new PortType[] {}, new PortType[] { new PortType(URIPortObject.class) }); - } - - @Override - protected void loadAdditionalValidatedSettingsFrom(NodeSettingsRO settings) - throws InvalidSettingsException - { - description = Util.deserializeDescription( - settings.getByteArray(AggregatedDataImportDescription.AGGREGATION_DESCRIPTION_KEY)); - parameterBindings.loadValidatedSettingsFrom(settings); - } - - @Override - protected void saveAdditionalSettingsTo(NodeSettingsWO settings) - { - settings.addByteArray(AggregatedDataImportDescription.AGGREGATION_DESCRIPTION_KEY, - Util.serializeDescription(description)); - parameterBindings.saveSettingsTo(settings); - } - - @Override - protected PortObjectSpec[] configure(PortObjectSpec[] inSpecs) throws InvalidSettingsException - { - return new PortObjectSpec[] { new URIPortObjectSpec(createType("")) }; - } - - @Override - protected PortObject[] execute(PortObject[] inObjects, ExecutionContext exec) throws Exception - { - IQueryApiFacade facade = createQueryFacade(); - try - { - QueryTableModel report = - Util.createReportFromAggregationService(facade, parameterBindings, description); - String fileName = (String) report.getRows().get(0)[0]; - String downloadUrl = getDataStore(facade).getDownloadUrl(); - File systemTempDir = getSystemTempDir(); - File file = download(facade.getSessionToken(), systemTempDir, fileName, downloadUrl); - addFlowVariable(FILE_PATH_FLOW_VARIABLE, file.getAbsolutePath()); - String type = createType(fileName); - logger.info("Content MIME type: " + type); - return new PortObject[] - { new URIPortObject(new URIPortObjectSpec(type), Arrays.asList(new URIContent(file - .toURI(), type))) }; - } finally - { - facade.logout(); - } - } - - protected File getSystemTempDir() - { - return new File(System.getProperty("java.io.tmpdir")); - } - - private File download(String sessionToken, File systemTempDir, String fileName, String baseURL) - { - File tempDir = new File(systemTempDir, "knime-openbis-" + sessionToken); - tempDir.mkdirs(); - tempDir.deleteOnExit(); - File file = new File(tempDir, fileName); - file.deleteOnExit(); - InputStream in = null; - OutputStream out = null; - try - { - in = new URL(baseURL + "/session_workspace_file_download?sessionID=" + sessionToken - + "&filePath=" + URLEncoder.encode(fileName, "UTF-8")).openStream(); - file.getParentFile().mkdirs(); - out = new FileOutputStream(file); - byte[] buffer = new byte[1024]; - int size = 0; - while ((size = in.read(buffer)) != -1) - { - out.write(buffer, 0, size); - } - return file; - } catch (Exception ex) - { - throw CheckedExceptionTunnel.wrapIfNecessary(ex); - } finally - { - IOUtils.closeQuietly(in); - IOUtils.closeQuietly(out); - } - } - - private DataStore getDataStore(IQueryApiFacade facade) - { - String dataStoreCode = description.getAggregationServiceDescription().getDataStoreCode(); - String sessionToken = facade.getSessionToken(); - IGeneralInformationService service = facade.getGeneralInformationService(); - List<DataStore> dataStores = service.listDataStores(sessionToken); - for (DataStore dataStore : dataStores) - { - if (dataStore.getCode().equals(dataStoreCode)) - { - return dataStore; - } - } - throw new IllegalArgumentException("Unknown data store: " + dataStoreCode); - } - - private String createType(String fileName) - { - return MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(fileName); - } -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeFactory.xml b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeFactory.xml deleted file mode 100644 index 04a998a96824997f649663b5c8a840015fe72892..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeFactory.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE knimeNode PUBLIC "-//UNIKN//DTD KNIME Node 2.0//EN" "http://www.knime.org/Node.dtd"> -<knimeNode icon="../common/openbis.png" type="Source"> - <name>openBIS Data Set File Importer</name> - - <shortDescription>Imports a file from a selected data set of an openBIS instance.</shortDescription> - - <fullDescription> - <intro>A selected file of a data set is imported and stored locally. - An URI pointing to this file is provided so that other nodes can access its content. - <p> - For more details see <a href="https://wiki-bsse.ethz.ch/display/openBISDoc1304/openBIS+KNIME+Nodes">openBIS KNIME Nodes</a>. - </p> - </intro> - </fullDescription> - - <ports> - <outPort index="0" name="Result Set">URI of the imported file.</outPort> - </ports> -</knimeNode> diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeModel.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeModel.java deleted file mode 100644 index c0eda096976816be2328c39e91caecce035fced9..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeModel.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2011 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Arrays; - -import javax.activation.MimetypesFileTypeMap; - -import org.knime.core.data.uri.URIContent; -import org.knime.core.data.uri.URIPortObject; -import org.knime.core.data.uri.URIPortObjectSpec; -import org.knime.core.node.ExecutionContext; -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; -import org.knime.core.node.port.PortObject; -import org.knime.core.node.port.PortObjectSpec; -import org.knime.core.node.port.PortType; - -import ch.systemsx.cisd.openbis.dss.client.api.v1.DataSet; -import ch.systemsx.cisd.openbis.dss.client.api.v1.IOpenbisServiceFacade; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwnerType; -import ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeModel; -import ch.systemsx.cisd.openbis.knime.common.IOpenbisServiceFacadeFactory; -import ch.systemsx.cisd.openbis.knime.common.Util; - -/** - * Node model for importing a file/folder from Data Store Server. - * - * @author Franz-Josef Elmer - */ -public class DataSetFileImportNodeModel extends AbstractOpenBisNodeModel -{ - static final String DATA_SET_CODE_KEY = "data-set-code"; - - static final String FILE_PATH_KEY = "file-path"; - - static final String DOWNLOADS_PATH_KEY = "downloads-path"; - - static final String ABSOLUTE_FILE_PATH_KEY = "absolute-file-path"; - - static final String REUSE_FILE = "reuse-file"; - - private final IOpenbisServiceFacadeFactory serviceFacadeFactory; - - private String dataSetCode = ""; - - private String filePath = ""; - - private String dowloadsPath = ""; - - private boolean reuseFile; - - public DataSetFileImportNodeModel(IOpenbisServiceFacadeFactory serviceFacadeFactory) - { - super(new PortType[] {}, new PortType[] - { new PortType(URIPortObject.class) }); - this.serviceFacadeFactory = serviceFacadeFactory; - } - - @Override - protected void loadAdditionalValidatedSettingsFrom(NodeSettingsRO settings) - throws InvalidSettingsException - { - dataSetCode = settings.getString(DATA_SET_CODE_KEY); - filePath = settings.getString(FILE_PATH_KEY); - dowloadsPath = settings.getString(DOWNLOADS_PATH_KEY); - reuseFile = settings.getBoolean(REUSE_FILE, false); - } - - @Override - protected void saveAdditionalSettingsTo(NodeSettingsWO settings) - { - settings.addString(DATA_SET_CODE_KEY, dataSetCode); - settings.addString(FILE_PATH_KEY, filePath); - settings.addString(DOWNLOADS_PATH_KEY, dowloadsPath); - settings.addString(ABSOLUTE_FILE_PATH_KEY, dowloadsPath + "/" + dataSetCode + "/" + filePath); - settings.addBoolean(REUSE_FILE, reuseFile); - } - - @Override - protected PortObjectSpec[] configure(PortObjectSpec[] inSpecs) throws InvalidSettingsException - { - String type = createType(); - return new PortObjectSpec[] - { new URIPortObjectSpec(type) }; - } - - @Override - protected PortObject[] execute(PortObject[] inObjects, ExecutionContext exec) throws Exception - { - File file = new File(dowloadsPath, dataSetCode + "/" + filePath); - if (reuseFile == false || file.exists() == false) - { - downloadTo(file); - } - String type = createType(); - logger.info("Content MIME type: " + type); - return new PortObject[] - { new URIPortObject(new URIPortObjectSpec(type), Arrays.asList(new URIContent(file.toURI(), type))) }; - } - - private void downloadTo(File file) throws Exception - { - InputStream in = null; - OutputStream out = null; - IOpenbisServiceFacade facade = null; - try - { - facade = serviceFacadeFactory.createFacade(url, userID, password); - DataSet dataSet = facade.getDataSet(dataSetCode); - if (dataSet == null) - { - throw new IllegalArgumentException("Unknown data set '" + dataSetCode + "'."); - } - pushDataSetMetaDataToVariables(dataSet); - in = dataSet.getFile(filePath); - file.getParentFile().mkdirs(); - out = new FileOutputStream(file); - byte[] buffer = new byte[1024]; - int size = 0; - while ((size = in.read(buffer)) != -1) - { - out.write(buffer, 0, size); - } - } finally - { - if (out != null) - { - out.close(); - } - if (in != null) - { - in.close(); - } - if (facade != null) - { - facade.logout(); - } - } - } - - private void pushDataSetMetaDataToVariables(DataSet dataSet) - { - addFlowVariable(Util.VARIABLE_PREFIX + DataSetOwnerType.DATA_SET.name(), - dataSet.getCode()); - addFlowVariable(Util.VARIABLE_PREFIX + DataSetOwnerType.EXPERIMENT.name(), - dataSet.getExperimentIdentifier()); - String sampleIdentifierOrNull = dataSet.getSampleIdentifierOrNull(); - if (sampleIdentifierOrNull != null) - { - addFlowVariable(Util.VARIABLE_PREFIX + DataSetOwnerType.SAMPLE.name(), - sampleIdentifierOrNull); - } - } - - private String createType() - { - return MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(filePath); - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeFactory.xml b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeFactory.xml deleted file mode 100644 index 6bc5adca2603b278d1b003384d645d5790f8f2d4..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeFactory.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE knimeNode PUBLIC "-//UNIKN//DTD KNIME Node 2.0//EN" "http://www.knime.org/Node.dtd"> -<knimeNode icon="../common/openbis.png" type="Source"> - <name>openBIS Data Set Registration (URI Port)</name> - - <shortDescription>Registers a file as a data set on an openBIS instance.</shortDescription> - - <fullDescription> - <intro>The URI input port specifies the location of the file to be registered. - The owner of the freshly registered data set is specified by a variable. - <p> - For more details see <a href="https://wiki-bsse.ethz.ch/display/openBISDoc1304/openBIS+KNIME+Nodes">openBIS KNIME Nodes</a>. - </p> - </intro> - </fullDescription> - - <ports> - <inPort index="0" name="Result Set">URI of the file to be registered.</inPort> - </ports> -</knimeNode> diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeModel.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeModel.java deleted file mode 100644 index 810122efe2095597098a9d546afbea8481a42219..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeModel.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.NoSuchElementException; -import java.util.Set; - -import org.apache.commons.lang.StringUtils; -import org.knime.core.data.uri.URIContent; -import org.knime.core.data.uri.URIPortObject; -import org.knime.core.node.ExecutionContext; -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeModel; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; -import org.knime.core.node.port.PortObject; -import org.knime.core.node.port.PortObjectSpec; -import org.knime.core.node.port.PortType; -import org.knime.core.node.port.flowvariable.FlowVariablePortObject; -import org.knime.core.node.workflow.FlowVariable; - -import ch.systemsx.cisd.openbis.dss.client.api.v1.DataSet; -import ch.systemsx.cisd.openbis.dss.client.api.v1.IOpenbisServiceFacade; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwnerType; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTOBuilder; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetMetadataDTO; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample; -import ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeModel; -import ch.systemsx.cisd.openbis.knime.common.IOpenbisServiceFacadeFactory; -import ch.systemsx.cisd.openbis.knime.common.Util; - -/** - * {@link NodeModel} for registration of a file as a new data set. The file path is expected as an {@link URIPortObject}. - * - * @author Franz-Josef Elmer - */ -public class DataSetRegistrationNodeModel extends AbstractOpenBisNodeModel -{ - static final String DATA_SET_TYPE_KEY = "data-set-type"; - - static final String OWNER_TYPE_KEY = "owner-type"; - - static final String OWNER_KEY = "owner"; - - static final String FILE_VARIABLE_KEY = "file-variable"; - - static final String PROPERTY_TYPE_CODES_KEY = "property-type-codes"; - - static final String PROPERTY_VALUES_KEY = "property-values"; - - private final IOpenbisServiceFacadeFactory serviceFacadeFactory; - - private DataSetOwnerType ownerType; - - private String owner; - - private String fileVariable; - - private Map<String, String> properties; - - private DataSetType dataSetType; - - public DataSetRegistrationNodeModel(IOpenbisServiceFacadeFactory serviceFacadeFactory) - { - this(URIPortObject.class, serviceFacadeFactory); - } - - protected DataSetRegistrationNodeModel(Class<? extends PortObject> portObjectClass, - IOpenbisServiceFacadeFactory serviceFacadeFactory) - { - super(new PortType[] { new PortType(portObjectClass) }, new PortType[] {}); - this.serviceFacadeFactory = serviceFacadeFactory; - } - - @Override - protected PortObjectSpec[] configure(PortObjectSpec[] inSpecs) throws InvalidSettingsException - { - return new PortObjectSpec[] {}; - } - - @Override - protected void loadAdditionalValidatedSettingsFrom(NodeSettingsRO settings) - throws InvalidSettingsException - { - byte[] bytes = settings.getByteArray(DATA_SET_TYPE_KEY, null); - dataSetType = (DataSetType) Util.deserializeDescription(bytes); - ownerType = DataSetOwnerType.valueOf(settings.getString(OWNER_TYPE_KEY)); - owner = settings.getString(OWNER_KEY); - fileVariable = settings.getString(FILE_VARIABLE_KEY, null); - properties = getProperties(settings); - } - - static Map<String, String> getProperties(NodeSettingsRO settings) - throws InvalidSettingsException - { - String[] propertyTypeCodes = settings.getStringArray(PROPERTY_TYPE_CODES_KEY, new String[0]); - String[] propertyValues = settings.getStringArray(PROPERTY_VALUES_KEY, new String[0]); - if (propertyTypeCodes.length != propertyValues.length) - { - throw new InvalidSettingsException("Corrupted properties: " + propertyTypeCodes.length - + " property type codes but " + propertyValues.length + " values."); - } - Map<String, String> props = new HashMap<String, String>(); - for (int i = 0; i < propertyTypeCodes.length; i++) - { - String propertyValue = propertyValues[i]; - if (StringUtils.isNotBlank(propertyValue)) - { - props.put(propertyTypeCodes[i], propertyValue); - } - } - return props; - } - - @Override - protected void saveAdditionalSettingsTo(NodeSettingsWO settings) - { - if (fileVariable != null) - { - settings.addString(FILE_VARIABLE_KEY, fileVariable); - } - if (dataSetType != null) - { - settings.addByteArray(DATA_SET_TYPE_KEY, Util.serializeDescription(dataSetType)); - } - settings.addString(OWNER_TYPE_KEY, (ownerType == null ? DataSetOwnerType.EXPERIMENT - : ownerType).name()); - settings.addString(OWNER_KEY, owner); - if (properties != null) - { - List<String> propertyTypeCodes = new ArrayList<String>(properties.size()); - List<String> propertyValues = new ArrayList<String>(properties.size()); - Set<Entry<String, String>> entrySet = properties.entrySet(); - for (Entry<String, String> entry : entrySet) - { - String value = entry.getValue(); - if (StringUtils.isNotBlank(value)) - { - propertyTypeCodes.add(entry.getKey()); - propertyValues.add(value); - } - } - settings.addStringArray(PROPERTY_TYPE_CODES_KEY, propertyTypeCodes.toArray(new String[0])); - settings.addStringArray(PROPERTY_VALUES_KEY, propertyValues.toArray(new String[0])); - } - } - - @Override - protected PortObject[] execute(PortObject[] inObjects, ExecutionContext exec) throws Exception - { - File file = getFirstFile(inObjects); - logger.info("data set file: " + file); - NewDataSetDTOBuilder builder = new NewDataSetDTOBuilder(); - builder.setDataSetOwnerType(ownerType); - if (owner != null && owner.trim().length() > 0) - { - builder.setDataSetOwnerIdentifier(owner.trim()); - } else - { - String variableName = Util.VARIABLE_PREFIX + ownerType.name(); - try - { - builder.setDataSetOwnerIdentifier(getStringFlowVariable(variableName)); - } catch (NoSuchElementException ex) - { - throw new IllegalArgumentException("Owner " + ownerType.toString().toLowerCase() - + " hasn't been specified. Also flow variable '" - + variableName + "' is undefined."); - } - } - builder.setFile(file); - NewDataSetMetadataDTO dataSetMetadata = builder.getDataSetMetadata(); - dataSetMetadata.setDataSetTypeOrNull(dataSetType.getCode()); - dataSetMetadata.setProperties(properties); - NewDataSetDTO dataSetDTO = builder.asNewDataSetDTO(); - - IOpenbisServiceFacade facade = null; - try - { - facade = serviceFacadeFactory.createFacade(url, userID, password); - checkOwner(dataSetDTO, facade); - facade.putDataSet(dataSetDTO, file); - return new PortObject[] {}; - } finally - { - if (facade != null) - { - facade.logout(); - } - } - } - - private void checkOwner(NewDataSetDTO dataSetDTO, IOpenbisServiceFacade facade) - { - String identifier = dataSetDTO.getDataSetOwner().getIdentifier(); - DataSetOwnerType type = dataSetDTO.getDataSetOwner().getType(); - try - { - switch (type) - { - case EXPERIMENT: - List<Experiment> experiments = facade.getExperiments(Collections.singletonList(identifier)); - if (experiments.isEmpty()) - { - throw new IllegalArgumentException("Unknown experiment."); - } - break; - case SAMPLE: - List<Sample> samples = facade.getSamples(Collections.singletonList(identifier)); - if (samples.isEmpty()) - { - throw new IllegalArgumentException("Unknown sample."); - } else if (samples.get(0).getExperimentIdentifierOrNull() == null) - { - throw new IllegalArgumentException("Not directly linked to an experiment."); - } - break; - case DATA_SET: - DataSet dataSet = facade.getDataSet(identifier); - if (dataSet == null) - { - throw new IllegalArgumentException("Unknown data set."); - } - } - } catch (Exception ex) - { - throw new IllegalArgumentException("Error for data set owner of type " + type.toString().toLowerCase() + " '" - + identifier + "': " + ex.getMessage(), ex); - } - } - - private File getFirstFile(PortObject[] inObjects) - { - if (inObjects.length != 1) - { - throw new IllegalArgumentException("Expecting exactly one port instead of " + inObjects.length + "."); - } - PortObject portObject = inObjects[0]; - File file; - if (portObject instanceof URIPortObject) - { - List<URIContent> uriContents = ((URIPortObject) portObject).getURIContents(); - if (uriContents.isEmpty()) - { - throw new IllegalArgumentException("Expecting at least on URI in input port."); - } - if (uriContents.size() > 1) - { - logger.warn(uriContents.size() + " URIs instead of only one: " + uriContents); - } - file = new File(uriContents.get(0).getURI()); - } else if (portObject instanceof FlowVariablePortObject) - { - if (StringUtils.isBlank(fileVariable)) - { - throw new IllegalArgumentException("Unspecified file variable."); - } - file = new File(getStringFlowVariable(fileVariable)); - } else - { - throw new IllegalArgumentException("Invalid port: " + portObject.getClass().getName() + "."); - } - if (file.exists() == false) - { - throw new IllegalArgumentException("File does not exist: " + file); - } - return file; - } - - protected Map<String, FlowVariable> getFlowVariables() - { - return getAvailableFlowVariables(); - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationViaFlowNodeFactory.xml b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationViaFlowNodeFactory.xml deleted file mode 100644 index 1f7e38543401be35e184fadce2df9ce01ab1cc80..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationViaFlowNodeFactory.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE knimeNode PUBLIC "-//UNIKN//DTD KNIME Node 2.0//EN" "http://www.knime.org/Node.dtd"> -<knimeNode icon="../common/openbis.png" type="Source"> - <name>openBIS Data Set Registration (Flow Variable Port)</name> - - <shortDescription>Registers a file as a data set on an openBIS instance.</shortDescription> - - <fullDescription> - <intro>A flow variable specifies the location of the file to be registered. - The owner of the freshly registered data set is specified by a variable. - <p> - For more details see <a href="https://wiki-bsse.ethz.ch/display/openBISDoc1304/openBIS+KNIME+Nodes">openBIS KNIME Nodes</a>. - </p> - </intro> - </fullDescription> - - <ports> - <inPort index="0" name="Result Set">Flow variables.</inPort> - </ports> -</knimeNode> diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationViaFlowNodeModel.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationViaFlowNodeModel.java deleted file mode 100644 index 92fe00bc5da38870a6dc997b5b978d26b35ad839..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationViaFlowNodeModel.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import org.knime.core.node.NodeModel; -import org.knime.core.node.port.flowvariable.FlowVariablePortObject; - -import ch.systemsx.cisd.openbis.knime.common.IOpenbisServiceFacadeFactory; - -/** - * {@link NodeModel} for registration of a file as a new data set. The file path is expected as a flow variable. - * - * @author Franz-Josef Elmer - */ -public class DataSetRegistrationViaFlowNodeModel extends DataSetRegistrationNodeModel -{ - - protected DataSetRegistrationViaFlowNodeModel(IOpenbisServiceFacadeFactory serviceFacadeFactory) - { - super(FlowVariablePortObject.class, serviceFacadeFactory); - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/FileChooser.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/FileChooser.java deleted file mode 100644 index 6bc59ae8efc08b7d0f9efbde39d3a2ea6e9cd4ec..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/file/FileChooser.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright 2012 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Window; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTree; -import javax.swing.SwingUtilities; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeNode; -import javax.swing.tree.TreePath; -import javax.swing.tree.TreeSelectionModel; - -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileInfoDssDTO; - -/** - * Chooser for files in a data set. - * - * @author Franz-Josef Elmer - */ -public class FileChooser extends JPanel -{ - private static final class FileNode implements TreeNode - { - private final FileInfoDssDTO fileInfo; - - private final String fileName; - - private final List<FileNode> children; - - private FileNode parent; - - FileNode(FileInfoDssDTO fileInfo) - { - this.fileInfo = fileInfo; - children = fileInfo.isDirectory() ? new ArrayList<FileNode>() : null; - fileName = extractFileName(fileInfo); - } - - @Override - public boolean getAllowsChildren() - { - return fileInfo.isDirectory(); - } - - @Override - public boolean isLeaf() - { - return fileInfo.isDirectory() == false; - } - - @Override - public Enumeration<FileNode> children() - { - return new Enumeration<FileNode>() - { - Iterator<FileNode> iterator = children.iterator(); - - @Override - public boolean hasMoreElements() - { - return iterator.hasNext(); - } - - @Override - public FileNode nextElement() - { - return iterator.next(); - } - }; - } - - @Override - public TreeNode getChildAt(int index) - { - return children.get(index); - } - - @Override - public int getChildCount() - { - return children == null ? 0 : children.size(); - } - - @Override - public int getIndex(TreeNode node) - { - return children.indexOf(node); - } - - @Override - public TreeNode getParent() - { - return parent; - } - - void addChild(FileNode fileNode) - { - if (isLeaf() == false) - { - children.add(fileNode); - fileNode.parent = this; - } - } - - FileInfoDssDTO getFileInfo() - { - return fileInfo; - } - - @Override - public String toString() - { - return fileName; - } - } - - private static final long serialVersionUID = 1L; - - private static String extractParentFileName(FileInfoDssDTO fileInfo) - { - String path = fileInfo.getPathInDataSet(); - int lastIndexOfPathSeparator = path.lastIndexOf('/'); - return lastIndexOfPathSeparator < 0 ? null : path.substring(0, lastIndexOfPathSeparator); - } - - private static String extractFileName(FileInfoDssDTO fileInfo) - { - String path = fileInfo.getPathInDataSet(); - int lastIndexOfPathSeparator = path.lastIndexOf('/'); - return lastIndexOfPathSeparator < 0 ? path : path.substring(lastIndexOfPathSeparator + 1); - } - - private JTree tree; - - FileChooser(String dataSetCode, FileInfoDssDTO[] fileInfos) - { - super(new BorderLayout()); - add(new JLabel("Choose a single file:"), BorderLayout.NORTH); - tree = new JTree(new DefaultTreeModel(createTree(dataSetCode, fileInfos), true)); - tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); - tree.addMouseListener(new MouseAdapter() - { - @Override - public void mousePressed(MouseEvent e) - { - if (e.getClickCount() < 2) - { - return; - } - TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY()); - if (path == null) - { - return; - } - FileInfoDssDTO fileInfo = ((FileNode) path.getLastPathComponent()).getFileInfo(); - if (fileInfo.isDirectory()) - { - return; - } - Window window = SwingUtilities.getWindowAncestor(tree); - if (window == null) - { - return; - } - JOptionPane op = (JOptionPane) SwingUtilities.getAncestorOfClass(JOptionPane.class, tree); - if (op != null) - { - op.setValue(JOptionPane.OK_OPTION); - } - window.setVisible(false); - } - }); - add(new JScrollPane(tree), BorderLayout.CENTER); - setPreferredSize(new Dimension(500, 700)); - } - - private FileNode createTree(String dataSetCode, FileInfoDssDTO[] fileInfos) - { - Arrays.sort(fileInfos, new Comparator<FileInfoDssDTO>() - { - @Override - public int compare(FileInfoDssDTO i1, FileInfoDssDTO i2) - { - return i1.getPathInDataSet().compareTo(i2.getPathInDataSet()); - } - }); - FileNode root = new FileNode(new FileInfoDssDTO(dataSetCode, null, true, -1)); - Map<String, FileNode> directories = new HashMap<String, FileChooser.FileNode>(); - for (FileInfoDssDTO fileInfo : fileInfos) - { - String parentFileName = extractParentFileName(fileInfo); - FileNode fileNode = new FileNode(fileInfo); - (parentFileName == null ? root : directories.get(parentFileName)).addChild(fileNode); - if (fileInfo.isDirectory()) - { - directories.put(fileInfo.getPathInDataSet(), fileNode); - } - } - return root; - } - - FileInfoDssDTO getSelectedFileInfoOrNull() - { - TreePath selectionPath = tree.getSelectionPath(); - return selectionPath == null ? null : ((FileNode) selectionPath.getLastPathComponent()) - .getFileInfo(); - } -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/AggregatedDataTableImportNodeFactory.xml b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/AggregatedDataTableImportNodeFactory.xml deleted file mode 100644 index cfa0dc75186fc50d2b1b7b397dd69b54c4258232..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/AggregatedDataTableImportNodeFactory.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE knimeNode PUBLIC "-//UNIKN//DTD KNIME Node 2.0//EN" "http://www.knime.org/Node.dtd"> -<knimeNode icon="../common/openbis.png" type="Source"> - <name>openBIS Aggregation Service Report Reader</name> - - <shortDescription>Provides the result table form an invocation of a special openBIS aggregation services.</shortDescription> - - <fullDescription> - <intro>This node invokes a special openBIS aggregation services which creates from some input - parameters a table. - <p> - For more details see <a href="https://wiki-bsse.ethz.ch/display/openBISDoc1304/openBIS+KNIME+Nodes">openBIS KNIME Nodes</a>. - </p> - </intro> - </fullDescription> - - <ports> - <outPort index="0" name="Result Set">Table</outPort> - </ports> -</knimeNode> diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/AggregatedDataTableImportNodeModel.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/AggregatedDataTableImportNodeModel.java deleted file mode 100644 index 427f85f95851b2f13976979072e1f719b6d5809d..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/AggregatedDataTableImportNodeModel.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; - -import ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeTableModel; -import ch.systemsx.cisd.openbis.knime.common.AggregatedDataImportDescription; -import ch.systemsx.cisd.openbis.knime.common.ParameterBindings; -import ch.systemsx.cisd.openbis.knime.common.Util; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableModel; - -/** - * @author Franz-Josef Elmer - */ -public class AggregatedDataTableImportNodeModel extends AbstractOpenBisNodeTableModel -{ - private AggregatedDataImportDescription description; - - private ParameterBindings parameterBindings = new ParameterBindings(); - - @Override - protected void loadAdditionalValidatedSettingsFrom(NodeSettingsRO settings) - throws InvalidSettingsException - { - description = Util.deserializeDescription( - settings.getByteArray(AggregatedDataImportDescription.AGGREGATION_DESCRIPTION_KEY)); - parameterBindings.loadValidatedSettingsFrom(settings); - } - - @Override - protected void saveAdditionalSettingsTo(NodeSettingsWO settings) - { - settings.addByteArray(AggregatedDataImportDescription.AGGREGATION_DESCRIPTION_KEY, - Util.serializeDescription(description)); - parameterBindings.saveSettingsTo(settings); - } - - @Override - protected QueryTableModel getData(IQueryApiFacade facade) - { - return Util.createReportFromAggregationService(facade, parameterBindings, description); - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/QueryNodeFactory.xml b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/QueryNodeFactory.xml deleted file mode 100644 index 4d9509b1e364798d1890b4f6bea8159d249ef32a..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/QueryNodeFactory.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE knimeNode PUBLIC "-//UNIKN//DTD KNIME Node 2.0//EN" "http://www.knime.org/Node.dtd"> -<knimeNode icon="../common/openbis.png" type="Source"> - <name>openBIS Query Reader</name> - - <shortDescription>Provides the result table form an invocation of a parameterized SQL Query on an openBIS instance.</shortDescription> - - <fullDescription> - <intro>This data source node invokes a parameterized SQL query on an openBIS Application Server. - <p> - For more details see <a href="https://wiki-bsse.ethz.ch/display/openBISDoc1304/openBIS+KNIME+Nodes">openBIS KNIME Nodes</a>. - </p> - </intro> - </fullDescription> - - <ports> - <outPort index="0" name="Result Set">Table with a result set</outPort> - </ports> -</knimeNode> diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/QueryNodeModel.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/QueryNodeModel.java deleted file mode 100644 index e9c196519c01eac3625ddcf734ca3da8180d8f38..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/QueryNodeModel.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2010 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; - -import ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeTableModel; -import ch.systemsx.cisd.openbis.knime.common.ParameterBindings; -import ch.systemsx.cisd.openbis.knime.common.Util; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryDescription; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableModel; - -/** - * Node model for SQL parameterized queries. - * - * @author Franz-Josef Elmer - */ -public class QueryNodeModel extends AbstractOpenBisNodeTableModel -{ - static final String QUERY_DESCRIPTION_KEY = "query-description"; - - private QueryDescription queryDescription; - - private ParameterBindings parameterBindings = new ParameterBindings(); - - @Override - protected void loadAdditionalValidatedSettingsFrom(NodeSettingsRO settings) - throws InvalidSettingsException - { - queryDescription = - Util.deserializeDescription(settings.getByteArray(QUERY_DESCRIPTION_KEY)); - parameterBindings.loadValidatedSettingsFrom(settings); - } - - @Override - protected void saveAdditionalSettingsTo(NodeSettingsWO settings) - { - settings.addByteArray(QUERY_DESCRIPTION_KEY, Util - .serializeDescription(queryDescription)); - parameterBindings.saveSettingsTo(settings); - } - - @Override - protected QueryTableModel getData(IQueryApiFacade facade) - { - return facade.executeQuery(queryDescription.getId(), parameterBindings.getBindings()); - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/ReportNodeFactory.xml b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/ReportNodeFactory.xml deleted file mode 100644 index 74d9825e908980dcf2d4dc805e43d42d845d3d3f..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/ReportNodeFactory.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE knimeNode PUBLIC "-//UNIKN//DTD KNIME Node 2.0//EN" "http://www.knime.org/Node.dtd"> -<knimeNode icon="../common/openbis.png" type="Source"> - <name>openBIS Report Reader</name> - - <shortDescription>Provides the result table form an invocation of an openBIS reporting plugin.</shortDescription> - - <fullDescription> - <intro>This data source node invokes a reporting plugin on an openBIS Application Server. - <p> - For more details see <a href="https://wiki-bsse.ethz.ch/display/openBISDoc1304/openBIS+KNIME+Nodes">openBIS KNIME Nodes</a>. - </p> - </intro> - </fullDescription> - - <ports> - <outPort index="0" name="Result Set">Table</outPort> - </ports> -</knimeNode> diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/ReportNodeModel.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/ReportNodeModel.java deleted file mode 100644 index 37e12b6772d66801a995c3a85595189388ed18f3..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/query/ReportNodeModel.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2011 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import java.util.Arrays; - -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; - -import ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeTableModel; -import ch.systemsx.cisd.openbis.knime.common.Util; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableModel; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.ReportDescription; - -/** - * Node model for report reader node. - * - * @author Franz-Josef Elmer - */ -public class ReportNodeModel extends AbstractOpenBisNodeTableModel -{ - static final String REPORT_DESCRIPTION_KEY = "report-description"; - - static final String DATA_SET_CODES_KEY = "data-set-codes"; - - private ReportDescription reportDescription; - - private String[] dataSetCodes; - - @Override - protected void loadAdditionalValidatedSettingsFrom(NodeSettingsRO settings) - throws InvalidSettingsException - { - reportDescription = - Util.deserializeDescription(settings.getByteArray(REPORT_DESCRIPTION_KEY)); - dataSetCodes = settings.getStringArray(DATA_SET_CODES_KEY); - } - - @Override - protected void saveAdditionalSettingsTo(NodeSettingsWO settings) - { - settings.addByteArray(REPORT_DESCRIPTION_KEY, Util.serializeDescription(reportDescription)); - settings.addStringArray(DATA_SET_CODES_KEY, dataSetCodes); - } - - @Override - protected QueryTableModel getData(IQueryApiFacade facade) - { - return facade.createReportFromDataSets(reportDescription.getKey(), Arrays.asList(dataSetCodes)); - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/AggregationCommand.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/AggregationCommand.java deleted file mode 100644 index fc4ff4a9714e20d0445332b31504fb8851630e98..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/AggregationCommand.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.server; - -import java.util.Map; - -import org.apache.log4j.Logger; - -import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; -import ch.systemsx.cisd.common.logging.LogCategory; -import ch.systemsx.cisd.common.logging.LogFactory; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.api.ITableModel; -import ch.systemsx.cisd.openbis.generic.shared.managed_property.api.ISimpleTableModelBuilderAdaptor; - -/** - * Super class of all aggregation commands. - * - * @author Franz-Josef Elmer - */ -public class AggregationCommand -{ - private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, - AggregationCommand.class); - - public final void handleRequest(Map<String, Object> parameters, - ISimpleTableModelBuilderAdaptor tableBuilder) - { - try - { - Object requestKey = parameters.get(Constants.REQUEST_KEY); - if (Constants.GET_PARAMETER_DESCRIPTIONS_REQUEST.equals(requestKey)) - { - defineParameters(new ParameterDescriptionsBuilder(tableBuilder)); - } else - { - aggregate(parameters, tableBuilder); - } - } catch (Throwable ex) - { - operationLog.error("", ex); - ITableModel tableModel = tableBuilder.getTableModel(); - if (tableModel instanceof TableModel) - { - // Put complete stack trace into the table if we can clear it - TableModel tm = (TableModel) tableModel; - tm.getHeader().clear(); - tm.getRows().clear(); - tableBuilder.addHeader(Constants.EXCEPTION_COLUMN); - tableBuilder.addHeader(Constants.STACK_TRACE_CLASS_COLUMN); - tableBuilder.addHeader(Constants.STACK_TRACE_METHOD_NAME_COLUMN); - tableBuilder.addHeader(Constants.STACK_TRACE_FILE_NAME_COLUMN); - tableBuilder.addHeader(Constants.STACK_TRACE_LINE_NUMBER_COLUMN); - for (Throwable throwable = ex; throwable != null; throwable = throwable.getCause()) - { - tableBuilder.addFullRow(throwable.toString(), "", "", "", ""); - StackTraceElement[] stackTraceElements = throwable.getStackTrace(); - for (StackTraceElement stackTraceElement : stackTraceElements) - { - tableBuilder.addFullRow("", stackTraceElement.getClassName(), - stackTraceElement.getMethodName(), - stackTraceElement.getFileName(), - Integer.toString(stackTraceElement.getLineNumber())); - } - } - } else - { - throw CheckedExceptionTunnel.wrapIfNecessary(ex); - } - } - } - - /** - * Defines parameters and their type by using specified {@link ParameterDescriptionsBuilder}. Should be overwritten by subclasses. - */ - protected void defineParameters(ParameterDescriptionsBuilder parameters) - { - } - - /** - * Aggregates data in tabular form based on specified parameter values. Should be overwritten by subclasses. - */ - protected void aggregate(Map<String, Object> parameters, - ISimpleTableModelBuilderAdaptor tableBuilder) - { - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/AggregationFileCommand.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/AggregationFileCommand.java deleted file mode 100644 index 03ec47e446b6696054e4ef019e11650a21b9af6b..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/AggregationFileCommand.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.server; - -import java.util.Map; - -import ch.systemsx.cisd.openbis.generic.shared.managed_property.api.ISimpleTableModelBuilderAdaptor; - -/** - * Aggregation command which creates a file in session workspace and returns the file name. - * - * @author Franz-Josef Elmer - */ -public class AggregationFileCommand extends AggregationCommand -{ - - @Override - protected void aggregate(Map<String, Object> parameters, - ISimpleTableModelBuilderAdaptor tableBuilder) - { - String fileName = createFile(parameters); - tableBuilder.addHeader(Constants.FILE_NAME_COLUMN); - tableBuilder.addRow().setCell(Constants.FILE_NAME_COLUMN, fileName); - } - - /** - * Creates a file by aggregating data based on specified parameters. Should be overridden by subclasses. - * - * @return the file name. - */ - protected String createFile(Map<String, Object> parameters) - { - return null; - } -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/Constants.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/Constants.java deleted file mode 100644 index d9b8841d5d6b9e9036d06998d7066ac29eece169..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/Constants.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.server; - -/** - * Basic constants. - * - * @author Franz-Josef Elmer - */ -public class Constants -{ - public static final String REQUEST_KEY = "_REQUEST_"; - - public static final String GET_PARAMETER_DESCRIPTIONS_REQUEST = "getParameterDescriptions"; - - public static final String EXCEPTION_COLUMN = "_EXCEPTION_"; - - public static final String STACK_TRACE_CLASS_COLUMN = "_STACK_TRACE_CLASS_"; - - public static final String STACK_TRACE_METHOD_NAME_COLUMN = "_STACK_TRACE_METHOD_NAME_"; - - public static final String STACK_TRACE_FILE_NAME_COLUMN = "_STACK_TRACE_FILE_NAME_"; - - public static final String STACK_TRACE_LINE_NUMBER_COLUMN = "_STACK_TRACE_LINE_NUMBER_"; - - public static final String PARAMETER_DESCRIPTION_NAME_COLUMN = "name"; - - public static final String PARAMETER_DESCRIPTION_TYPE_COLUMN = "type"; - - public static final String FILE_NAME_COLUMN = "filename"; -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/FieldType.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/FieldType.java deleted file mode 100644 index ad03d7cc2ed9fa783cf218eec91e68c54234c55b..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/FieldType.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.server; - -/** - * Enumeration of parameter field types. - * - * @author Franz-Josef Elmer - */ -public enum FieldType -{ - VARCHAR, VOCABULARY, EXPERIMENT, SAMPLE, DATA_SET; -} \ No newline at end of file diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/ParameterDescriptionBuilder.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/ParameterDescriptionBuilder.java deleted file mode 100644 index 6fe4ef12210eced905bfa64f69e5529b71d3a835..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/ParameterDescriptionBuilder.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.server; - -import ch.systemsx.cisd.openbis.generic.shared.managed_property.api.IRowBuilderAdaptor; - -/** - * @author Franz-Josef Elmer - */ -public class ParameterDescriptionBuilder -{ - private final IRowBuilderAdaptor row; - - ParameterDescriptionBuilder(IRowBuilderAdaptor row) - { - this.row = row; - } - - public void text() - { - row.setCell(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN, FieldType.VARCHAR.toString()); - } - - public void experiment() - { - row.setCell(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN, FieldType.EXPERIMENT.toString()); - } - - public void sample() - { - row.setCell(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN, FieldType.SAMPLE.toString()); - } - - public void dataSet() - { - row.setCell(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN, FieldType.DATA_SET.toString()); - } - - public VocabularyBuilder vocabulary(String... terms) - { - VocabularyBuilder vocabularyBuilder = new VocabularyBuilder(row); - for (String term : terms) - { - vocabularyBuilder.term(term); - } - return vocabularyBuilder; - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/ParameterDescriptionsBuilder.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/ParameterDescriptionsBuilder.java deleted file mode 100644 index ea92c96e814bdd7aa119e415b862dbbb680e694c..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/ParameterDescriptionsBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.server; - -import java.util.HashSet; -import java.util.Set; - -import ch.systemsx.cisd.openbis.generic.shared.managed_property.api.IRowBuilderAdaptor; -import ch.systemsx.cisd.openbis.generic.shared.managed_property.api.ISimpleTableModelBuilderAdaptor; - -/** - * @author Franz-Josef Elmer - */ -public class ParameterDescriptionsBuilder -{ - private final ISimpleTableModelBuilderAdaptor tableBuilder; - - private final Set<String> names = new HashSet<String>(); - - ParameterDescriptionsBuilder(ISimpleTableModelBuilderAdaptor tableBuilder) - { - this.tableBuilder = tableBuilder; - tableBuilder.addHeader(Constants.PARAMETER_DESCRIPTION_NAME_COLUMN); - tableBuilder.addHeader(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN); - } - - public ParameterDescriptionBuilder parameter(String name) - { - if (names.contains(name)) - { - throw new IllegalArgumentException("There is already a parameter with name '" + name + "'."); - } - names.add(name); - IRowBuilderAdaptor row = tableBuilder.addRow(); - row.setCell(Constants.PARAMETER_DESCRIPTION_NAME_COLUMN, name); - return new ParameterDescriptionBuilder(row); - } - -} diff --git a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/VocabularyBuilder.java b/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/VocabularyBuilder.java deleted file mode 100644 index 228881ee18ad0c9f3aa1f50d067a723cbdba2af2..0000000000000000000000000000000000000000 --- a/openbis_knime/source/java/ch/systemsx/cisd/openbis/knime/server/VocabularyBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.server; - -import java.util.HashSet; -import java.util.Set; - -import ch.systemsx.cisd.openbis.generic.shared.managed_property.api.IRowBuilderAdaptor; - -/** - * @author Franz-Josef Elmer - */ -public class VocabularyBuilder -{ - private final IRowBuilderAdaptor row; - - private final Set<String> terms = new HashSet<String>(); - - private final StringBuilder termsBuilder = new StringBuilder(); - - VocabularyBuilder(IRowBuilderAdaptor row) - { - this.row = row; - row.setCell(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN, FieldType.VOCABULARY.toString()); - } - - public VocabularyBuilder term(String term) - { - if (terms.contains(term)) - { - throw new IllegalArgumentException("There is already a term '" + term + "' defined."); - } - if (termsBuilder.length() > 0) - { - termsBuilder.append(", "); - } - termsBuilder.append(term); - row.setCell(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN, - FieldType.VOCABULARY + ":" + termsBuilder); - return this; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractAggregatedDataImportNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractAggregatedDataImportNodeDialog.java deleted file mode 100644 index cf8781ced3b6345273d8c5b5a1e6d9cf23ac6278..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractAggregatedDataImportNodeDialog.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.AggregationServiceDescription; - -/** - * Abstract super class of nodes dialogs for importing data from an aggregation service. - * - * @author Franz-Josef Elmer - */ -public abstract class AbstractAggregatedDataImportNodeDialog - extends AbstractParameterDescriptionBasedNodeDialog<AggregatedDataImportDescription> -{ - protected AbstractAggregatedDataImportNodeDialog(String tabTitle) - { - super(tabTitle); - } - - @Override - protected List<FieldDescription> getFieldDescriptions( - AggregatedDataImportDescription description) - { - return Util.getFieldDescriptions(createFacade(), description, logger); - } - - @Override - protected List<AggregatedDataImportDescription> getSortedDescriptions(IQueryApiFacade facade) - { - List<AggregationServiceDescription> services = facade.listAggregationServices(); - Collections.sort(services, new Comparator<AggregationServiceDescription>() - { - @Override - public int compare(AggregationServiceDescription d1, - AggregationServiceDescription d2) - { - return d1.getServiceKey().compareTo(d2.getServiceKey()); - } - }); - List<AggregatedDataImportDescription> descriptions = - new ArrayList<AggregatedDataImportDescription>(); - Set<String> dssCodes = new HashSet<String>(); - - for (AggregationServiceDescription aggregationServiceDescription : services) - { - addDescription(descriptions, aggregationServiceDescription); - dssCodes.add(aggregationServiceDescription.getDataStoreCode()); - } - - if (dssCodes.size() > 1) - { - for (AggregatedDataImportDescription description : descriptions) - { - description.setShowFullDescription(true); - } - } - - return descriptions; - } - - protected abstract void addDescription(List<AggregatedDataImportDescription> descriptions, - AggregationServiceDescription aggregationServiceDescription); - - @Override - protected String getDescriptionKey() - { - return AggregatedDataImportDescription.AGGREGATION_DESCRIPTION_KEY; - } - - @Override - protected String getParametersSectionLabel() - { - return "Service Parameters"; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractDescriptionBasedNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractDescriptionBasedNodeDialog.java deleted file mode 100644 index 18d4ad796919f3006e7870663140291648295fa7..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractDescriptionBasedNodeDialog.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2011 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.io.Serializable; -import java.util.List; - -import javax.swing.JComboBox; -import javax.swing.JOptionPane; -import javax.swing.JPanel; - -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; -import org.knime.core.node.NotConfigurableException; -import org.knime.core.node.port.PortObjectSpec; - -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; - -/** - * @author Franz-Josef Elmer - */ -public abstract class AbstractDescriptionBasedNodeDialog<D extends Serializable> extends AbstractOpenBisNodeDialog -{ - private JComboBox descriptionComboBox; - - private FocusAdapter focusListener; - - protected AbstractDescriptionBasedNodeDialog(String tabTitle) - { - super(tabTitle); - } - - @Override - protected void defineQueryForm(JPanel queryPanel) - { - descriptionComboBox = new JComboBox(); - focusListener = new FocusAdapter() - { - @Override - public void focusGained(FocusEvent e) - { - JOptionPane.showMessageDialog(descriptionComboBox, - "Please, reconnect to openBIS to get all available " + getDescriptionKey() + "."); - descriptionComboBox.removeFocusListener(focusListener); - } - }; - descriptionComboBox.addFocusListener(focusListener); - defineQueryForm(queryPanel, descriptionComboBox); - } - - @Override - protected void updateQueryForm(IQueryApiFacade queryFacade) - { - List<D> descriptions = getSortedDescriptions(queryFacade); - D selectedQueryDescription = getSelectedDescriptionOrNull(); - descriptionComboBox.removeFocusListener(focusListener); - descriptionComboBox.removeAllItems(); - for (D description : descriptions) - { - descriptionComboBox.addItem(description); - if (description.equals(selectedQueryDescription)) - { - descriptionComboBox.setSelectedItem(description); - } - } - } - - @SuppressWarnings("unchecked") - protected D getSelectedDescriptionOrNull() - { - Object selectedItem = descriptionComboBox.getSelectedItem(); - return selectedItem == null ? null : (D) selectedItem; - } - - @Override - protected final void loadAdditionalSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs) - throws NotConfigurableException - { - byte[] bytes = settings.getByteArray(getDescriptionKey(), null); - D descriptionOrNull = Util.deserializeDescription(bytes); - if (descriptionOrNull != null && descriptionComboBox.getItemCount() == 0) - { - descriptionComboBox.addItem(descriptionOrNull); - descriptionComboBox.setSelectedIndex(0); - } - loadMoreSettingsFrom(settings, specs); - } - - @Override - protected final void saveAdditionalSettingsTo(NodeSettingsWO settings) - throws InvalidSettingsException - { - byte[] bytes = Util.serializeDescription(getSelectedDescriptionOrNull()); - settings.addByteArray(getDescriptionKey(), bytes); - saveMoreSettingsTo(settings); - } - - protected abstract void defineQueryForm(JPanel queryPanel, JComboBox comboBoxWithDescriptions); - - protected abstract List<D> getSortedDescriptions(IQueryApiFacade facade); - - protected abstract String getDescriptionKey(); - - protected abstract void loadMoreSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs) - throws NotConfigurableException; - - protected abstract void saveMoreSettingsTo(NodeSettingsWO settings) - throws InvalidSettingsException; -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractOpenBisNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractOpenBisNodeDialog.java deleted file mode 100644 index 1d2709e6d9e9009ff08acafe0179818ed0fd9959..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractOpenBisNodeDialog.java +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Copyright 2011 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import static ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeModel.CREDENTIALS_KEY; -import static ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeModel.PASSWORD_KEY; -import static ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeModel.URL_KEY; -import static ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeModel.USER_KEY; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Container; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.EventQueue; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.Window; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPasswordField; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.SwingUtilities; - -import org.apache.commons.lang.StringUtils; -import org.eclipse.jface.preference.IPreferenceStore; -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeLogger; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; -import org.knime.core.node.NotConfigurableException; -import org.knime.core.node.port.PortObjectSpec; -import org.knime.core.node.workflow.Credentials; -import org.knime.core.node.workflow.ICredentials; -import org.knime.workbench.core.KNIMECorePlugin; - -import ch.systemsx.cisd.openbis.dss.client.api.v1.IOpenbisServiceFacade; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.FacadeFactory; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; - -/** - * Abstract super class of all openBIS KNIME nodes. - * - * @author Franz-Josef Elmer - */ -public abstract class AbstractOpenBisNodeDialog extends NodeDialogPane implements IOpenBisNode -{ - private static final class Key - { - private final String url; - - private final String userID; - - private final String password; - - Key(String url, String userID, String password) - { - this.url = url; - this.userID = userID; - this.password = password; - } - - @Override - public boolean equals(Object obj) - { - if (obj == this) - { - return true; - } - if (obj instanceof Key == false) - { - return false; - } - Key key = (Key) obj; - return String.valueOf(key.url).equals(String.valueOf(url)) - && String.valueOf(key.userID).equals(String.valueOf(userID)) - && String.valueOf(key.password).equals(String.valueOf(password)); - } - - @Override - public int hashCode() - { - int result = String.valueOf(url).hashCode(); - result = 37 * result + String.valueOf(userID).hashCode(); - result = 37 * result + String.valueOf(password).hashCode(); - return result; - } - } - - private Map<Key, IQueryApiFacade> facades = new HashMap<Key, IQueryApiFacade>(); - - protected NodeLogger logger; - - private JComboBox urlField; - - private JComboBox credentialsField; - - private JTextField userField; - - private JPasswordField passwordField; - - private final IOpenbisServiceFacadeFactory serviceFacadeFactory; - - protected AbstractOpenBisNodeDialog(String tabTitle) - { - this(tabTitle, new OpenbisServiceFacadeFactory()); - } - - protected AbstractOpenBisNodeDialog(String tabTitle, IOpenbisServiceFacadeFactory serviceFacadeFactory) - { - this.serviceFacadeFactory = serviceFacadeFactory; - logger = NodeLogger.getLogger(getClass()); - addTab(tabTitle, createTab()); - } - - private Component createTab() - { - JPanel panel = new JPanel(new BorderLayout()); - JPanel connectionPanel = new JPanel(new GridBagLayout()); - connectionPanel.setBorder(BorderFactory.createTitledBorder("Connection Parameters")); - urlField = addField(connectionPanel, "openBIS URL", new JComboBox()); - urlField.setToolTipText("Additional URLs can be defined on the KNIME openBIS preference page."); - credentialsField = addField(connectionPanel, "Credentials", new JComboBox()); - credentialsField.addItemListener(new ItemListener() - { - @Override - public void itemStateChanged(ItemEvent event) - { - boolean enable = "".equals(event.getItem()); - enableField(userField, enable); - enableField(passwordField, enable); - } - }); - credentialsField.setToolTipText("<html>Additional credentials can be defined by the menu item 'Workflow Credentials...'<br>" - + "of the context menu of workflow in the KNIME Explorer.<br><br>" - + "For security reasons it is not recommended to use the fields 'User' and 'Password'<br>" - + "because the password is only encrypted if the KNIME Master Key has been defined."); - userField = addField(connectionPanel, "User", new JTextField(20)); - passwordField = addField(connectionPanel, "Password", new JPasswordField(20)); - JButton button = new JButton("connect"); - button.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - connectServer(); - } - }); - connectionPanel.add(button, createLast()); - panel.add(connectionPanel, BorderLayout.NORTH); - JPanel queryPanel = new JPanel(new BorderLayout()); - defineQueryForm(queryPanel); - panel.add(queryPanel, BorderLayout.CENTER); - - JScrollPane scrollPane = new JScrollPane(panel); - scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); - scrollPane.setPreferredSize(new Dimension(600, 450)); - - return scrollPane; - } - - @Override - public void logError(Throwable throwable) - { - logger.error(throwable.toString(), throwable); - } - - @Override - protected final void loadSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs) - throws NotConfigurableException - { - String[] urls = getUrls(); - urlField.removeAllItems(); - for (String url : urls) - { - urlField.addItem(url); - } - urlField.setSelectedItem(settings.getString(URL_KEY, "")); - credentialsField.removeAllItems(); - credentialsField.addItem(""); - Collection<String> credentialsNames = getAllCredentialsNames(); - for (String credentialsName : credentialsNames) - { - credentialsField.addItem(credentialsName); - } - String credential = settings.getString(CREDENTIALS_KEY, ""); - credentialsField.setSelectedItem(credential); - userField.setText(settings.getString(USER_KEY, "")); - passwordField.setText(Util.getDecryptedPassword(settings)); - loadAdditionalSettingsFrom(settings, specs); - } - - protected Collection<String> getAllCredentialsNames() - { - return getCredentialsNames(); - } - - protected String[] getUrls() - { - IPreferenceStore preferenceStore = KNIMECorePlugin.getDefault().getPreferenceStore(); - return preferenceStore.getString(OpenBisPreferencePage.OPENBIS_URLS_KEY).split("\n"); - } - - @Override - protected final void saveSettingsTo(NodeSettingsWO settings) throws InvalidSettingsException - { - settings.addString(URL_KEY, getUrl()); - Object selectedCredentials = credentialsField.getSelectedItem(); - String credentialsName = selectedCredentials == null ? "" : selectedCredentials.toString(); - settings.addString(CREDENTIALS_KEY, credentialsName); - if (StringUtils.isBlank(credentialsName)) - { - settings.addString(USER_KEY, userField.getText().trim()); - settings.addString(PASSWORD_KEY, Util.getEncryptedPassword(passwordField.getPassword())); - } - saveAdditionalSettingsTo(settings); - } - - protected void showException(Throwable throwable) - { - logger.error(throwable.toString(), throwable); - final String message = createMessage(throwable); - final JPanel panel = getPanel(); - Window windowAncestor = SwingUtilities.getWindowAncestor(panel); - if (windowAncestor != null && windowAncestor.isVisible()) - { - EventQueue.invokeLater(new Runnable() - { - @Override - public void run() - { - JOptionPane.showMessageDialog(panel, message, "Error", JOptionPane.ERROR_MESSAGE); - } - }); - } - } - - private String createMessage(Throwable throwable) - { - String message = throwable.toString(); - String[] lines = message.split("\n"); - int maxNumberOfLines = 10; - if (lines.length < maxNumberOfLines) - { - return message; - } - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < maxNumberOfLines; i++) - { - builder.append(lines[i]).append('\n'); - } - builder.append("...\n\nSee KNIME log for the complete error message."); - return builder.toString(); - } - - protected abstract void defineQueryForm(JPanel queryPanel); - - protected abstract void updateQueryForm(IQueryApiFacade queryFacade); - - protected abstract void loadAdditionalSettingsFrom(NodeSettingsRO settings, - PortObjectSpec[] specs) throws NotConfigurableException; - - protected abstract void saveAdditionalSettingsTo(NodeSettingsWO settings) - throws InvalidSettingsException; - - private void connectServer() - { - performAction(new IQueryFacadeAction() - { - @Override - public void execute(IQueryApiFacade queryFacade) - { - updateQueryForm(queryFacade); - } - }); - } - - @Override - public void onCancel() - { - logoutAndRemoveAllFacades(); - } - - @Override - public void onClose() - { - logoutAndRemoveAllFacades(); - } - - private void logoutAndRemoveAllFacades() - { - for (IQueryApiFacade facade : facades.values()) - { - facade.logout(); - } - facades.clear(); - } - - protected void performAction(final IQueryFacadeAction action) - { - performAction(new ILoadingBuildingAction<IQueryApiFacade>() - { - @Override - public IQueryApiFacade load() - { - return createFacade(); - } - - @Override - public void build(IQueryApiFacade facade) - { - action.execute(facade); - } - }); - } - - protected <T> void performAction(ILoadingBuildingAction<T> loadingBuildingAction) - { - new ActionExecutor().executeAsync(loadingBuildingAction, - new DefaultAsyncNodeAction(AbstractOpenBisNodeDialog.this)); - } - - protected IQueryApiFacade createFacade() - { - try - { - String url = getUrl(); - ICredentials credentials = getCredentials(); - String userID = credentials.getLogin(); - String password = credentials.getPassword(); - Key key = new Key(url, userID, password); - IQueryApiFacade facade = facades.get(key); - if (facade == null) - { - JPanel panel = getPanel(); - Cursor cursor = panel.getCursor(); - try - { - panel.setCursor(new Cursor(Cursor.WAIT_CURSOR)); - facade = FacadeFactory.create(url, userID, password); - } finally - { - panel.setCursor(cursor); - } - facades.put(key, facade); - } - return facade; - } catch (RuntimeException ex) - { - showException(ex); - throw ex; - } - } - - protected IOpenbisServiceFacade createOpenbisFacade(String sessionToken) - { - try - { - return serviceFacadeFactory.createFacade(getUrl(), sessionToken); - } catch (RuntimeException ex) - { - showException(ex); - throw ex; - } - } - - protected String getUrl() - { - Object selectedItem = urlField.getSelectedItem(); - if (selectedItem == null) - { - throw new IllegalArgumentException("Missing URL."); - } - return selectedItem.toString(); - } - - protected ICredentials getCredentials() - { - Object selectedItem = credentialsField.getSelectedItem(); - if (selectedItem == null || selectedItem.toString().trim().length() == 0) - { - String user = userField.getText(); - if (StringUtils.isBlank(user)) - { - throw new IllegalArgumentException("Unspecified credentials or missing user."); - } - char[] password = passwordField.getPassword(); - if (password == null || password.length == 0) - { - throw new IllegalArgumentException("Unspecified credentials or missing password."); - } - return new Credentials("_", user, new String(password)); - } - return getCredentialsProvider().get(selectedItem.toString()); - } - - protected <T extends JComponent> T addField(Container panel, String label, T field) - { - return addField(panel, label, field, false); - } - - protected <T extends JComponent> T addField(Container panel, String label, T field, - boolean mandatory) - { - panel.add(new JLabel(label + (mandatory ? ":*" : ":")), createFirst()); - panel.add(field, createLast()); - return field; - } - - protected GridBagConstraints createLast() - { - GridBagConstraints last = createFirst(); - last.gridwidth = GridBagConstraints.REMAINDER; - return last; - } - - protected GridBagConstraints createFirst() - { - GridBagConstraints constraints = new GridBagConstraints(); - constraints.anchor = GridBagConstraints.WEST; - constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.insets = new Insets(2, 3, 2, 3); - return constraints; - } - - protected void enableField(JComponent field, boolean enable) - { - field.setEnabled(enable); - Component[] components = field.getParent().getComponents(); - for (int i = 1; i < components.length; i++) - { - if (components[i] == field) - { - components[i - 1].setEnabled(enable); - break; - } - } - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractParameterDescriptionBasedNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractParameterDescriptionBasedNodeDialog.java deleted file mode 100644 index ead153b9c7285daf05775b9bcb2d0ea9b2b6b429..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractParameterDescriptionBasedNodeDialog.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.GridBagLayout; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import javax.swing.BorderFactory; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; - -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; -import org.knime.core.node.NotConfigurableException; -import org.knime.core.node.port.PortObjectSpec; - -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwnerType; -import ch.systemsx.cisd.openbis.knime.server.FieldType; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; - -/** - * Abstract super class of node dialogs with a description and a set of parameters different for each description. - * - * @author Franz-Josef Elmer - */ -public abstract class AbstractParameterDescriptionBasedNodeDialog<D extends Serializable> - extends AbstractDescriptionBasedNodeDialog<D> -{ - private ParameterBindings parameterBindings = new ParameterBindings(); - - private Map<String, IField> parameterFields = new HashMap<String, IField>(); - - private JPanel parametersPanel; - - protected AbstractParameterDescriptionBasedNodeDialog(String tabTitle) - { - super(tabTitle); - } - - protected abstract List<FieldDescription> getFieldDescriptions(D description); - - protected abstract String getDescriptionComboBoxLabel(); - - protected String getParametersSectionLabel() - { - return getDescriptionComboBoxLabel() + " Parameters"; - } - - @Override - protected void defineQueryForm(JPanel queryPanel, JComboBox comboBoxWithDescriptions) - { - comboBoxWithDescriptions.addItemListener(new ItemListener() - { - @SuppressWarnings("unchecked") - @Override - public void itemStateChanged(ItemEvent e) - { - if (e.getStateChange() == ItemEvent.SELECTED) - { - try - { - updateParametersPanel((D) e.getItem()); - } catch (Throwable ex) - { - showException(ex); - } - } - } - }); - JPanel querySelectionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - querySelectionPanel.add(new JLabel(getDescriptionComboBoxLabel() + ":")); - querySelectionPanel.add(comboBoxWithDescriptions); - queryPanel.add(querySelectionPanel, BorderLayout.NORTH); - parametersPanel = new JPanel(new GridBagLayout()); - JPanel northPanel = new JPanel(new BorderLayout()); - JPanel northWestPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - northWestPanel.setBorder(BorderFactory.createTitledBorder(getParametersSectionLabel())); - northWestPanel.add(parametersPanel); - northPanel.add(northWestPanel, BorderLayout.NORTH); - queryPanel.add(northPanel, BorderLayout.CENTER); - } - - private void updateParametersPanel(final D description) - { - new ActionExecutor().executeAsync(new ILoadingBuildingAction<List<FieldDescription>>() - { - @Override - public List<FieldDescription> load() - { - return getFieldDescriptions(description); - } - - @Override - public void build(List<FieldDescription> fieldDescriptions) - { - parametersPanel.removeAll(); - parameterFields.clear(); - parametersPanel.getParent().setVisible(fieldDescriptions.isEmpty() == false); - for (FieldDescription fieldDescription : fieldDescriptions) - { - String name = fieldDescription.getName(); - IField field = parameterFields.get(name); - if (field == null) - { - String fieldParameters = fieldDescription.getFieldParameters(); - FieldType fieldType = fieldDescription.getFieldType(); - field = createField(fieldType, fieldParameters); - parameterFields.put(name, field); - } - String value = parameterBindings.tryToGetBinding(name); - if (value != null) - { - field.setValue(value); - } - addField(parametersPanel, name, field.getComponent()); - } - parametersPanel.invalidate(); - parametersPanel.getParent().getParent().validate(); - } - }, new DefaultAsyncNodeAction(this)); - } - - private IField createField(FieldType fieldType, String fieldParameters) - { - IQueryApiFacadeProvider facadeProvider = new IQueryApiFacadeProvider() - { - @Override - public IQueryApiFacade getQueryFacade() - { - return createFacade(); - } - }; - IAsyncNodeAction asyncNodeAction = new DefaultAsyncNodeAction(this); - switch (fieldType) - { - case VOCABULARY: - return new VocabularyField(fieldParameters); - case EXPERIMENT: - return new EntityField(DataSetOwnerType.EXPERIMENT, facadeProvider, asyncNodeAction); - case SAMPLE: - return new EntityField(DataSetOwnerType.SAMPLE, facadeProvider, asyncNodeAction); - case DATA_SET: - return new EntityField(DataSetOwnerType.DATA_SET, facadeProvider, asyncNodeAction); - default: - return new TextField(); - } - } - - @Override - protected void loadMoreSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs) - throws NotConfigurableException - { - parameterBindings.loadValidatedSettingsFrom(settings); - - } - - @Override - protected void saveMoreSettingsTo(NodeSettingsWO settings) throws InvalidSettingsException - { - parameterBindings.removeAllBindings(); - Set<Entry<String, IField>> entrySet = parameterFields.entrySet(); - for (Entry<String, IField> entry : entrySet) - { - parameterBindings.bind(entry.getKey(), entry.getValue().getValue()); - } - parameterBindings.saveSettingsTo(settings); - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractTestNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractTestNodeDialog.java deleted file mode 100644 index f652810ab70a5e37193742d1eb87294fc5574b09..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/AbstractTestNodeDialog.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.JPanel; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeSettings; -import org.knime.core.node.NotConfigurableException; - -import ch.systemsx.cisd.common.logging.LogInitializer; -import ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeModel; -import ch.systemsx.cisd.openbis.knime.common.Util; - -/** - * @author Franz-Josef Elmer - */ -public abstract class AbstractTestNodeDialog -{ - public static NodeSettings createSettings() - { - NodeSettings settings = new NodeSettings(""); - settings.addString(AbstractOpenBisNodeModel.URL_KEY, "http://localhost:8888"); - settings.addString(AbstractOpenBisNodeModel.USER_KEY, "test"); - settings.addString(AbstractOpenBisNodeModel.PASSWORD_KEY, - Util.getEncryptedPassword("a".toCharArray())); - return settings; - } - - public static void createAndShow(AbstractTestNodeDialog factory) - { - LogInitializer.init(); - JFrame frame = new JFrame("test"); - JPanel panel = new JPanel(new BorderLayout()); - frame.getContentPane().add(panel); - final NodeManager nodeManager = new NodeManager(panel, factory); - nodeManager.createNode(); - JPanel buttonPanel = new JPanel(); - JButton saveButton = new JButton("Save"); - saveButton.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - nodeManager.saveSettings(); - } - }); - buttonPanel.add(saveButton); - JButton readButton = new JButton("Read"); - readButton.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - nodeManager.createNode(); - } - }); - buttonPanel.add(readButton); - panel.add(buttonPanel, BorderLayout.SOUTH); - frame.pack(); - frame.setVisible(true); - } - - public abstract NodeDialogPane create() throws NotConfigurableException; - - private static final class NodeManager - { - private final JPanel panel; - - private final AbstractTestNodeDialog nodeDialogFactory; - - private NodeDialogPane nodeDialog; - - private byte[] settings; - - NodeManager(JPanel panel, AbstractTestNodeDialog nodeDialogFactory) - { - this.panel = panel; - this.nodeDialogFactory = nodeDialogFactory; - } - - void createNode() - { - try - { - if (nodeDialog != null) - { - panel.remove(nodeDialog.getPanel()); - } - nodeDialog = nodeDialogFactory.create(); - if (settings != null) - { - nodeDialog.loadSettingsFrom(new ByteArrayInputStream(settings)); - } - panel.add(nodeDialog.getPanel(), BorderLayout.CENTER); - panel.invalidate(); - panel.getParent().validate(); - } catch (Exception ex) - { - showMessage(ex); - } - } - - void saveSettings() - { - try - { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - nodeDialog.saveSettingsTo(out); - System.out.println(out.toString()); - settings = out.toByteArray(); - } catch (Exception ex) - { - showMessage(ex); - } - } - - private void showMessage(Exception ex) - { - ex.printStackTrace(); - JPanel component = nodeDialog == null ? null : nodeDialog.getPanel(); - JOptionPane.showMessageDialog(component, ex.toString()); - } - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/OpenBisPreferencePage.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/OpenBisPreferencePage.java deleted file mode 100644 index 8c3c8e73f04eed0a5af80d0325da60810736b32b..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/common/OpenBisPreferencePage.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.ListEditor; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.knime.workbench.core.KNIMECorePlugin; - -/** - * Preference page for openBIS KNIME nodes. - * - * @author Franz-Josef Elmer - */ -public class OpenBisPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage -{ - public static final String OPENBIS_URLS_KEY = "openbis_urls"; - - public OpenBisPreferencePage() - { - super("openBIS", null, GRID); - } - - @Override - public void init(IWorkbench workbench) - { - setPreferenceStore(KNIMECorePlugin.getDefault().getPreferenceStore()); - } - - @Override - protected void createFieldEditors() - { - final Shell shell = Display.getDefault().getActiveShell(); - addField(new ListEditor(OPENBIS_URLS_KEY, "List of openBIS URLs which can be used to configure nodes:", getFieldEditorParent()) - { - @Override - protected String[] parseString(String stringList) - { - return stringList.split("\n"); - } - - @Override - protected String getNewInputObject() - { - InputDialog inputDialog = new InputDialog(shell, "openBIS URL", - "Enter the base URL of an openBIS application server", "", null); - inputDialog.setBlockOnOpen(true); - return inputDialog.open() == InputDialog.OK ? inputDialog.getValue() : null; - } - - @Override - protected String createList(String[] items) - { - StringBuilder builder = new StringBuilder(); - for (String item : items) - { - if (builder.length() > 0) - { - builder.append('\n'); - } - builder.append(item); - } - return builder.toString(); - } - }); - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeDialog.java deleted file mode 100644 index b91331c6f33e35a7a2d965e7a7a5e10ebdaf2b25..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeDialog.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.util.List; - -import ch.systemsx.cisd.openbis.knime.common.AbstractAggregatedDataImportNodeDialog; -import ch.systemsx.cisd.openbis.knime.common.AggregatedDataImportDescription; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.AggregationServiceDescription; - -/** - * Node dialog for get a data file created by an aggregation service. - * - * @author Franz-Josef Elmer - */ -class AggregatedDataFileImportNodeDialog extends AbstractAggregatedDataImportNodeDialog -{ - AggregatedDataFileImportNodeDialog() - { - super("Aggregated Data File Importing Settings"); - } - - @Override - protected void addDescription(List<AggregatedDataImportDescription> descriptions, - AggregationServiceDescription aggregationServiceDescription) - { - AggregatedDataImportDescription.addDescriptionIfDataFile(descriptions, - aggregationServiceDescription); - } - - @Override - protected String getDescriptionComboBoxLabel() - { - return "Data File Importing Service"; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeFactory.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeFactory.java deleted file mode 100644 index 40334fab5e1d4e7912acae820dfdbff22aa8aeaa..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeFactory.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeFactory; -import org.knime.core.node.NodeView; - -/** - * @author Franz-Josef Elmer - */ -public class AggregatedDataFileImportNodeFactory extends NodeFactory<AggregatedDataFileImportNodeModel> -{ - @Override - public AggregatedDataFileImportNodeModel createNodeModel() - { - return new AggregatedDataFileImportNodeModel(); - } - - @Override - protected NodeDialogPane createNodeDialogPane() - { - return new AggregatedDataFileImportNodeDialog(); - } - - @Override - protected int getNrNodeViews() - { - return 0; - } - - @Override - public NodeView<AggregatedDataFileImportNodeModel> createNodeView(int viewIndex, - AggregatedDataFileImportNodeModel nodeModel) - { - return null; - } - - @Override - protected boolean hasDialog() - { - return true; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeDialog.java deleted file mode 100644 index e01cdc1a63a4653c37b35c4c939acc24bb7491f0..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeDialog.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright 2011 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.awt.BorderLayout; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.text.JTextComponent; - -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; -import org.knime.core.node.NotConfigurableException; -import org.knime.core.node.port.PortObjectSpec; - -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.openbis.dss.client.api.v1.IOpenbisServiceFacade; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileInfoDssDTO; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwnerType; -import ch.systemsx.cisd.openbis.knime.common.AbstractDescriptionBasedNodeDialog; -import ch.systemsx.cisd.openbis.knime.common.DefaultAsyncNodeAction; -import ch.systemsx.cisd.openbis.knime.common.EntityChooser; -import ch.systemsx.cisd.openbis.knime.common.ILoadingBuildingAction; -import ch.systemsx.cisd.openbis.knime.common.IQueryFacadeAction; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.ReportDescription; - -/** - * Node for downloading a file of an openBIS data set. - * - * @author Franz-Josef Elmer - */ -public class DataSetFileImportNodeDialog extends AbstractDescriptionBasedNodeDialog<ReportDescription> -{ - private static boolean isBlank(String text) - { - return text == null || text.trim().length() == 0; - } - - private JTextComponent dataSetCodeField; - - private JTextComponent filePathField; - - private JTextComponent downloadsPathField; - - private JCheckBox reuseCheckBox; - - DataSetFileImportNodeDialog() - { - super("Data Set File Importer Settings"); - } - - @Override - protected void defineQueryForm(JPanel queryPanel, JComboBox reportComboBox) - { - JPanel panel = new JPanel(new GridBagLayout()); - dataSetCodeField = createTextFieldWithButton("Data Set Code", new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - performAction(new IQueryFacadeAction() - { - @Override - public void execute(IQueryApiFacade queryFacade) - { - chooseDataSet(queryFacade); - } - }); - } - }, panel); - filePathField = createTextFieldWithButton("File", new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - chooseDataSetFile(); - } - }, panel); - downloadsPathField = - createTextFieldWithButton("Location of Downloads", new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - chooseTempFolder(); - } - }, panel); - reuseCheckBox = new JCheckBox(); - addField(panel, "Reuse already downloaded file", reuseCheckBox); - JPanel northPanel = new JPanel(new BorderLayout()); - northPanel.add(panel, BorderLayout.NORTH); - queryPanel.add(northPanel, BorderLayout.CENTER); - } - - private JTextComponent createTextFieldWithButton(String label, ActionListener actionListener, - JPanel panel) - { - JPanel textFieldWithButton = new JPanel(new BorderLayout()); - JTextField field = new JTextField(20); - textFieldWithButton.add(field, BorderLayout.CENTER); - JButton button = new JButton("..."); - button.addActionListener(actionListener); - textFieldWithButton.add(button, BorderLayout.EAST); - addField(panel, label, textFieldWithButton); - return field; - } - - @Override - protected List<ReportDescription> getSortedDescriptions(IQueryApiFacade facade) - { - List<ReportDescription> descriptions = facade.listTableReportDescriptions(); - Collections.sort(descriptions, new Comparator<ReportDescription>() - { - @Override - public int compare(ReportDescription o1, ReportDescription o2) - { - return o1.getLabel().compareTo(o2.getLabel()); - } - }); - return descriptions; - } - - @Override - protected String getDescriptionKey() - { - return ""; - } - - @Override - protected void loadMoreSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs) - throws NotConfigurableException - { - dataSetCodeField.setText(settings.getString(DataSetFileImportNodeModel.DATA_SET_CODE_KEY, - "")); - filePathField.setText(settings.getString(DataSetFileImportNodeModel.FILE_PATH_KEY, "")); - downloadsPathField.setText(settings.getString( - DataSetFileImportNodeModel.DOWNLOADS_PATH_KEY, "")); - reuseCheckBox.setSelected(settings.getBoolean(DataSetFileImportNodeModel.REUSE_FILE, true)); - } - - @Override - protected void saveMoreSettingsTo(NodeSettingsWO settings) throws InvalidSettingsException - { - String dataSetCode = dataSetCodeField.getText(); - if (isBlank(dataSetCode)) - { - throw new InvalidSettingsException("Data set code hasn't been specified."); - } - settings.addString(DataSetFileImportNodeModel.DATA_SET_CODE_KEY, dataSetCode); - String filePath = filePathField.getText(); - if (isBlank(filePath)) - { - throw new InvalidSettingsException("Data set file path hasn't been specified."); - } - settings.addString(DataSetFileImportNodeModel.FILE_PATH_KEY, filePath); - String downloadsPath = downloadsPathField.getText(); - if (isBlank(downloadsPath)) - { - throw new InvalidSettingsException("Location of downloads hasn't been specified."); - } - settings.addString(DataSetFileImportNodeModel.DOWNLOADS_PATH_KEY, downloadsPath); - settings.addString(DataSetFileImportNodeModel.ABSOLUTE_FILE_PATH_KEY, - downloadsPath + "/" + dataSetCode + "/" + filePath); - settings.addBoolean(DataSetFileImportNodeModel.REUSE_FILE, reuseCheckBox.isSelected()); - } - - private void chooseDataSet(IQueryApiFacade facade) - { - try - { - String ownerOrNull = new EntityChooser(getPanel(), DataSetOwnerType.DATA_SET, true, - facade.getSessionToken(), facade.getGeneralInformationService(), - new DefaultAsyncNodeAction(this)).getOwnerOrNull(); - if (ownerOrNull != null) - { - dataSetCodeField.setText(ownerOrNull); - filePathField.setText(""); - } - } catch (Exception ex) - { - showException(ex); - } - } - - private void chooseDataSetFile() - { - final String dataSetCode = dataSetCodeField.getText(); - if (isBlank(dataSetCode)) - { - return; - } - - performAction(new ILoadingBuildingAction<FileInfoDssDTO[]>() - { - @Override - public FileInfoDssDTO[] load() - { - IOpenbisServiceFacade openbisFacade = createOpenbisFacade(createFacade().getSessionToken()); - ch.systemsx.cisd.openbis.dss.client.api.v1.DataSet dataSet = - openbisFacade.getDataSet(dataSetCode); - if (dataSet == null) - { - throw new UserFailureException("Unknown data set: " + dataSetCode); - } - return dataSet.listFiles("", true); - } - - @Override - public void build(FileInfoDssDTO[] files) - { - FileChooser fileChooser = new FileChooser(dataSetCode, files); - int result = JOptionPane.showOptionDialog(getPanel(), fileChooser, "Data Set File Chooser", - JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null); - FileInfoDssDTO fileInfo = fileChooser.getSelectedFileInfoOrNull(); - if (fileInfo != null && fileInfo.getPathInListing() != null - && fileInfo.isDirectory() == false && result == JOptionPane.OK_OPTION) - { - filePathField.setText(fileInfo.getPathInDataSet()); - } - } - }); - } - - private void chooseTempFolder() - { - JFileChooser chooser = new JFileChooser(); - String path = downloadsPathField.getText(); - if (isBlank(path) == false) - { - chooser.setSelectedFile(new File(path)); - } - chooser.setDialogType(JFileChooser.OPEN_DIALOG); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - chooser.setMultiSelectionEnabled(false); - chooser.showDialog(getPanel(), "Select"); - File selectedFile = chooser.getSelectedFile(); - if (selectedFile != null) - { - downloadsPathField.setText(selectedFile.getPath()); - } - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeFactory.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeFactory.java deleted file mode 100644 index b14ca0d7241f3db5020e0bfe2c399388a1f1f0dd..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2010 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeFactory; -import org.knime.core.node.NodeView; - -import ch.systemsx.cisd.openbis.knime.common.IOpenbisServiceFacadeFactory; -import ch.systemsx.cisd.openbis.knime.common.OpenbisServiceFacadeFactory; - -/** - * Factory for {@link DataSetFileImportNodeDialog} and {@link DataSetFileImportNodeModel}. - * - * @author Franz-Josef Elmer - */ -public class DataSetFileImportNodeFactory extends NodeFactory<DataSetFileImportNodeModel> -{ - private final IOpenbisServiceFacadeFactory factory = new OpenbisServiceFacadeFactory(); - - @Override - protected NodeDialogPane createNodeDialogPane() - { - return new DataSetFileImportNodeDialog(); - } - - @Override - public DataSetFileImportNodeModel createNodeModel() - { - return new DataSetFileImportNodeModel(factory); - } - - @Override - public NodeView<DataSetFileImportNodeModel> createNodeView(int viewIndex, - DataSetFileImportNodeModel model) - { - return null; - } - - @Override - protected int getNrNodeViews() - { - return 0; - } - - @Override - protected boolean hasDialog() - { - return true; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeDialog.java deleted file mode 100644 index f3ac427caf95bbfeda46cb93ac9e7d3bc4cb0e92..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeDialog.java +++ /dev/null @@ -1,580 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Container; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JSeparator; -import javax.swing.JTextField; -import javax.swing.JViewport; -import javax.swing.text.JTextComponent; - -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; -import org.knime.core.node.NotConfigurableException; -import org.knime.core.node.port.PortObjectSpec; -import org.knime.core.node.util.FlowVariableListCellRenderer; -import org.knime.core.node.workflow.FlowVariable; -import org.knime.core.node.workflow.FlowVariable.Type; - -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwnerType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ControlledVocabularyPropertyType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ControlledVocabularyPropertyType.VocabularyTerm; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyTypeGroup; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode; -import ch.systemsx.cisd.openbis.generic.shared.util.SimplePropertyValidator; -import ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeDialog; -import ch.systemsx.cisd.openbis.knime.common.DefaultAsyncNodeAction; -import ch.systemsx.cisd.openbis.knime.common.EntityChooser; -import ch.systemsx.cisd.openbis.knime.common.IOpenbisServiceFacadeFactory; -import ch.systemsx.cisd.openbis.knime.common.IQueryFacadeAction; -import ch.systemsx.cisd.openbis.knime.common.Util; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; - -/** - * @author Franz-Josef Elmer - */ -public class DataSetRegistrationNodeDialog extends AbstractOpenBisNodeDialog -{ - private static final class ValidationHandler - { - private final StringBuilder builder = new StringBuilder(); - - private final SimplePropertyValidator validator; - - ValidationHandler(SimplePropertyValidator validator) - { - this.validator = validator; - } - - String getErrorMessage() - { - return builder.toString(); - } - - void validate(PropertyType propertyType, String value) - { - if (value == null || value.trim().length() == 0) - { - if (propertyType.isMandatory()) - { - addErrorMessage(propertyType, "Missing mandatory value"); - } - } else - { - DataTypeCode dataType = propertyType.getDataType(); - if (validator.canValidate(dataType)) - { - try - { - validator.validatePropertyValue(dataType, value); - } catch (UserFailureException ex) - { - addErrorMessage(propertyType, ex.getMessage()); - } - } - } - } - - private void addErrorMessage(PropertyType propertyType, String message) - { - builder.append("Invalid property '").append(propertyType.getLabel()); - builder.append("': ").append(message).append(".\n"); - } - } - - private static final class DataSetTypeAdapter - { - private final DataSetType dataSetType; - - DataSetTypeAdapter(DataSetType dataSetType) - { - this.dataSetType = dataSetType; - } - - public DataSetType getDataSetType() - { - return dataSetType; - } - - @Override - public String toString() - { - return dataSetType.getCode(); - } - } - - private static final class TermAdapter - { - private final VocabularyTerm vocabularyTerm; - - TermAdapter(VocabularyTerm vocabularyTerm) - { - this.vocabularyTerm = vocabularyTerm; - } - - public VocabularyTerm getVocabularyTerm() - { - return vocabularyTerm; - } - - @Override - public String toString() - { - return getVocabularyTerm().getLabel(); - } - } - - private static enum FieldFactory - { - VOCABULARY_FIELD_FACTORY() - { - @Override - boolean canCreate(PropertyType propertyType) - { - return propertyType instanceof ControlledVocabularyPropertyType; - } - - @Override - JComponent create(PropertyType propertyType, String valueOrNull) - { - List<VocabularyTerm> terms = - ((ControlledVocabularyPropertyType) propertyType).getTerms(); - JComboBox comboBox = new JComboBox(); - for (VocabularyTerm vocabularyTerm : terms) - { - TermAdapter termAdapter = new TermAdapter(vocabularyTerm); - comboBox.addItem(termAdapter); - if (vocabularyTerm.getCode().equals(valueOrNull)) - { - comboBox.setSelectedItem(termAdapter); - } - } - return comboBox; - } - }, - CHECK_BOX_FIELD_FACTORY() - { - @Override - boolean canCreate(PropertyType propertyType) - { - return propertyType.getDataType() == DataTypeCode.BOOLEAN; - } - - @Override - JComponent create(PropertyType propertyType, String valueOrNull) - { - JCheckBox checkBox = new JCheckBox(); - checkBox.setSelected(Boolean.parseBoolean(valueOrNull)); - return checkBox; - } - }, - FIELD_FACTORY() - { - @Override - boolean canCreate(PropertyType propertyType) - { - return true; - } - - @Override - JComponent create(PropertyType propertyType, String valueOrNull) - { - JTextField textField = new JTextField(10); - if (valueOrNull != null) - { - textField.setText(valueOrNull); - } - return textField; - } - }, - ; - - abstract boolean canCreate(PropertyType propertyType); - - abstract JComponent create(PropertyType propertyType, String valueOrNull); - } - - private JComboBox ownerTypeComboBox; - - private JTextField ownerField; - - private JComboBox fileVariableComboBox; - - private JComboBox dataSetTypeComboBox; - - private Map<String, JComponent> propertyFieldRepository = new HashMap<String, JComponent>(); - - private Map<String, JComponent> propertyFields = new HashMap<String, JComponent>(); - - private JComponent propertiesLabel; - - protected DataSetRegistrationNodeDialog(IOpenbisServiceFacadeFactory serviceFacadeFactory) - { - super("Data Set Registration Settings", serviceFacadeFactory); - } - - @Override - protected void defineQueryForm(JPanel queryPanel) - { - JPanel fields = new JPanel(new GridBagLayout()); - ownerTypeComboBox = new JComboBox(DataSetOwnerType.values()); - ownerTypeComboBox.addItemListener(new ItemListener() - { - @Override - public void itemStateChanged(ItemEvent event) - { - setOwnerToolTip(); - ownerField.setText(""); - } - }); - addField(fields, "Owner type", ownerTypeComboBox) - .setToolTipText("The type of entity the new data set will directly be linked to."); - ownerField = new JTextField(20); - setOwnerToolTip(); - JPanel textFieldWithButton = new JPanel(new BorderLayout()); - textFieldWithButton.add(ownerField, BorderLayout.CENTER); - JButton button = new JButton("..."); - button.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - performAction(new IQueryFacadeAction() - { - @Override - public void execute(IQueryApiFacade queryFacade) - { - chooseOwner(queryFacade); - } - }); - } - }); - textFieldWithButton.add(button, BorderLayout.EAST); - addField(fields, "Owner", textFieldWithButton) - .setToolTipText("Owner is the experiment/sample/data set the new data set will directly be linked to."); - dataSetTypeComboBox = new JComboBox(); - addField(fields, "Data Set Type", dataSetTypeComboBox); - if (withFileVariable()) - { - fileVariableComboBox = new JComboBox(); - fileVariableComboBox.setRenderer(new FlowVariableListCellRenderer()); - addField(fields, "File Variable", fileVariableComboBox) - .setToolTipText("The flow variable storing the location of the file to be registered."); - } - propertiesLabel = new JSeparator(); - fields.add(propertiesLabel, createLast()); - queryPanel.add(fields, BorderLayout.NORTH); - } - - protected boolean withFileVariable() - { - return false; - } - - private void setOwnerToolTip() - { - DataSetOwnerType ownerType = getSelectedOwnerType(); - String ownerTypeName = null; - switch (ownerType) - { - case EXPERIMENT: - ownerTypeName = "an experiment"; - break; - case SAMPLE: - ownerTypeName = "a sample"; - break; - case DATA_SET: - ownerTypeName = "a data set"; - break; - } - ownerField.setToolTipText("Choose " + ownerTypeName + " or keep it empty if flow variable " - + Util.VARIABLE_PREFIX + ownerType.name() + " should be used."); - } - - private DataSetOwnerType getSelectedOwnerType() - { - return (DataSetOwnerType) ownerTypeComboBox.getSelectedItem(); - } - - private void chooseOwner(IQueryApiFacade facade) - { - DataSetOwnerType ownerType = getSelectedOwnerType(); - String sessionToken = facade.getSessionToken(); - IGeneralInformationService service = facade.getGeneralInformationService(); - String ownerOrNull = new EntityChooser(ownerField, ownerType, true, sessionToken, service, - new DefaultAsyncNodeAction(this)).getOwnerOrNull(); - if (ownerOrNull != null) - { - ownerField.setText(ownerOrNull); - } - } - - @Override - protected void updateQueryForm(IQueryApiFacade queryFacade) - { - DataSetTypeAdapter dataSetTypeAdapter = null; - Object selectedItem = dataSetTypeComboBox.getSelectedItem(); - if (selectedItem instanceof DataSetTypeAdapter) - { - dataSetTypeAdapter = (DataSetTypeAdapter) selectedItem; - } - dataSetTypeComboBox.removeAllItems(); - String sessionToken = queryFacade.getSessionToken(); - List<DataSetType> dataSetTypes = createOpenbisFacade(sessionToken).listDataSetTypes(); - for (DataSetType dataSetType : dataSetTypes) - { - dataSetTypeComboBox.addItem(new DataSetTypeAdapter(dataSetType)); - } - dataSetTypeComboBox.addItemListener(new ItemListener() - { - @Override - public void itemStateChanged(ItemEvent event) - { - changeDataSetType(((DataSetTypeAdapter) event.getItem()).getDataSetType(), - new HashMap<String, String>()); - } - }); - if (dataSetTypes.isEmpty() == false) - { - int index = 0; - if (dataSetTypeAdapter != null) - { - String dataSetTypeCode = dataSetTypeAdapter.getDataSetType().getCode(); - for (int i = 0, n = dataSetTypeComboBox.getItemCount(); i < n; i++) - { - Object item = dataSetTypeComboBox.getItemAt(i); - if (item instanceof DataSetTypeAdapter) - { - DataSetTypeAdapter dAdapter = (DataSetTypeAdapter) item; - if (dAdapter.getDataSetType().getCode().equals(dataSetTypeCode)) - { - index = i; - break; - } - } - } - } - dataSetTypeComboBox.setSelectedIndex(index); - changeDataSetType(dataSetTypes.get(index), new HashMap<String, String>()); - } - } - - private void changeDataSetType(DataSetType dataSetType, Map<String, String> properties) - { - Container parent = propertiesLabel.getParent(); - Component[] components = parent.getComponents(); - boolean removing = false; - for (Component component : components) - { - if (removing) - { - parent.remove(component); - } else if (component == propertiesLabel) - { - removing = true; - } - } - propertyFields.clear(); - List<PropertyTypeGroup> propertyTypeGroups = dataSetType.getPropertyTypeGroups(); - for (PropertyTypeGroup propertyTypeGroup : propertyTypeGroups) - { - List<PropertyType> propertyTypes = propertyTypeGroup.getPropertyTypes(); - for (PropertyType propertyType : propertyTypes) - { - String code = propertyType.getCode(); - String valueOrNull = properties.get(code); - JComponent field = getField(propertyType, valueOrNull); - addField(parent, propertyType.getLabel(), field, propertyType.isMandatory()); - propertyFields.put(code, field); - } - } - parent.invalidate(); - while (parent != null && parent instanceof JViewport == false) - { - parent = parent.getParent(); - } - parent.validate(); - } - - private JComponent getField(PropertyType propertyType, String valueOrNull) - { - JComponent field = propertyFieldRepository.get(propertyType.getCode()); - if (field == null) - { - FieldFactory[] values = FieldFactory.values(); - for (FieldFactory fieldFactory : values) - { - if (fieldFactory.canCreate(propertyType)) - { - field = fieldFactory.create(propertyType, valueOrNull); - field.setToolTipText(propertyType.getDescription()); - propertyFieldRepository.put(propertyType.getCode(), field); - break; - } - } - } - return field; - } - - @Override - protected void loadAdditionalSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs) - throws NotConfigurableException - { - ownerTypeComboBox.setSelectedItem(DataSetOwnerType.valueOf(settings.getString( - DataSetRegistrationNodeModel.OWNER_TYPE_KEY, DataSetOwnerType.EXPERIMENT.name()))); - ownerField.setText(settings.getString(DataSetRegistrationNodeModel.OWNER_KEY, "")); - if (fileVariableComboBox != null) - { - fileVariableComboBox.removeAllItems(); - String fileVariable = settings.getString(DataSetRegistrationNodeModel.FILE_VARIABLE_KEY, ""); - for (FlowVariable flowVariable : getFlowVariables()) - { - if (flowVariable.getType().equals(Type.STRING)) - { - fileVariableComboBox.addItem(flowVariable); - if (flowVariable.getName().equals(fileVariable)) - { - fileVariableComboBox.setSelectedItem(flowVariable); - } - } - } - } - byte[] bytes = settings.getByteArray(DataSetRegistrationNodeModel.DATA_SET_TYPE_KEY, null); - DataSetType dataSetType = Util.deserializeDescription(bytes); - if (dataSetType != null && dataSetTypeComboBox.getItemCount() == 0) - { - dataSetTypeComboBox.addItem(new DataSetTypeAdapter(dataSetType)); - dataSetTypeComboBox.setSelectedIndex(0); - try - { - changeDataSetType(dataSetType, DataSetRegistrationNodeModel.getProperties(settings)); - } catch (InvalidSettingsException ex) - { - throw new NotConfigurableException("Couldn't get properties", ex); - } - } - } - - protected Collection<FlowVariable> getFlowVariables() - { - return getAvailableFlowVariables().values(); - } - - @Override - protected void saveAdditionalSettingsTo(NodeSettingsWO settings) - throws InvalidSettingsException - { - SimplePropertyValidator propertyValidator = new SimplePropertyValidator(); - settings.addString(DataSetRegistrationNodeModel.OWNER_TYPE_KEY, - getSelectedOwnerType().name()); - settings.addString(DataSetRegistrationNodeModel.OWNER_KEY, ownerField.getText()); - if (fileVariableComboBox != null) - { - Object selectedItem = fileVariableComboBox.getSelectedItem(); - if (selectedItem instanceof FlowVariable) - { - FlowVariable flowVariable = (FlowVariable) selectedItem; - settings.addString(DataSetRegistrationNodeModel.FILE_VARIABLE_KEY, flowVariable.getName()); - } - } - DataSetTypeAdapter dataSetTypeAdapter = - (DataSetTypeAdapter) dataSetTypeComboBox.getSelectedItem(); - if (dataSetTypeAdapter == null) - { - throw new InvalidSettingsException("Unspecified data set type."); - } - DataSetType dataSetType = dataSetTypeAdapter.getDataSetType(); - byte[] bytes = Util.serializeDescription(dataSetType); - settings.addByteArray(DataSetRegistrationNodeModel.DATA_SET_TYPE_KEY, bytes); - Map<String, PropertyType> propertyTypes = getPropertyTypes(dataSetType); - List<String> propertyTypeCodes = new ArrayList<String>(propertyFields.size()); - List<String> propertyValues = new ArrayList<String>(propertyFields.size()); - ValidationHandler validationHandler = new ValidationHandler(propertyValidator); - for (Entry<String, JComponent> entry : propertyFields.entrySet()) - { - String propertyTypeCode = entry.getKey(); - propertyTypeCodes.add(propertyTypeCode); - JComponent component = entry.getValue(); - String value = null; - if (component instanceof JTextComponent) - { - JTextComponent textComponent = (JTextComponent) component; - value = textComponent.getText(); - } else if (component instanceof JCheckBox) - { - JCheckBox checkBox = (JCheckBox) component; - value = Boolean.toString(checkBox.isSelected()); - } else if (component instanceof JComboBox) - { - JComboBox comboBox = (JComboBox) component; - value = ((TermAdapter) comboBox.getSelectedItem()).getVocabularyTerm().getCode(); - } - PropertyType propertyType = propertyTypes.get(propertyTypeCode); - validationHandler.validate(propertyType, value); - propertyValues.add(value); - } - String errorMessage = validationHandler.getErrorMessage(); - if (errorMessage.length() > 0) - { - throw new InvalidSettingsException(errorMessage); - } - settings.addStringArray(DataSetRegistrationNodeModel.PROPERTY_TYPE_CODES_KEY, - propertyTypeCodes.toArray(new String[0])); - settings.addStringArray(DataSetRegistrationNodeModel.PROPERTY_VALUES_KEY, - propertyValues.toArray(new String[0])); - } - - private Map<String, PropertyType> getPropertyTypes(DataSetType dataSetType) - { - List<PropertyTypeGroup> propertyTypeGroups = dataSetType.getPropertyTypeGroups(); - Map<String, PropertyType> result = new HashMap<String, PropertyType>(); - for (PropertyTypeGroup propertyTypeGroup : propertyTypeGroups) - { - List<PropertyType> propertyTypes = propertyTypeGroup.getPropertyTypes(); - for (PropertyType propertyType : propertyTypes) - { - result.put(propertyType.getCode(), propertyType); - } - } - return result; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeFactory.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeFactory.java deleted file mode 100644 index 931f22feed8a8128a78b16a0f3fb305e22879d89..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeFactory; -import org.knime.core.node.NodeView; - -import ch.systemsx.cisd.openbis.knime.common.IOpenbisServiceFacadeFactory; -import ch.systemsx.cisd.openbis.knime.common.OpenbisServiceFacadeFactory; - -/** - * @author Franz-Josef Elmer - */ -public class DataSetRegistrationNodeFactory extends NodeFactory<DataSetRegistrationNodeModel> -{ - private final IOpenbisServiceFacadeFactory factory = new OpenbisServiceFacadeFactory(); - - @Override - protected NodeDialogPane createNodeDialogPane() - { - return new DataSetRegistrationNodeDialog(factory); - } - - @Override - public DataSetRegistrationNodeModel createNodeModel() - { - return new DataSetRegistrationNodeModel(factory); - } - - @Override - protected int getNrNodeViews() - { - return 0; - } - - @Override - public NodeView<DataSetRegistrationNodeModel> createNodeView(int viewIndex, - DataSetRegistrationNodeModel nodeModel) - { - return null; - } - - @Override - protected boolean hasDialog() - { - return true; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationViaFlowNodeFactory.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationViaFlowNodeFactory.java deleted file mode 100644 index 50d265530491fe655bc3a7d817821d9cd038983b..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationViaFlowNodeFactory.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeFactory; -import org.knime.core.node.NodeView; - -import ch.systemsx.cisd.openbis.knime.common.IOpenbisServiceFacadeFactory; -import ch.systemsx.cisd.openbis.knime.common.OpenbisServiceFacadeFactory; - -/** - * @author Franz-Josef Elmer - */ -public class DataSetRegistrationViaFlowNodeFactory extends NodeFactory<DataSetRegistrationViaFlowNodeModel> -{ - private final IOpenbisServiceFacadeFactory factory = new OpenbisServiceFacadeFactory(); - - @Override - protected NodeDialogPane createNodeDialogPane() - { - return new DataSetRegistrationNodeDialog(factory) - { - @Override - protected boolean withFileVariable() - { - return true; - } - }; - } - - @Override - public DataSetRegistrationViaFlowNodeModel createNodeModel() - { - return new DataSetRegistrationViaFlowNodeModel(factory); - } - - @Override - protected int getNrNodeViews() - { - return 0; - } - - @Override - public NodeView<DataSetRegistrationViaFlowNodeModel> createNodeView(int viewIndex, - DataSetRegistrationViaFlowNodeModel nodeModel) - { - return null; - } - - @Override - protected boolean hasDialog() - { - return true; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/TestAggregatedDataImportNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/TestAggregatedDataImportNodeDialog.java deleted file mode 100644 index c380aaeabb8e422c13cae49fe6a2b5aef0c49906..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/TestAggregatedDataImportNodeDialog.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.util.Arrays; -import java.util.Collection; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeSettings; -import org.knime.core.node.NotConfigurableException; -import org.knime.core.node.port.PortObjectSpec; -import org.knime.core.node.workflow.Credentials; -import org.knime.core.node.workflow.ICredentials; - -import ch.systemsx.cisd.openbis.knime.common.AbstractTestNodeDialog; -import ch.systemsx.cisd.openbis.knime.common.ParameterBindings; - -/** - * Stand alone application for testing {@link AggregatedDataFileImportNodeDialog}. - * - * @author Franz-Josef Elmer - */ -public class TestAggregatedDataImportNodeDialog extends AbstractTestNodeDialog -{ - - public static void main(String[] args) throws NotConfigurableException - { - AbstractTestNodeDialog.createAndShow(new TestAggregatedDataImportNodeDialog()); - } - - @Override - public NodeDialogPane create() throws NotConfigurableException - { - return new AggregatedDataFileImportNodeDialog() - { - { - NodeSettings settings = createSettings(); - settings.addStringArray(ParameterBindings.PARAMETER_KEYS_KEY, new String[0]); - settings.addStringArray(ParameterBindings.PARAMETER_VALUES_KEY, new String[0]); - loadSettingsFrom(settings, (PortObjectSpec[]) null); - } - - @Override - protected String[] getUrls() - { - return new String[] { "http://localhost:8888" }; - } - - @Override - protected Collection<String> getAllCredentialsNames() - { - return Arrays.asList("test"); - } - - @Override - protected ICredentials getCredentials() - { - return new Credentials("_", "test", "a"); - } - - }; - } -} \ No newline at end of file diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/TestDataSetFileImportNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/TestDataSetFileImportNodeDialog.java deleted file mode 100644 index 19f4ba97f3a5a735de02c9bc829e6605fdd2b13e..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/TestDataSetFileImportNodeDialog.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2012 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.util.Arrays; -import java.util.Collection; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeSettings; -import org.knime.core.node.NotConfigurableException; -import org.knime.core.node.port.PortObjectSpec; -import org.knime.core.node.workflow.Credentials; -import org.knime.core.node.workflow.ICredentials; - -import ch.systemsx.cisd.openbis.knime.common.AbstractTestNodeDialog; -import ch.systemsx.cisd.openbis.knime.common.ParameterBindings; - -/** - * @author Franz-Josef Elmer - */ -public class TestDataSetFileImportNodeDialog extends AbstractTestNodeDialog -{ - public static void main(String[] args) - { - AbstractTestNodeDialog.createAndShow(new TestDataSetFileImportNodeDialog()); - } - - @Override - public NodeDialogPane create() throws NotConfigurableException - { - return new DataSetFileImportNodeDialog() - { - { - NodeSettings settings = createSettings(); - settings.addStringArray(ParameterBindings.PARAMETER_KEYS_KEY, new String[0]); - settings.addStringArray(ParameterBindings.PARAMETER_VALUES_KEY, new String[0]); - loadSettingsFrom(settings, (PortObjectSpec[]) null); - } - - @Override - protected String[] getUrls() - { - return new String[] { "http://localhost:8888" }; - } - - @Override - protected Collection<String> getAllCredentialsNames() - { - return Arrays.asList("test"); - } - - @Override - protected ICredentials getCredentials() - { - return new Credentials("_", "test", "a"); - } - - }; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/TestDataSetRegistrationNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/TestDataSetRegistrationNodeDialog.java deleted file mode 100644 index 858033cc10007028a1bbcbe8ab4ee1816c6044f2..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/file/TestDataSetRegistrationNodeDialog.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.util.Arrays; -import java.util.Collection; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeSettings; -import org.knime.core.node.NotConfigurableException; -import org.knime.core.node.port.PortObjectSpec; -import org.knime.core.node.workflow.Credentials; -import org.knime.core.node.workflow.FlowVariable; -import org.knime.core.node.workflow.ICredentials; - -import ch.systemsx.cisd.openbis.knime.common.AbstractTestNodeDialog; -import ch.systemsx.cisd.openbis.knime.common.OpenbisServiceFacadeFactory; - -/** - * Stand alone application for testing {@link DataSetRegistrationNodeDialog}. - * - * @author Franz-Josef Elmer - */ -public class TestDataSetRegistrationNodeDialog extends AbstractTestNodeDialog -{ - - public static void main(String[] args) throws NotConfigurableException - { - AbstractTestNodeDialog.createAndShow(new TestDataSetRegistrationNodeDialog()); - } - - @Override - public NodeDialogPane create() throws NotConfigurableException - { - return new DataSetRegistrationNodeDialog(new OpenbisServiceFacadeFactory()) - { - { - NodeSettings settings = createSettings(); - loadSettingsFrom(settings, (PortObjectSpec[]) null); - } - - @Override - protected String[] getUrls() - { - return new String[] { "http://localhost:8888" }; - } - - @Override - protected Collection<String> getAllCredentialsNames() - { - return Arrays.asList("test"); - } - - @Override - protected ICredentials getCredentials() - { - return new Credentials("_", "test", "a"); - } - - @Override - protected boolean withFileVariable() - { - return true; - } - - @Override - protected Collection<FlowVariable> getFlowVariables() - { - return Arrays.asList(new FlowVariable("answer", 42), - new FlowVariable("fname", "here/and/there"), - new FlowVariable("file-name", "this/and/that")); - } - }; - } -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/AggregatedDataTableImportNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/AggregatedDataTableImportNodeDialog.java deleted file mode 100644 index 4adb3ea272eb47af1769f64cefc3a58c7321049f..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/AggregatedDataTableImportNodeDialog.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import java.util.List; - -import ch.systemsx.cisd.openbis.knime.common.AbstractAggregatedDataImportNodeDialog; -import ch.systemsx.cisd.openbis.knime.common.AggregatedDataImportDescription; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.AggregationServiceDescription; - -/** - * Node dialog for get a table created by an aggregation service. - * - * @author Franz-Josef Elmer - */ -class AggregatedDataTableImportNodeDialog extends AbstractAggregatedDataImportNodeDialog -{ - AggregatedDataTableImportNodeDialog() - { - super("Aggregation Service Report Settings"); - } - - @Override - protected void addDescription(List<AggregatedDataImportDescription> descriptions, - AggregationServiceDescription aggregationServiceDescription) - { - AggregatedDataImportDescription.addDescriptionIfDataTable(descriptions, - aggregationServiceDescription); - } - - @Override - protected String getDescriptionComboBoxLabel() - { - return "Aggregation Service"; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/AggregatedDataTableImportNodeFactory.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/AggregatedDataTableImportNodeFactory.java deleted file mode 100644 index bb829e86eec43c451668cfa9fd363cf70090fa97..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/AggregatedDataTableImportNodeFactory.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeFactory; -import org.knime.core.node.NodeView; - -/** - * @author Franz-Josef Elmer - */ -public class AggregatedDataTableImportNodeFactory extends NodeFactory<AggregatedDataTableImportNodeModel> -{ - @Override - public AggregatedDataTableImportNodeModel createNodeModel() - { - return new AggregatedDataTableImportNodeModel(); - } - - @Override - protected NodeDialogPane createNodeDialogPane() - { - return new AggregatedDataTableImportNodeDialog(); - } - - @Override - protected int getNrNodeViews() - { - return 0; - } - - @Override - public NodeView<AggregatedDataTableImportNodeModel> createNodeView(int viewIndex, - AggregatedDataTableImportNodeModel nodeModel) - { - return null; - } - - @Override - protected boolean hasDialog() - { - return true; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/QueryNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/QueryNodeDialog.java deleted file mode 100644 index d4acf7befc7c8efc0d98348b4e2707129b5e62e9..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/QueryNodeDialog.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2010 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import static ch.systemsx.cisd.openbis.knime.query.QueryNodeModel.QUERY_DESCRIPTION_KEY; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import ch.systemsx.cisd.openbis.knime.common.AbstractParameterDescriptionBasedNodeDialog; -import ch.systemsx.cisd.openbis.knime.common.FieldDescription; -import ch.systemsx.cisd.openbis.knime.server.FieldType; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryDescription; - -/** - * Node dialog for an openBIS SQL query. - * - * @author Franz-Josef Elmer - */ -class QueryNodeDialog extends AbstractParameterDescriptionBasedNodeDialog<QueryDescription> -{ - QueryNodeDialog() - { - super("Query Settings"); - } - - @Override - protected List<FieldDescription> getFieldDescriptions(QueryDescription description) - { - List<FieldDescription> fieldDescriptions = new ArrayList<FieldDescription>(); - List<String> parameters = description.getParameters(); - for (String parameter : parameters) - { - fieldDescriptions.add(new FieldDescription(parameter, FieldType.VARCHAR, "")); - } - return fieldDescriptions; - } - - @Override - protected List<QueryDescription> getSortedDescriptions(IQueryApiFacade facade) - { - List<QueryDescription> queries = facade.listQueries(); - Collections.sort(queries, new Comparator<QueryDescription>() - { - @Override - public int compare(QueryDescription d1, QueryDescription d2) - { - return d1.getName().compareTo(d2.getName()); - } - }); - return queries; - } - - @Override - protected String getDescriptionKey() - { - return QUERY_DESCRIPTION_KEY; - } - - @Override - protected String getDescriptionComboBoxLabel() - { - return "Query"; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/QueryNodeFactory.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/QueryNodeFactory.java deleted file mode 100644 index f18c57bec1e290faceb94f55dcae9e7269ca28b0..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/QueryNodeFactory.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2010 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeFactory; -import org.knime.core.node.NodeView; - -/** - * @author Franz-Josef Elmer - */ -public class QueryNodeFactory extends NodeFactory<QueryNodeModel> -{ - - @Override - protected NodeDialogPane createNodeDialogPane() - { - return new QueryNodeDialog(); - } - - @Override - public QueryNodeModel createNodeModel() - { - return new QueryNodeModel(); - } - - @Override - public NodeView<QueryNodeModel> createNodeView(int viewIndex, QueryNodeModel model) - { - return null; - } - - @Override - protected int getNrNodeViews() - { - return 0; - } - - @Override - protected boolean hasDialog() - { - return true; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/ReportNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/ReportNodeDialog.java deleted file mode 100644 index 9ba530ae451bbd283e369c1154095ec53cfd5268..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/ReportNodeDialog.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright 2011 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.text.JTextComponent; - -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; -import org.knime.core.node.NotConfigurableException; -import org.knime.core.node.port.PortObjectSpec; - -import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClauseAttribute; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.SearchOperator; -import ch.systemsx.cisd.openbis.knime.common.AbstractDescriptionBasedNodeDialog; -import ch.systemsx.cisd.openbis.knime.common.GUIUtil; -import ch.systemsx.cisd.openbis.knime.common.IQueryFacadeAction; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.ReportDescription; - -/** - * @author Franz-Josef Elmer - */ -public class ReportNodeDialog extends AbstractDescriptionBasedNodeDialog<ReportDescription> -{ - private static final String DELIMITER = ", "; - - private JTextComponent dataSetCodeFields; - - ReportNodeDialog() - { - super("Report Settings"); - } - - @Override - protected void defineQueryForm(JPanel queryPanel, JComboBox reportComboBox) - { - JPanel panel = new JPanel(new GridBagLayout()); - addField(panel, "Reports", reportComboBox); - JPanel textFieldWithButton = new JPanel(new BorderLayout()); - dataSetCodeFields = new JTextField(20); - textFieldWithButton.add(dataSetCodeFields, BorderLayout.CENTER); - JButton button = new JButton("..."); - button.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - performAction(new IQueryFacadeAction() - { - @Override - public void execute(IQueryApiFacade queryFacade) - { - chooseDataSet(queryFacade); - } - }); - } - }); - textFieldWithButton.add(button, BorderLayout.EAST); - addField(panel, "Data Set Codes", textFieldWithButton); - JPanel northPanel = new JPanel(new BorderLayout()); - northPanel.add(panel, BorderLayout.NORTH); - queryPanel.add(northPanel, BorderLayout.CENTER); - } - - @Override - protected List<ReportDescription> getSortedDescriptions(IQueryApiFacade facade) - { - List<ReportDescription> descriptions = facade.listTableReportDescriptions(); - - if (descriptions != null) - { - Set<String> keys = new HashSet<String>(); - List<ReportDescription> uniqueDescriptions = new ArrayList<ReportDescription>(); - - for (ReportDescription description : descriptions) - { - if (keys.contains(description.getKey()) == false) - { - uniqueDescriptions.add(description); - keys.add(description.getKey()); - } - } - - Collections.sort(uniqueDescriptions, new Comparator<ReportDescription>() - { - @Override - public int compare(ReportDescription o1, ReportDescription o2) - { - return o1.getLabel().compareToIgnoreCase(o2.getLabel()); - } - }); - - return uniqueDescriptions; - } else - { - return Collections.emptyList(); - } - } - - @Override - protected String getDescriptionKey() - { - return ReportNodeModel.REPORT_DESCRIPTION_KEY; - } - - @Override - protected void loadMoreSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs) - throws NotConfigurableException - { - String[] dataSetCodes; - try - { - dataSetCodes = settings.getStringArray(ReportNodeModel.DATA_SET_CODES_KEY); - } catch (InvalidSettingsException ex) - { - throw CheckedExceptionTunnel.wrapIfNecessary(ex); - } - StringBuilder builder = new StringBuilder(); - for (String dataSetCode : dataSetCodes) - { - if (builder.length() > 0) - { - builder.append(DELIMITER); - } - builder.append(dataSetCode); - } - dataSetCodeFields.setText(builder.toString()); - } - - @Override - protected void saveMoreSettingsTo(NodeSettingsWO settings) throws InvalidSettingsException - { - String dataSetCodes = dataSetCodeFields.getText(); - if (dataSetCodes == null || dataSetCodes.trim().length() == 0) - { - throw new InvalidSettingsException("Data set code hasn't been specified."); - } - settings.addStringArray(ReportNodeModel.DATA_SET_CODES_KEY, dataSetCodes.split(" *, *")); - } - - private void chooseDataSet(IQueryApiFacade facade) - { - ReportDescription description = getSelectedDescriptionOrNull(); - if (description == null) - { - return; - } - JPanel panel = getPanel(); - Cursor cursor = panel.getCursor(); - try - { - panel.setCursor(new Cursor(Cursor.WAIT_CURSOR)); - List<DataSet> dataSets = loadDataSets(description, facade); - List<DataSet> selectedDataSets = GUIUtil.getSelectedDataSets(getPanel(), cursor, dataSets, false); - if (selectedDataSets.isEmpty()) - { - return; - } - StringBuilder builder = new StringBuilder(); - for (DataSet dataSet : selectedDataSets) - { - - if (builder.length() > 0) - { - builder.append(DELIMITER); - } - builder.append(dataSet.getCode()); - } - dataSetCodeFields.setText(builder.toString()); - } finally - { - panel.setCursor(cursor); - } - } - - private List<DataSet> loadDataSets(ReportDescription description, IQueryApiFacade facade) - { - List<String> dataSetTypes = description.getDataSetTypes(); - IGeneralInformationService service = facade.getGeneralInformationService(); - List<DataSet> allDataSets = new ArrayList<DataSet>(); - for (String dataSetType : dataSetTypes) - { - SearchCriteria searchCriteria = new SearchCriteria(); - searchCriteria.setOperator(SearchOperator.MATCH_ANY_CLAUSES); - MatchClause clause = - MatchClause.createAttributeMatch(MatchClauseAttribute.TYPE, dataSetType); - searchCriteria.addMatchClause(clause); - List<DataSet> dataSets = service.searchForDataSets(facade.getSessionToken(), searchCriteria); - logger.info(dataSets.size() + " data sets of type " + dataSetType); - allDataSets.addAll(dataSets); - } - return allDataSets; - } -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/ReportNodeFactory.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/ReportNodeFactory.java deleted file mode 100644 index b61ac6d3df170e25570b39a6231faa4a07725e8a..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/ReportNodeFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2010 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeFactory; -import org.knime.core.node.NodeView; - -/** - * Factory for {@link ReportNodeDialog} and {@link ReportNodeModel}. - * - * @author Franz-Josef Elmer - */ -public class ReportNodeFactory extends NodeFactory<ReportNodeModel> -{ - - @Override - protected NodeDialogPane createNodeDialogPane() - { - return new ReportNodeDialog(); - } - - @Override - public ReportNodeModel createNodeModel() - { - return new ReportNodeModel(); - } - - @Override - public NodeView<ReportNodeModel> createNodeView(int viewIndex, ReportNodeModel model) - { - return null; - } - - @Override - protected int getNrNodeViews() - { - return 0; - } - - @Override - protected boolean hasDialog() - { - return true; - } - -} diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/TestAggregatedDataTableImportNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/TestAggregatedDataTableImportNodeDialog.java deleted file mode 100644 index 590a6d77bcb6cc6ffed2eab33268c516115f5562..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/TestAggregatedDataTableImportNodeDialog.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import java.util.Arrays; -import java.util.Collection; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeSettings; -import org.knime.core.node.NotConfigurableException; -import org.knime.core.node.port.PortObjectSpec; -import org.knime.core.node.workflow.Credentials; -import org.knime.core.node.workflow.ICredentials; - -import ch.systemsx.cisd.openbis.knime.common.AbstractTestNodeDialog; -import ch.systemsx.cisd.openbis.knime.common.ParameterBindings; - -/** - * Stand alone application for testing {@link AggregatedDataTableImportNodeDialog}. - * - * @author Franz-Josef Elmer - */ -public class TestAggregatedDataTableImportNodeDialog extends AbstractTestNodeDialog -{ - - public static void main(String[] args) throws NotConfigurableException - { - AbstractTestNodeDialog.createAndShow(new TestAggregatedDataTableImportNodeDialog()); - } - - @Override - public NodeDialogPane create() throws NotConfigurableException - { - return new AggregatedDataTableImportNodeDialog() - { - { - NodeSettings settings = createSettings(); - settings.addStringArray(ParameterBindings.PARAMETER_KEYS_KEY, new String[0]); - settings.addStringArray(ParameterBindings.PARAMETER_VALUES_KEY, new String[0]); - loadSettingsFrom(settings, (PortObjectSpec[]) null); - } - - @Override - protected String[] getUrls() - { - return new String[] { "http://localhost:8888" }; - } - - @Override - protected Collection<String> getAllCredentialsNames() - { - return Arrays.asList("test"); - } - - @Override - protected ICredentials getCredentials() - { - return new Credentials("_", "test", "a"); - } - - }; - } -} \ No newline at end of file diff --git a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/TestReportNodeDialog.java b/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/TestReportNodeDialog.java deleted file mode 100644 index 9ac04f8651c0564d42969b75ab254b74bc43bc7d..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceEclipse/java/ch/systemsx/cisd/openbis/knime/query/TestReportNodeDialog.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import java.util.Arrays; -import java.util.Collection; - -import org.knime.core.node.NodeDialogPane; -import org.knime.core.node.NodeSettings; -import org.knime.core.node.NotConfigurableException; -import org.knime.core.node.port.PortObjectSpec; -import org.knime.core.node.workflow.Credentials; -import org.knime.core.node.workflow.ICredentials; - -import ch.systemsx.cisd.openbis.knime.common.AbstractTestNodeDialog; - -/** - * @author Franz-Josef Elmer - */ -public class TestReportNodeDialog extends AbstractTestNodeDialog -{ - - public static void main(String[] args) throws NotConfigurableException - { - AbstractTestNodeDialog.createAndShow(new TestReportNodeDialog()); - } - - @Override - public NodeDialogPane create() throws NotConfigurableException - { - return new ReportNodeDialog() - { - { - NodeSettings settings = createSettings(); - settings.addStringArray(ReportNodeModel.DATA_SET_CODES_KEY, new String[0]); - loadSettingsFrom(settings, (PortObjectSpec[]) null); - } - - @Override - protected String[] getUrls() - { - return new String[] { "http://localhost:8888" }; - } - - @Override - protected Collection<String> getAllCredentialsNames() - { - return Arrays.asList("test"); - } - - @Override - protected ICredentials getCredentials() - { - return new Credentials("_", "test", "a"); - } - }; - - } - -} diff --git a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/common/ChooserTreeModelTest.java b/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/common/ChooserTreeModelTest.java deleted file mode 100644 index fd06c022627a7d29c7e0a29de5cd9160a63dc1b7..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/common/ChooserTreeModelTest.java +++ /dev/null @@ -1,826 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import static ch.systemsx.cisd.openbis.knime.common.ChooserTreeModel.LOADING_TEXT; - -import java.util.Arrays; -import java.util.EnumSet; -import java.util.List; - -import javax.swing.event.TreeModelEvent; -import javax.swing.event.TreeModelListener; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreeNode; -import javax.swing.tree.TreePath; - -import org.hamcrest.core.IsNull; -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.jmock.internal.NamedSequence; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import ch.systemsx.cisd.common.logging.LogInitializer; -import ch.systemsx.cisd.common.test.RecordingMatcher; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwnerType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample.SampleInitializer; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleFetchOption; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria; - -/** - * @author Franz-Josef Elmer - */ -public class ChooserTreeModelTest extends AssertJUnit -{ - private static final class NonThreadChooserTreeModel extends ChooserTreeModel - { - private static final long serialVersionUID = 1L; - - NonThreadChooserTreeModel(DataSetOwnerType entityType, String sessionToken, - IGeneralInformationService service) - { - this(entityType, true, sessionToken, service); - } - - NonThreadChooserTreeModel(DataSetOwnerType entityType, boolean ownerEntity, String sessionToken, - IGeneralInformationService service) - { - super(entityType, ownerEntity, sessionToken, service); - } - - @Override - void execute(Runnable runnable) - { - runnable.run(); - } - } - - private static final class MockNodeAction implements IAsyncNodeAction - { - private boolean executed; - - private Throwable handledException; - - @Override - public void execute(Runnable runnable) - { - executed = true; - runnable.run(); - } - - @Override - public void handleException(Throwable throwable) - { - handledException = throwable; - } - } - - private static final String SESSION_TOKEN = "s-token"; - - private static final String LISTABLE_SAMPLE_TYPE = "ST1"; - - private static final String NON_LISTABLE_SAMPLE_TYPE = "ST2"; - - private static final String SPACE_1 = "SP1"; - - private static final String SPACE_2 = "SP2"; - - private static final String P_1 = "P1"; - - private static final String P_2 = "P2"; - - private static final String EXP_1 = "EXP1"; - - private static final String EXP_2 = "EXP2"; - - private static final String SAMPLE_1 = "S1"; - - private static final String SAMPLE_2 = "S2"; - - private Mockery context; - - private IGeneralInformationService service; - - private ChooserTreeModel experimentChooserModel; - - private ChooserTreeModel sampleChooserModel; - - private ChooserTreeModel dataSetChooserModel; - - private MockNodeAction nodeAction; - - private TreeModelListener treeModelListener; - - private RecordingMatcher<SearchCriteria> criteriaMatcher; - - private NamedSequence searchForSequence; - - @BeforeMethod - public void beforeMethod() - { - LogInitializer.init(); - context = new Mockery(); - service = context.mock(IGeneralInformationService.class); - treeModelListener = context.mock(TreeModelListener.class); - nodeAction = new MockNodeAction(); - context.checking(new Expectations() - { - { - atLeast(3).of(service).listSampleTypes(SESSION_TOKEN); - SampleType.SampleTypeInitializer sampleTypeInitializer = - new SampleType.SampleTypeInitializer(); - sampleTypeInitializer.setCode(LISTABLE_SAMPLE_TYPE); - sampleTypeInitializer.setListable(true); - SampleType listableSampleType = new SampleType(sampleTypeInitializer); - sampleTypeInitializer.setCode(NON_LISTABLE_SAMPLE_TYPE); - sampleTypeInitializer.setListable(false); - SampleType nonListableSampleType = new SampleType(sampleTypeInitializer); - will(returnValue(Arrays.asList(listableSampleType, nonListableSampleType))); - - atLeast(3).of(service).listProjects(SESSION_TOKEN); - will(returnValue(Arrays.asList(new Project(SPACE_1, P_1), - new Project(SPACE_2, P_1), - new Project(SPACE_1, P_2)))); - } - }); - experimentChooserModel = - new NonThreadChooserTreeModel(DataSetOwnerType.EXPERIMENT, SESSION_TOKEN, service); - experimentChooserModel.addTreeModelListener(treeModelListener); - sampleChooserModel = - new NonThreadChooserTreeModel(DataSetOwnerType.SAMPLE, SESSION_TOKEN, service); - sampleChooserModel.addTreeModelListener(treeModelListener); - dataSetChooserModel = - new NonThreadChooserTreeModel(DataSetOwnerType.DATA_SET, SESSION_TOKEN, service); - dataSetChooserModel.addTreeModelListener(treeModelListener); - criteriaMatcher = new RecordingMatcher<SearchCriteria>(); - searchForSequence = new NamedSequence("criteria-matcher"); - } - - @AfterMethod - public void afterMethod() - { - // To following line of code should also be called at the end of each test method. - // Otherwise one do not known which test failed. - context.assertIsSatisfied(); - } - - @Test - public void testSpaces() - { - Object root = experimentChooserModel.getRoot(); - Object space1 = experimentChooserModel.getChild(root, 0); - Object space2 = experimentChooserModel.getChild(root, 1); - Object loadingNode1 = experimentChooserModel.getChild(space1, 0); - Object loadingNode2 = experimentChooserModel.getChild(space2, 0); - - assertEquals(2, experimentChooserModel.getChildCount(root)); - assertEquals(SPACE_1, space1.toString()); - assertEquals(SPACE_2, space2.toString()); - assertEquals(1, experimentChooserModel.getChildCount(space1)); - assertEquals(1, experimentChooserModel.getChildCount(space2)); - assertEquals(LOADING_TEXT, loadingNode1.toString()); - assertEquals(LOADING_TEXT, loadingNode2.toString()); - assertEquals(0, experimentChooserModel.getChildCount(loadingNode1)); - assertEquals(0, experimentChooserModel.getChildCount(loadingNode2)); - assertSelectibility(false, experimentChooserModel, root); - assertSelectibility(false, experimentChooserModel, space1); - assertSelectibility(false, experimentChooserModel, loadingNode1); - context.assertIsSatisfied(); - } - - @Test - public void testExpandSpaceNodeInDataSetChooserForOwner() - { - Object root = dataSetChooserModel.getRoot(); - Object space1 = dataSetChooserModel.getChild(root, 0); - RecordingMatcher<TreeModelEvent> matcher = prepareTreeStructureChanged(1); - - dataSetChooserModel.expandNode(createPath(dataSetChooserModel, space1), nodeAction); - - assertEquals(null, nodeAction.handledException); - assertEquals(true, nodeAction.executed); - assertEquals(2, dataSetChooserModel.getChildCount(space1)); - assertEquals("P1", dataSetChooserModel.getChild(space1, 0).toString()); - assertEquals("P2", dataSetChooserModel.getChild(space1, 1).toString()); - assertEquals(createPath(dataSetChooserModel, space1).toString(), - matcher.recordedObject().getTreePath().toString()); - context.assertIsSatisfied(); - } - - @Test - public void testExpandSpaceNodeInDataSetChooserForNoOwner() - { - NonThreadChooserTreeModel chooser = new NonThreadChooserTreeModel(DataSetOwnerType.DATA_SET, false, SESSION_TOKEN, service); - chooser.addTreeModelListener(treeModelListener); - Object root = chooser.getRoot(); - Object space1 = chooser.getChild(root, 0); - RecordingMatcher<TreeModelEvent> matcher = prepareTreeStructureChanged(1); - - chooser.expandNode(createPath(chooser, space1), nodeAction); - - assertEquals(null, nodeAction.handledException); - assertEquals(true, nodeAction.executed); - assertEquals(2, chooser.getChildCount(space1)); - assertEquals("P1", chooser.getChild(space1, 0).toString()); - assertEquals("P2", chooser.getChild(space1, 1).toString()); - assertEquals(createPath(chooser, space1).toString(), - matcher.recordedObject().getTreePath().toString()); - context.assertIsSatisfied(); - } - - @Test - public void testExpandSpaceNodeInSampleChooserForOwner() - { - Object root = sampleChooserModel.getRoot(); - Object space1 = sampleChooserModel.getChild(root, 0); - RecordingMatcher<TreeModelEvent> matcher = prepareTreeStructureChanged(1); - - sampleChooserModel.expandNode(createPath(sampleChooserModel, space1), nodeAction); - - assertEquals(null, nodeAction.handledException); - assertEquals(true, nodeAction.executed); - assertEquals(2, sampleChooserModel.getChildCount(space1)); - assertEquals("P1", sampleChooserModel.getChild(space1, 0).toString()); - assertEquals("P2", sampleChooserModel.getChild(space1, 1).toString()); - assertEquals(createPath(sampleChooserModel, space1).toString(), - matcher.recordedObject().getTreePath().toString()); - context.assertIsSatisfied(); - } - - @Test - public void testExpandSpaceNodeInSampleChooserForNoOwner() - { - NonThreadChooserTreeModel chooser = new NonThreadChooserTreeModel(DataSetOwnerType.SAMPLE, false, SESSION_TOKEN, service); - chooser.addTreeModelListener(treeModelListener); - Object root = chooser.getRoot(); - Object space1 = chooser.getChild(root, 0); - RecordingMatcher<TreeModelEvent> matcher = prepareTreeStructureChanged(1); - Sample s2 = TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, SAMPLE_2); - Sample s1 = TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, SAMPLE_1); - prepareSearchForSamples(s2, s1); - - chooser.expandNode(createPath(chooser, space1), nodeAction); - - assertEquals(null, nodeAction.handledException); - assertEquals(true, nodeAction.executed); - assertEquals(4, chooser.getChildCount(space1)); - assertEquals("/SP1/S1", chooser.getChild(space1, 0).toString()); - assertEquals("/SP1/S2", chooser.getChild(space1, 1).toString()); - assertEquals("P1", chooser.getChild(space1, 2).toString()); - assertEquals("P2", chooser.getChild(space1, 3).toString()); - assertEquals(createPath(chooser, space1).toString(), - matcher.recordedObject().getTreePath().toString()); - context.assertIsSatisfied(); - } - - @Test - public void testCollapseSpaceNode() - { - Object root = dataSetChooserModel.getRoot(); - Object space1 = dataSetChooserModel.getChild(root, 0); - prepareTreeStructureChanged(1); - dataSetChooserModel.expandNode(createPath(dataSetChooserModel, space1), nodeAction); - assertEquals(null, nodeAction.handledException); - assertEquals(2, dataSetChooserModel.getChildCount(space1)); - - dataSetChooserModel.collapsNode(createPath(dataSetChooserModel, space1)); - - Object project11 = dataSetChooserModel.getChild(space1, 0); - assertEquals(P_1, project11.toString()); - assertEquals(2, dataSetChooserModel.getChildCount(space1)); - context.assertIsSatisfied(); - } - - @Test - public void testExpandProjectNodeInExperimentChooser() - { - Object root = experimentChooserModel.getRoot(); - Object space1 = experimentChooserModel.getChild(root, 0); - RecordingMatcher<TreeModelEvent> matcher = prepareTreeStructureChanged(2); - experimentChooserModel.expandNode(createPath(experimentChooserModel, space1), nodeAction); - assertEquals(null, nodeAction.handledException); - Object project11 = experimentChooserModel.getChild(space1, 0); - prepareListExperiments(project11); - - experimentChooserModel.expandNode(createPath(experimentChooserModel, project11), nodeAction); - - assertEquals(null, nodeAction.handledException); - assertEquals(true, nodeAction.executed); - assertEquals(2, experimentChooserModel.getChildCount(project11)); - Object child1 = experimentChooserModel.getChild(project11, 0); - assertEquals(EXP_1, child1.toString()); - assertEquals(0, experimentChooserModel.getChildCount(child1)); - assertEquals(true, experimentChooserModel.isLeaf(child1)); - Object child2 = experimentChooserModel.getChild(project11, 1); - assertEquals(EXP_2, child2.toString()); - assertEquals(0, experimentChooserModel.getChildCount(child2)); - assertEquals(true, experimentChooserModel.isLeaf(child2)); - assertEquals(createPath(experimentChooserModel, space1).toString(), - matcher.getRecordedObjects().get(0).getTreePath().toString()); - assertEquals(createPath(experimentChooserModel, project11).toString(), - matcher.getRecordedObjects().get(1).getTreePath().toString()); - assertEquals(2, matcher.getRecordedObjects().size()); - context.assertIsSatisfied(); - } - - @Test - public void testExpandProjectNodeInSampleChooser() - { - Object root = sampleChooserModel.getRoot(); - Object space1 = sampleChooserModel.getChild(root, 0); - RecordingMatcher<TreeModelEvent> matcher = prepareTreeStructureChanged(2); - sampleChooserModel.expandNode(createPath(sampleChooserModel, space1), nodeAction); - assertEquals(null, nodeAction.handledException); - Object project11 = sampleChooserModel.getChild(space1, 0); - prepareListExperiments(project11); - - sampleChooserModel.expandNode(createPath(sampleChooserModel, project11), nodeAction); - - assertEquals(null, nodeAction.handledException); - assertEquals(true, nodeAction.executed); - assertEquals(2, sampleChooserModel.getChildCount(project11)); - Object child1 = sampleChooserModel.getChild(project11, 0); - assertEquals(EXP_1, child1.toString()); - assertEquals(1, sampleChooserModel.getChildCount(child1)); - assertEquals(LOADING_TEXT, sampleChooserModel.getChild(child1, 0).toString()); - assertEquals(false, sampleChooserModel.isLeaf(child1)); - Object child2 = sampleChooserModel.getChild(project11, 1); - assertEquals(EXP_2, child2.toString()); - assertEquals(1, sampleChooserModel.getChildCount(child2)); - assertEquals(LOADING_TEXT, sampleChooserModel.getChild(child2, 0).toString()); - assertEquals(false, sampleChooserModel.isLeaf(child2)); - assertEquals(createPath(sampleChooserModel, space1).toString(), - matcher.getRecordedObjects().get(0).getTreePath().toString()); - assertEquals(createPath(sampleChooserModel, project11).toString(), - matcher.getRecordedObjects().get(1).getTreePath().toString()); - assertEquals(2, matcher.getRecordedObjects().size()); - context.assertIsSatisfied(); - } - - @Test - public void testCollapsProjectNode() - { - Object root = dataSetChooserModel.getRoot(); - Object space1 = dataSetChooserModel.getChild(root, 0); - prepareTreeStructureChanged(3); - dataSetChooserModel.expandNode(createPath(dataSetChooserModel, space1), nodeAction); - assertEquals(null, nodeAction.handledException); - Object project11 = dataSetChooserModel.getChild(space1, 0); - prepareListExperiments(project11); - TreePath path = createPath(dataSetChooserModel, project11); - dataSetChooserModel.expandNode(path, nodeAction); - assertEquals(null, nodeAction.handledException); - assertEquals(2, dataSetChooserModel.getChildCount(project11)); - - dataSetChooserModel.collapsNode(path); - - assertEquals(1, dataSetChooserModel.getChildCount(project11)); - assertEquals(LOADING_TEXT, dataSetChooserModel.getChild(project11, 0).toString()); - context.assertIsSatisfied(); - } - - @Test - public void testExpandExperimentNodeInSampleChooser() - { - Object root = sampleChooserModel.getRoot(); - Object space1 = sampleChooserModel.getChild(root, 0); - RecordingMatcher<TreeModelEvent> eventMatcher = prepareTreeStructureChanged(3); - sampleChooserModel.expandNode(createPath(sampleChooserModel, space1), nodeAction); - assertEquals(null, nodeAction.handledException); - Object project11 = sampleChooserModel.getChild(space1, 0); - prepareListExperiments(project11); - sampleChooserModel.expandNode(createPath(sampleChooserModel, project11), nodeAction); - assertEquals(null, nodeAction.handledException); - Object exp1 = sampleChooserModel.getChild(project11, 0); - assertEquals(EXP_1, exp1.toString()); - Sample sample = TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, SAMPLE_1); - prepareSearchForSamples(sample); - - sampleChooserModel.expandNode(createPath(sampleChooserModel, exp1), nodeAction); - - assertEquals(null, nodeAction.handledException); - assertEquals(true, nodeAction.executed); - List<TreeModelEvent> recordedObjects = eventMatcher.getRecordedObjects(); - assertEquals(createPath(sampleChooserModel, space1).toString(), - recordedObjects.get(0).getTreePath().toString()); - assertEquals(createPath(sampleChooserModel, project11).toString(), - recordedObjects.get(1).getTreePath().toString()); - assertEquals(createPath(sampleChooserModel, exp1).toString(), - recordedObjects.get(2).getTreePath().toString()); - assertEquals(3, recordedObjects.size()); - assertEquals("SearchCriteria[MATCH_ALL_CLAUSES,[" - + "SearchCriteria.AttributeMatchClause[ATTRIBUTE,TYPE,ST1,EQUALS]]," - + "[SearchSubCriteria[EXPERIMENT,SearchCriteria[MATCH_ALL_CLAUSES," - + "[SearchCriteria.AttributeMatchClause[ATTRIBUTE,PERM_ID," - + "PERM-/SP1/P1/EXP1,EQUALS]],[]]]]]", criteriaMatcher.recordedObject().toString()); - Object child = sampleChooserModel.getChild(exp1, 0); - IChooserTreeNode<?> childNodeObject = getTreeNode(child); - assertEquals(ChooserTreeNodeType.SAMPLE, childNodeObject.getNodeType()); - assertSame(sample, childNodeObject.getNodeObject()); - assertEquals(1, sampleChooserModel.getChildCount(exp1)); - assertEquals(LOADING_TEXT, sampleChooserModel.getChild(child, 0).toString()); - assertEquals(1, sampleChooserModel.getChildCount(child)); - context.assertIsSatisfied(); - } - - @Test - public void testExpandExperimentNodeInDataSetChooser() - { - Object root = dataSetChooserModel.getRoot(); - Object space1 = dataSetChooserModel.getChild(root, 0); - RecordingMatcher<TreeModelEvent> eventMatcher = prepareTreeStructureChanged(3); - dataSetChooserModel.expandNode(createPath(dataSetChooserModel, space1), nodeAction); - assertEquals(null, nodeAction.handledException); - Object project11 = dataSetChooserModel.getChild(space1, 0); - prepareListExperiments(project11); - dataSetChooserModel.expandNode(createPath(dataSetChooserModel, project11), nodeAction); - assertEquals(null, nodeAction.handledException); - Object exp1 = dataSetChooserModel.getChild(project11, 0); - assertEquals(EXP_1, exp1.toString()); - Sample sample = TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, SAMPLE_1); - prepareSearchForSamples(sample); - DataSet dataSet = TestUtils.dataSet("DS-1"); - prepareSearchForDataSets(dataSet); - - dataSetChooserModel.expandNode(createPath(dataSetChooserModel, exp1), nodeAction); - - assertEquals(null, nodeAction.handledException); - assertEquals(true, nodeAction.executed); - List<TreeModelEvent> recordedObjects = eventMatcher.getRecordedObjects(); - assertEquals(createPath(dataSetChooserModel, space1).toString(), - recordedObjects.get(0).getTreePath().toString()); - assertEquals(createPath(dataSetChooserModel, project11).toString(), - recordedObjects.get(1).getTreePath().toString()); - assertEquals(createPath(dataSetChooserModel, exp1).toString(), - recordedObjects.get(2).getTreePath().toString()); - assertEquals(3, recordedObjects.size()); - assertEquals("SearchCriteria[MATCH_ALL_CLAUSES,[" - + "SearchCriteria.AttributeMatchClause[ATTRIBUTE,TYPE,ST1,EQUALS]]," - + "[SearchSubCriteria[EXPERIMENT,SearchCriteria[MATCH_ALL_CLAUSES," - + "[SearchCriteria.AttributeMatchClause[ATTRIBUTE,PERM_ID," - + "PERM-/SP1/P1/EXP1,EQUALS]],[]]]]]", - criteriaMatcher.getRecordedObjects().get(0).toString()); - assertEquals("SearchCriteria[MATCH_ALL_CLAUSES,[],[SearchSubCriteria[EXPERIMENT," - + "SearchCriteria[MATCH_ALL_CLAUSES,[SearchCriteria.AttributeMatchClause[" - + "ATTRIBUTE,PERM_ID,PERM-/SP1/P1/EXP1,EQUALS]],[]]]]]", - criteriaMatcher.getRecordedObjects().get(1).toString()); - assertEquals(2, criteriaMatcher.getRecordedObjects().size()); - Object dataSetChild = dataSetChooserModel.getChild(exp1, 0); - IChooserTreeNode<?> dataSetObject = getTreeNode(dataSetChild); - assertEquals(ChooserTreeNodeType.DATA_SET, dataSetObject.getNodeType()); - assertSame(dataSet, dataSetObject.getNodeObject()); - assertEquals(true, dataSetChooserModel.isLeaf(dataSetChild)); - Object sampleChild = dataSetChooserModel.getChild(exp1, 1); - IChooserTreeNode<?> sampleObject = getTreeNode(sampleChild); - assertEquals(ChooserTreeNodeType.SAMPLE, sampleObject.getNodeType()); - assertSame(sample, sampleObject.getNodeObject()); - assertEquals(2, dataSetChooserModel.getChildCount(exp1)); - assertEquals(LOADING_TEXT, dataSetChooserModel.getChild(sampleChild, 0).toString()); - assertEquals(1, dataSetChooserModel.getChildCount(sampleChild)); - context.assertIsSatisfied(); - } - - @Test - public void testCollapsExperimentNode() - { - Object root = sampleChooserModel.getRoot(); - Object space1 = sampleChooserModel.getChild(root, 0); - prepareTreeStructureChanged(4); - sampleChooserModel.expandNode(createPath(sampleChooserModel, space1), nodeAction); - assertEquals(null, nodeAction.handledException); - Object project11 = sampleChooserModel.getChild(space1, 0); - prepareListExperiments(project11); - sampleChooserModel.expandNode(createPath(sampleChooserModel, project11), nodeAction); - assertEquals(null, nodeAction.handledException); - Object exp1 = sampleChooserModel.getChild(project11, 0); - assertEquals(EXP_1, exp1.toString()); - prepareSearchForSamples(TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, SAMPLE_2), - TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, SAMPLE_1)); - TreePath path = createPath(sampleChooserModel, exp1); - sampleChooserModel.expandNode(path, nodeAction); - assertEquals(null, nodeAction.handledException); - assertEquals(2, sampleChooserModel.getChildCount(exp1)); - - sampleChooserModel.collapsNode(path); - - assertEquals(1, sampleChooserModel.getChildCount(exp1)); - assertEquals(LOADING_TEXT, sampleChooserModel.getChild(exp1, 0).toString()); - context.assertIsSatisfied(); - } - - @Test - public void testExpandSampleNodeInSampleChooser() - { - Object root = sampleChooserModel.getRoot(); - Object space1 = sampleChooserModel.getChild(root, 0); - RecordingMatcher<TreeModelEvent> eventMatcher = prepareTreeStructureChanged(4); - sampleChooserModel.expandNode(createPath(sampleChooserModel, space1), nodeAction); - assertEquals(null, nodeAction.handledException); - Object project11 = sampleChooserModel.getChild(space1, 0); - prepareListExperiments(project11); - sampleChooserModel.expandNode(createPath(sampleChooserModel, project11), nodeAction); - assertEquals(null, nodeAction.handledException); - Object exp1 = sampleChooserModel.getChild(project11, 0); - prepareSearchForSamples(TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, SAMPLE_1)); - sampleChooserModel.expandNode(createPath(sampleChooserModel, exp1), nodeAction); - assertEquals(null, nodeAction.handledException); - Object sample1 = sampleChooserModel.getChild(exp1, 0); - String experimentIdentifier = "/" + SPACE_1 + "/" + P_1 + "/" + EXP_1; - Sample childSampleWithExperiment = - TestUtils.sample(NON_LISTABLE_SAMPLE_TYPE, SPACE_2, "CHILD_WE", experimentIdentifier); - Sample childSampleWithoutExperiment = TestUtils.sample(NON_LISTABLE_SAMPLE_TYPE, SPACE_2, "CHILD_WOE"); - prepareSearchForSamplesWithChildren(childSampleWithExperiment, childSampleWithoutExperiment); - Sample containedSampleWithoutExperiment = TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, "CONT_WOE"); - Sample containedSampleWithExperiment = - TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, "CONT_WE", experimentIdentifier); - prepareSearchForSamples(containedSampleWithExperiment, containedSampleWithoutExperiment); - - sampleChooserModel.expandNode(createPath(sampleChooserModel, sample1), nodeAction); - - assertEquals(null, nodeAction.handledException); - assertEquals(true, nodeAction.executed); - List<TreeModelEvent> recordedObjects = eventMatcher.getRecordedObjects(); - assertEquals(createPath(sampleChooserModel, space1).toString(), - recordedObjects.get(0).getTreePath().toString()); - assertEquals(createPath(sampleChooserModel, project11).toString(), - recordedObjects.get(1).getTreePath().toString()); - assertEquals(createPath(sampleChooserModel, exp1).toString(), - recordedObjects.get(2).getTreePath().toString()); - assertEquals(createPath(sampleChooserModel, sample1).toString(), - recordedObjects.get(3).getTreePath().toString()); - assertEquals(4, recordedObjects.size()); - assertEquals("SearchCriteria[MATCH_ALL_CLAUSES,[" - + "SearchCriteria.AttributeMatchClause[ATTRIBUTE,TYPE,ST1,EQUALS]]," - + "[SearchSubCriteria[EXPERIMENT,SearchCriteria[MATCH_ALL_CLAUSES," - + "[SearchCriteria.AttributeMatchClause[ATTRIBUTE,PERM_ID," - + "PERM-/SP1/P1/EXP1,EQUALS]],[]]]]]", - criteriaMatcher.getRecordedObjects().get(0).toString()); - assertEquals("SearchCriteria[MATCH_ALL_CLAUSES,[SearchCriteria.AttributeMatchClause[" - + "ATTRIBUTE,PERM_ID,PERM-/SP1/S1,EQUALS]],[]]", - criteriaMatcher.getRecordedObjects().get(1).toString()); - assertEquals("SearchCriteria[MATCH_ALL_CLAUSES,[],[SearchSubCriteria[SAMPLE_CONTAINER," - + "SearchCriteria[MATCH_ALL_CLAUSES,[SearchCriteria.AttributeMatchClause[" - + "ATTRIBUTE,PERM_ID,PERM-/SP1/S1,EQUALS]],[]]]]]", - criteriaMatcher.getRecordedObjects().get(2).toString()); - assertEquals(3, criteriaMatcher.getRecordedObjects().size()); - Object child = sampleChooserModel.getChild(exp1, 0); - Object child1 = sampleChooserModel.getChild(child, 0); - IChooserTreeNode<?> sampleNode1 = getTreeNode(child1); - assertEquals(ChooserTreeNodeType.SAMPLE, sampleNode1.getNodeType()); - assertSame(containedSampleWithExperiment, sampleNode1.getNodeObject()); - assertEquals(1, sampleChooserModel.getChildCount(child1)); - assertEquals(LOADING_TEXT, sampleChooserModel.getChild(child1, 0).toString()); - Object child2 = sampleChooserModel.getChild(child, 1); - IChooserTreeNode<?> sampleNode2 = getTreeNode(child2); - assertEquals(ChooserTreeNodeType.SAMPLE, sampleNode2.getNodeType()); - assertSame(childSampleWithExperiment, sampleNode2.getNodeObject()); - assertEquals(1, sampleChooserModel.getChildCount(child2)); - assertEquals(LOADING_TEXT, sampleChooserModel.getChild(child2, 0).toString()); - assertEquals(2, sampleChooserModel.getChildCount(child)); - context.assertIsSatisfied(); - } - - @Test - public void testExpandSampleNodeInDataSetChooser() - { - Object root = dataSetChooserModel.getRoot(); - Object space1 = dataSetChooserModel.getChild(root, 0); - RecordingMatcher<TreeModelEvent> eventMatcher = prepareTreeStructureChanged(4); - dataSetChooserModel.expandNode(createPath(dataSetChooserModel, space1), nodeAction); - assertEquals(null, nodeAction.handledException); - Object project11 = dataSetChooserModel.getChild(space1, 0); - prepareListExperiments(project11); - dataSetChooserModel.expandNode(createPath(dataSetChooserModel, project11), nodeAction); - assertEquals(null, nodeAction.handledException); - Object exp1 = dataSetChooserModel.getChild(project11, 0); - prepareSearchForSamples(TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, SAMPLE_1)); - prepareSearchForDataSets(); - dataSetChooserModel.expandNode(createPath(dataSetChooserModel, exp1), nodeAction); - assertEquals(null, nodeAction.handledException); - Object sample1 = dataSetChooserModel.getChild(exp1, 0); - String experimentIdentifier = "/" + SPACE_1 + "/" + P_1 + "/" + EXP_1; - prepareSearchForSamplesWithChildren(); - Sample containedSampleWithoutExperiment = TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, "CONT_WOE"); - Sample containedSampleWithExperiment = - TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, "CONT_WE", experimentIdentifier); - prepareSearchForSamples(containedSampleWithExperiment, containedSampleWithoutExperiment); - DataSet dataSet = TestUtils.dataSet("DS1"); - prepareSearchForDataSets(dataSet); - - dataSetChooserModel.expandNode(createPath(dataSetChooserModel, sample1), nodeAction); - - assertEquals(null, nodeAction.handledException); - assertEquals(true, nodeAction.executed); - List<TreeModelEvent> recordedObjects = eventMatcher.getRecordedObjects(); - assertEquals(createPath(dataSetChooserModel, space1).toString(), - recordedObjects.get(0).getTreePath().toString()); - assertEquals(createPath(dataSetChooserModel, project11).toString(), - recordedObjects.get(1).getTreePath().toString()); - assertEquals(createPath(dataSetChooserModel, exp1).toString(), - recordedObjects.get(2).getTreePath().toString()); - assertEquals(createPath(dataSetChooserModel, sample1).toString(), - recordedObjects.get(3).getTreePath().toString()); - assertEquals(4, recordedObjects.size()); - assertEquals("SearchCriteria[MATCH_ALL_CLAUSES,[" - + "SearchCriteria.AttributeMatchClause[ATTRIBUTE,TYPE,ST1,EQUALS]]," - + "[SearchSubCriteria[EXPERIMENT,SearchCriteria[MATCH_ALL_CLAUSES," - + "[SearchCriteria.AttributeMatchClause[ATTRIBUTE,PERM_ID," - + "PERM-/SP1/P1/EXP1,EQUALS]],[]]]]]", - criteriaMatcher.getRecordedObjects().get(0).toString()); - assertEquals("SearchCriteria[MATCH_ALL_CLAUSES,[],[SearchSubCriteria[EXPERIMENT," - + "SearchCriteria[MATCH_ALL_CLAUSES,[SearchCriteria.AttributeMatchClause[" - + "ATTRIBUTE,PERM_ID,PERM-/SP1/P1/EXP1,EQUALS]],[]]]]]", - criteriaMatcher.getRecordedObjects().get(1).toString()); - assertEquals("SearchCriteria[MATCH_ALL_CLAUSES,[SearchCriteria.AttributeMatchClause[" - + "ATTRIBUTE,PERM_ID,PERM-/SP1/S1,EQUALS]],[]]", - criteriaMatcher.getRecordedObjects().get(2).toString()); - assertEquals("SearchCriteria[MATCH_ALL_CLAUSES,[],[SearchSubCriteria[SAMPLE_CONTAINER," - + "SearchCriteria[MATCH_ALL_CLAUSES,[SearchCriteria.AttributeMatchClause[" - + "ATTRIBUTE,PERM_ID,PERM-/SP1/S1,EQUALS]],[]]]]]", - criteriaMatcher.getRecordedObjects().get(3).toString()); - assertEquals("SearchCriteria[MATCH_ALL_CLAUSES,[],[SearchSubCriteria[SAMPLE," - + "SearchCriteria[MATCH_ALL_CLAUSES,[SearchCriteria.AttributeMatchClause[" - + "ATTRIBUTE,PERM_ID,PERM-/SP1/S1,EQUALS]],[]]]]]", - criteriaMatcher.getRecordedObjects().get(4).toString()); - assertEquals(5, criteriaMatcher.getRecordedObjects().size()); - Object child = dataSetChooserModel.getChild(exp1, 0); - Object child1 = dataSetChooserModel.getChild(child, 0); - IChooserTreeNode<?> dataSetNode = getTreeNode(child1); - assertEquals(ChooserTreeNodeType.DATA_SET, dataSetNode.getNodeType()); - assertSame(dataSet, dataSetNode.getNodeObject()); - assertEquals(0, dataSetChooserModel.getChildCount(child1)); - assertEquals(true, dataSetChooserModel.isLeaf(child1)); - Object child2 = dataSetChooserModel.getChild(child, 1); - IChooserTreeNode<?> sampleNode2 = getTreeNode(child2); - assertEquals(ChooserTreeNodeType.SAMPLE, sampleNode2.getNodeType()); - assertSame(containedSampleWithExperiment, sampleNode2.getNodeObject()); - assertEquals(1, dataSetChooserModel.getChildCount(child2)); - assertEquals(LOADING_TEXT, dataSetChooserModel.getChild(child2, 0).toString()); - Object child3 = dataSetChooserModel.getChild(child, 2); - IChooserTreeNode<?> sampleNode3 = getTreeNode(child3); - assertEquals(ChooserTreeNodeType.SAMPLE, sampleNode3.getNodeType()); - assertSame(containedSampleWithoutExperiment, sampleNode3.getNodeObject()); - assertEquals(1, dataSetChooserModel.getChildCount(child3)); - assertEquals(LOADING_TEXT, dataSetChooserModel.getChild(child3, 0).toString()); - assertEquals(3, dataSetChooserModel.getChildCount(child)); - context.assertIsSatisfied(); - } - - @Test - public void testCollapsSampleNode() - { - Object root = sampleChooserModel.getRoot(); - Object space1 = sampleChooserModel.getChild(root, 0); - prepareTreeStructureChanged(5); - sampleChooserModel.expandNode(createPath(sampleChooserModel, space1), nodeAction); - assertEquals(null, nodeAction.handledException); - Object project11 = sampleChooserModel.getChild(space1, 0); - prepareListExperiments(project11); - sampleChooserModel.expandNode(createPath(sampleChooserModel, project11), nodeAction); - assertEquals(null, nodeAction.handledException); - Object exp1 = sampleChooserModel.getChild(project11, 0); - assertEquals(EXP_1, exp1.toString()); - prepareSearchForSamples(TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_1, SAMPLE_2)); - sampleChooserModel.expandNode(createPath(sampleChooserModel, exp1), nodeAction); - assertEquals(null, nodeAction.handledException); - Object sample1 = sampleChooserModel.getChild(exp1, 0); - String experimentIdentifier = "/" + SPACE_1 + "/" + P_1 + "/" + EXP_1; - Sample s1 = TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_2, SAMPLE_1, experimentIdentifier); - Sample s2 = TestUtils.sample(LISTABLE_SAMPLE_TYPE, SPACE_2, SAMPLE_2, experimentIdentifier); - prepareSearchForSamplesWithChildren(s2, s1); - prepareSearchForSamples(); - TreePath path = createPath(sampleChooserModel, sample1); - sampleChooserModel.expandNode(path, nodeAction); - assertEquals(null, nodeAction.handledException); - assertEquals(2, sampleChooserModel.getChildCount(sample1)); - - sampleChooserModel.collapsNode(path); - - assertEquals(1, sampleChooserModel.getChildCount(sample1)); - assertEquals(LOADING_TEXT, sampleChooserModel.getChild(sample1, 0).toString()); - context.assertIsSatisfied(); - } - - private void prepareSearchForSamplesWithChildren(final Sample... childSamples) - { - context.checking(new Expectations() - { - { - one(service).searchForSamples(with(SESSION_TOKEN), with(criteriaMatcher), - with(EnumSet.of(SampleFetchOption.CHILDREN))); - if (childSamples.length == 0) - { - will(returnValue(Arrays.asList())); - } else - { - will(returnValue(Arrays.asList(sampleWithChildren(childSamples)))); - } - inSequence(searchForSequence); - } - }); - } - - private void prepareSearchForSamples(final Sample... samples) - { - context.checking(new Expectations() - { - { - one(service).searchForSamples(with(SESSION_TOKEN), with(criteriaMatcher), - with(new IsNull<EnumSet<SampleFetchOption>>())); - will(returnValue(Arrays.asList(samples))); - inSequence(searchForSequence); - } - }); - } - - private void prepareSearchForDataSets(final DataSet... dataSets) - { - context.checking(new Expectations() - { - { - one(service).searchForDataSets(with(SESSION_TOKEN), with(criteriaMatcher)); - will(returnValue(Arrays.asList(dataSets))); - inSequence(searchForSequence); - } - }); - } - - private void prepareListExperiments(final Object projectObject) - { - context.checking(new Expectations() - { - { - Project project = getWrappedObject(projectObject); - one(service).listExperiments(SESSION_TOKEN, Arrays.asList(project), null); - will(returnValue(Arrays.asList(TestUtils.experiment(project, EXP_2), - TestUtils.experiment(project, EXP_1)))); - } - }); - } - - private RecordingMatcher<TreeModelEvent> prepareTreeStructureChanged(final int numberOfEvents) - { - final RecordingMatcher<TreeModelEvent> matcher = new RecordingMatcher<TreeModelEvent>(); - context.checking(new Expectations() - { - { - exactly(numberOfEvents).of(treeModelListener).treeStructureChanged( - with(matcher)); - } - }); - return matcher; - } - - private Sample sampleWithChildren(Sample... children) - { - SampleInitializer initializer = - TestUtils.createSampleInitializer(LISTABLE_SAMPLE_TYPE, SPACE_1, SAMPLE_2, null); - initializer.setRetrievedFetchOptions(EnumSet.of(SampleFetchOption.CHILDREN)); - initializer.setChildren(Arrays.asList(children)); - return new Sample(initializer); - } - - private IChooserTreeNode<?> getTreeNode(Object node) - { - return (IChooserTreeNode<?>) ((DefaultMutableTreeNode) node).getUserObject(); - } - - @SuppressWarnings("unchecked") - private <T> T getWrappedObject(Object node) - { - return ((IChooserTreeNode<T>) ((DefaultMutableTreeNode) node).getUserObject()).getNodeObject(); - } - - private void assertSelectibility(boolean expected, ChooserTreeModel model, Object node) - { - assertEquals(expected, model.isSelectable(createPath(model, node))); - } - - private TreePath createPath(ChooserTreeModel model, Object node) - { - return new TreePath(model.getPathToRoot((TreeNode) node)); - } - -} diff --git a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/common/TestUtils.java b/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/common/TestUtils.java deleted file mode 100644 index 2542100494869e0b2c5c1ce5fd58bf8459aafa81..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/common/TestUtils.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.DataSetInitializer; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.EntityRegistrationDetails; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.EntityRegistrationDetails.EntityRegistrationDetailsInitializer; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment.ExperimentInitializer; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample.SampleInitializer; - -/** - * @author Franz-Josef Elmer - */ -public class TestUtils -{ - - public static DataSet dataSet(String code) - { - DataSetInitializer initializer = new DataSetInitializer(); - initializer.setDataSetTypeCode("DT"); - initializer.setCode(code); - initializer.setRegistrationDetails(registrationDetails()); - return new DataSet(initializer); - } - - public static Experiment experiment(Project project, String experimentCode) - { - return experiment(project.getIdentifier(), experimentCode); - } - - public static Experiment experiment(String projectIdentifier, String experimentCode) - { - ExperimentInitializer initializer = new ExperimentInitializer(); - initializer.setCode(experimentCode); - initializer.setExperimentTypeCode("ET"); - initializer.setIdentifier(projectIdentifier + "/" + experimentCode); - initializer.setPermId("PERM-" + initializer.getIdentifier()); - initializer.setId((long) initializer.getIdentifier().hashCode()); - initializer.setRegistrationDetails(registrationDetails()); - return new Experiment(initializer); - } - - public static SampleInitializer createSampleInitializer(String sampleTypeCode, String spaceCode, - String sampleCode, String experimentIdentifierOrNull) - { - SampleInitializer initializer = new SampleInitializer(); - initializer.setSampleTypeCode(sampleTypeCode); - initializer.setSampleTypeId(new Long(sampleTypeCode.hashCode())); - initializer.setCode(sampleCode); - initializer.setIdentifier("/" + spaceCode + "/" + sampleCode); - initializer.setPermId("PERM-" + initializer.getIdentifier()); - initializer.setId((long) initializer.getIdentifier().hashCode()); - initializer.setExperimentIdentifierOrNull(experimentIdentifierOrNull); - initializer.setRegistrationDetails(registrationDetails()); - return initializer; - } - - public static Sample sample(String sampleTypeCode, String spaceCode, String sampleCode, - String experimentIdentifierOrNull) - { - return new Sample(createSampleInitializer(sampleTypeCode, spaceCode, sampleCode, - experimentIdentifierOrNull)); - } - - public static Sample sample(String sampleTypeCode, String spaceCode, String sampleCode) - { - return sample(sampleTypeCode, spaceCode, sampleCode, null); - } - - private static EntityRegistrationDetails registrationDetails() - { - return new EntityRegistrationDetails(new EntityRegistrationDetailsInitializer()); - } - -} diff --git a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/common/UtilTest.java b/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/common/UtilTest.java deleted file mode 100644 index 163727c1285aafc3cba3a88d8ad01096d650ae5a..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/common/UtilTest.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.common; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Level; -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.knime.core.node.NodeLogger; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import ch.systemsx.cisd.common.logging.BufferedAppender; -import ch.systemsx.cisd.common.logging.LogInitializer; -import ch.systemsx.cisd.openbis.generic.shared.util.IRowBuilder; -import ch.systemsx.cisd.openbis.generic.shared.util.SimpleTableModelBuilder; -import ch.systemsx.cisd.openbis.knime.server.Constants; -import ch.systemsx.cisd.openbis.knime.server.FieldType; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.AggregationServiceDescription; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableModel; -import ch.systemsx.cisd.openbis.plugin.query.shared.translator.QueryTableModelTranslator; - -/** - * @author Franz-Josef Elmer - */ -public class UtilTest extends AssertJUnit -{ - private BufferedAppender logRecorder; - - private Mockery context; - - private IQueryApiFacade facade; - - private NodeLogger logger; - - private AggregatedDataImportDescription description; - - @BeforeMethod - public void beforeMethod() - { - LogInitializer.init(); - logRecorder = new BufferedAppender("%-5p %c - %m%n", Level.DEBUG); - context = new Mockery(); - facade = context.mock(IQueryApiFacade.class); - logger = NodeLogger.getLogger("test"); - AggregationServiceDescription desc = new AggregationServiceDescription(); - desc.setServiceKey(AggregatedDataImportDescription.PREFIX + "as"); - ArrayList<AggregatedDataImportDescription> descriptions = new ArrayList<AggregatedDataImportDescription>(); - AggregatedDataImportDescription.addDescriptionIfDataTable(descriptions, desc); - description = descriptions.get(0); - } - - @AfterMethod - public void afterMethod() - { - logRecorder.reset(); - // To following line of code should also be called at the end of each test method. - // Otherwise one do not known which test failed. - context.assertIsSatisfied(); - } - - @Test - public void testGetFieldDescriptionsWithEmptyTable() - { - SimpleTableModelBuilder builder = new SimpleTableModelBuilder(); - prepareCreateReport(builder); - - assertGetFieldDescriptionsFailed("0 columns instead of 2"); - - context.assertIsSatisfied(); - } - - @Test - public void testGetFieldDescriptionsWithOneColumn() - { - SimpleTableModelBuilder builder = new SimpleTableModelBuilder(); - builder.addHeader(Constants.PARAMETER_DESCRIPTION_NAME_COLUMN); - prepareCreateReport(builder); - - assertGetFieldDescriptionsFailed("1 columns instead of 2"); - - context.assertIsSatisfied(); - } - - @Test - public void testGetFieldDescriptionsWithWrongColumns() - { - SimpleTableModelBuilder builder = new SimpleTableModelBuilder(); - builder.addHeader(Constants.PARAMETER_DESCRIPTION_NAME_COLUMN); - builder.addHeader("blabla"); - prepareCreateReport(builder); - - assertGetFieldDescriptionsFailed("2. column is 'blabla' instead of 'type'."); - - context.assertIsSatisfied(); - } - - @Test - public void testGetFieldDescriptionsWithUnspecifiedName() - { - SimpleTableModelBuilder builder = new SimpleTableModelBuilder(true); - builder.addHeader(Constants.PARAMETER_DESCRIPTION_NAME_COLUMN); - builder.addHeader(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN); - builder.addRow(); - prepareCreateReport(builder); - - assertGetFieldDescriptionsFailed("Unspecified parameter name."); - - context.assertIsSatisfied(); - } - - @Test - public void testGetFieldDescriptionsWithUnspecifiedType() - { - SimpleTableModelBuilder builder = new SimpleTableModelBuilder(true); - builder.addHeader(Constants.PARAMETER_DESCRIPTION_NAME_COLUMN); - builder.addHeader(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN); - builder.addRow().setCell(Constants.PARAMETER_DESCRIPTION_NAME_COLUMN, "Description"); - IRowBuilder row = builder.addRow(); - row.setCell(Constants.PARAMETER_DESCRIPTION_NAME_COLUMN, "Greetings"); - row.setCell(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN, FieldType.VOCABULARY + ":Hi, Hello"); - prepareCreateReport(builder); - - List<FieldDescription> fieldDescriptions = Util.getFieldDescriptions(facade, description, logger); - - assertEquals("[Description:VARCHAR, Greetings:VOCABULARY[Hi, Hello]]", fieldDescriptions.toString()); - assertEquals("WARN test - Unknown field type '' using VARCHAR instead.", logRecorder.getLogContent()); - context.assertIsSatisfied(); - } - - private void assertGetFieldDescriptionsFailed(String expectedMessage) - { - try - { - Util.getFieldDescriptions(facade, description, logger); - fail("IllegalArgumentException expected."); - } catch (IllegalArgumentException ex) - { - String serviceKey = description.getAggregationServiceDescription().getServiceKey(); - assertEquals("Invalid response of aggregation service '" + serviceKey + "' when invoked with parameter " - + Constants.REQUEST_KEY + " = " + Constants.GET_PARAMETER_DESCRIPTIONS_REQUEST + ":\n" + - expectedMessage, ex.getMessage()); - } - } - - private void prepareCreateReport(SimpleTableModelBuilder builder) - { - final QueryTableModel tableModel = new QueryTableModelTranslator(builder.getTableModel()).translate(); - context.checking(new Expectations() - { - { - Map<String, Object> parameters = new HashMap<String, Object>(); - parameters.put(Constants.REQUEST_KEY, Constants.GET_PARAMETER_DESCRIPTIONS_REQUEST); - - one(facade).createReportFromAggregationService(description.getAggregationServiceDescription(), parameters); - will(returnValue(tableModel)); - } - }); - } - -} diff --git a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeModelTest.java b/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeModelTest.java deleted file mode 100644 index 3cedb80bb843138ca3170a919aa191fa65d2c77b..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/file/AggregatedDataFileImportNodeModelTest.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.TreeMap; - -import org.apache.log4j.Level; -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.knime.core.node.NodeSettingsRO; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase; -import ch.systemsx.cisd.common.filesystem.FileUtilities; -import ch.systemsx.cisd.common.logging.BufferedAppender; -import ch.systemsx.cisd.common.logging.LogInitializer; -import ch.systemsx.cisd.common.test.RecordingMatcher; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataStore; -import ch.systemsx.cisd.openbis.generic.shared.util.SimpleTableModelBuilder; -import ch.systemsx.cisd.openbis.knime.common.AggregatedDataImportDescription; -import ch.systemsx.cisd.openbis.knime.common.ParameterBindings; -import ch.systemsx.cisd.openbis.knime.common.Util; -import ch.systemsx.cisd.openbis.knime.server.Constants; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.AggregationServiceDescription; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableModel; -import ch.systemsx.cisd.openbis.plugin.query.shared.translator.QueryTableModelTranslator; - -/** - * @author Franz-Josef Elmer - */ -public class AggregatedDataFileImportNodeModelTest extends AbstractFileSystemTestCase -{ - private static final String SESSION_TOKEN = "session"; - - private static final String DATA_STORE_CODE = "DS"; - - private static final class MockAggregatedDataFileImportNodeModel extends AggregatedDataFileImportNodeModel - { - private final Map<String, String> flowVariables = new TreeMap<String, String>(); - - private final IQueryApiFacade facade; - - private final File sysTempDir; - - MockAggregatedDataFileImportNodeModel(IQueryApiFacade facade, File sysTempDir) - { - this.facade = facade; - this.sysTempDir = sysTempDir; - } - - @Override - protected File getSystemTempDir() - { - return sysTempDir; - } - - @Override - protected IQueryApiFacade createQueryFacade() - { - return facade; - } - - @Override - protected void addFlowVariable(String name, String value) - { - flowVariables.put(name, value); - } - - } - - private BufferedAppender logRecorder; - - private Mockery context; - - private IQueryApiFacade facade; - - private IGeneralInformationService service; - - private File tempDir; - - private MockAggregatedDataFileImportNodeModel model; - - private NodeSettingsRO nodeSettingsRO; - - private AggregationServiceDescription description; - - @BeforeMethod - public void setUpModel() throws Exception - { - LogInitializer.init(); - logRecorder = new BufferedAppender("%-5p %c - %m%n", Level.DEBUG); - context = new Mockery(); - service = context.mock(IGeneralInformationService.class); - facade = context.mock(IQueryApiFacade.class); - nodeSettingsRO = context.mock(NodeSettingsRO.class); - description = new AggregationServiceDescription(); - description.setDataStoreCode(DATA_STORE_CODE); - description.setServiceKey(AggregatedDataImportDescription.PREFIX + "as"); - ArrayList<AggregatedDataImportDescription> descriptions = new ArrayList<AggregatedDataImportDescription>(); - AggregatedDataImportDescription.addDescriptionIfDataTable(descriptions, description); - final byte[] bytes = Util.serializeDescription(descriptions.get(0)); - context.checking(new Expectations() - { - { - allowing(nodeSettingsRO).getByteArray(AggregatedDataImportDescription.AGGREGATION_DESCRIPTION_KEY); - will(returnValue(bytes)); - - allowing(nodeSettingsRO).getStringArray(ParameterBindings.PARAMETER_KEYS_KEY); - allowing(nodeSettingsRO).getStringArray(ParameterBindings.PARAMETER_VALUES_KEY); - - allowing(facade).getSessionToken(); - will(returnValue(SESSION_TOKEN)); - - allowing(facade).getGeneralInformationService(); - will(returnValue(service)); - } - }); - tempDir = new File(workingDirectory, "temp"); - model = new MockAggregatedDataFileImportNodeModel(facade, tempDir); - File reportFile = new File(workingDirectory, "session_workspace_file_download"); - FileUtilities.writeToFile(reportFile, "hello world"); - } - - @AfterMethod - public void afterMethod() - { - logRecorder.reset(); - // To following line of code should also be called at the end of each test method. - // Otherwise one do not known which test failed. - context.assertIsSatisfied(); - } - - @Test - public void testExecute() throws Exception - { - final RecordingMatcher<AggregationServiceDescription> descriptionRecorder = new RecordingMatcher<AggregationServiceDescription>(); - SimpleTableModelBuilder builder = new SimpleTableModelBuilder(true); - builder.addHeader(Constants.FILE_NAME_COLUMN); - builder.addRow().setCell(Constants.FILE_NAME_COLUMN, "report.txt"); - final QueryTableModel tableModel = new QueryTableModelTranslator(builder.getTableModel()).translate(); - context.checking(new Expectations() - { - { - one(facade).createReportFromAggregationService(with(descriptionRecorder), with(new HashMap<String, Object>())); - will(returnValue(tableModel)); - - one(facade).logout(); - - one(service).listDataStores(SESSION_TOKEN); - DataStore dataStore = new DataStore(DATA_STORE_CODE, "file://" + workingDirectory.getAbsolutePath(), ""); - will(returnValue(Arrays.asList(dataStore))); - } - }); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - logRecorder.resetLogContent(); - - model.execute(null, null); - - assertEquals("AggregationServiceDescription [dataStoreCode=DS, serviceKey=knime-as, label=null, type=null]", - descriptionRecorder.recordedObject().toString()); - assertEquals("hello world", FileUtilities.loadToString(new File(tempDir, "knime-openbis-session/report.txt")).trim()); - assertEquals("INFO " + MockAggregatedDataFileImportNodeModel.class.getName() - + " - Content MIME type: text/plain", logRecorder.getLogContent()); - assertEquals(new File(tempDir, "knime-openbis-session/report.txt").getAbsolutePath(), - model.flowVariables.get(AggregatedDataFileImportNodeModel.FILE_PATH_FLOW_VARIABLE)); - context.assertIsSatisfied(); - } - -} diff --git a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeModelTest.java b/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeModelTest.java deleted file mode 100644 index 93dc58bdbf9fa81ec59366547e1418622516dee5..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/file/DataSetFileImportNodeModelTest.java +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Copyright 2012 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.TreeMap; - -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.knime.core.data.uri.URIContent; -import org.knime.core.data.uri.URIPortObject; -import org.knime.core.data.uri.URIPortObjectSpec; -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettings; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; -import org.knime.core.node.port.PortObject; -import org.knime.core.node.port.PortObjectSpec; -import org.knime.core.node.workflow.Credentials; -import org.knime.core.node.workflow.ICredentials; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase; -import ch.systemsx.cisd.common.filesystem.FileUtilities; -import ch.systemsx.cisd.common.logging.LogInitializer; -import ch.systemsx.cisd.openbis.dss.client.api.v1.DataSet; -import ch.systemsx.cisd.openbis.dss.client.api.v1.IDataSetDss; -import ch.systemsx.cisd.openbis.dss.client.api.v1.IDssComponent; -import ch.systemsx.cisd.openbis.dss.client.api.v1.IOpenbisServiceFacade; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.DataSetInitializer; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.EntityRegistrationDetails; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.EntityRegistrationDetails.EntityRegistrationDetailsInitializer; -import ch.systemsx.cisd.openbis.knime.common.AbstractOpenBisNodeModel; -import ch.systemsx.cisd.openbis.knime.common.IOpenbisServiceFacadeFactory; - -/** - * @author Franz-Josef Elmer - */ -public class DataSetFileImportNodeModelTest extends AbstractFileSystemTestCase -{ - private static final String FILE_PATH = "document.txt"; - - private static final String DATA_SET_CODE = "DS-42"; - - private static final String MY_PASSWORD = "my-password"; - - private static final String MY_PASSWORD2 = "my-password2"; - - private static final String CREDENTIALS_NAME = "my-credentials"; - - private static final String USER = "albert"; - - private static final String USER2 = "isaac"; - - private static final String URL = "https://open.bis"; - - private static final class Model extends DataSetFileImportNodeModel - { - private final Map<String, String> flowVariables = new TreeMap<String, String>(); - - private final Map<String, ICredentials> credentialsMap = new HashMap<String, ICredentials>(); - - public Model(IOpenbisServiceFacadeFactory factory) - { - super(factory); - } - - @Override - protected void loadValidatedSettingsFrom(NodeSettingsRO settings) - throws InvalidSettingsException - { - super.loadValidatedSettingsFrom(settings); - } - - @Override - protected void saveSettingsTo(NodeSettingsWO settings) - { - super.saveSettingsTo(settings); - } - - @Override - protected void addFlowVariable(String name, String value) - { - flowVariables.put(name, value); - } - - void addCredentials(String name, ICredentials credentials) - { - credentialsMap.put(name, credentials); - } - - @Override - protected ICredentials getCredentials(String name) - { - return credentialsMap.get(name); - } - - String getUrl() - { - return url; - } - - String getUserId() - { - return userID; - } - - String getPassword() - { - return password; - } - } - - private Mockery context; - - private IOpenbisServiceFacadeFactory facadeFactory; - - private Model model; - - private NodeSettingsRO nodeSettingsRO; - - private NodeSettingsWO nodeSettingsWO; - - private IOpenbisServiceFacade facade; - - private IDssComponent dssComponent; - - private IDataSetDss dataSetDss; - - private ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet metadata; - - private DataSet dataSet; - - @BeforeMethod - public void beforeMethod() - { - LogInitializer.init(); - context = new Mockery(); - facadeFactory = context.mock(IOpenbisServiceFacadeFactory.class); - nodeSettingsRO = context.mock(NodeSettingsRO.class); - nodeSettingsWO = context.mock(NodeSettingsWO.class); - dataSetDss = context.mock(IDataSetDss.class); - facade = context.mock(IOpenbisServiceFacade.class); - DataSetInitializer dataSetInitializer = new DataSetInitializer(); - dataSetInitializer.setCode(DATA_SET_CODE); - dataSetInitializer.setDataSetTypeCode("MY-TYPE"); - EntityRegistrationDetailsInitializer regDetailsInit = - new EntityRegistrationDetailsInitializer(); - dataSetInitializer.setRegistrationDetails(new EntityRegistrationDetails(regDetailsInit)); - dataSetInitializer.setExperimentIdentifier("/A/B/C"); - dataSetInitializer.setSampleIdentifierOrNull("/A/B"); - metadata = new ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet(dataSetInitializer); - model = new Model(facadeFactory); - model.addCredentials(CREDENTIALS_NAME, new Credentials(CREDENTIALS_NAME, USER2, MY_PASSWORD2)); - dataSet = new DataSet(facade, dssComponent, metadata, dataSetDss); - context.checking(new Expectations() - { - { - allowing(dataSetDss).getCode(); - will(returnValue(DATA_SET_CODE)); - - allowing(facade).getDataSet(DATA_SET_CODE); - will(returnValue(dataSet)); - } - }); - } - - @AfterMethod - public void afterMethod() - { - // To following line of code should also be called at the end of each test method. - // Otherwise one do not known which test failed. - context.assertIsSatisfied(); - } - - @Test - public void testLoadingAndSavingSettingsWithCredentials() throws InvalidSettingsException - { - prepareLoadSaveStringSetting(AbstractOpenBisNodeModel.URL_KEY, URL); - prepareLoadSaveStringSetting(AbstractOpenBisNodeModel.CREDENTIALS_KEY, CREDENTIALS_NAME, ""); - prepareLoadSaveStringSetting(DataSetFileImportNodeModel.DATA_SET_CODE_KEY, DATA_SET_CODE); - prepareLoadSaveStringSetting(DataSetFileImportNodeModel.FILE_PATH_KEY, FILE_PATH); - prepareLoadSaveStringSetting(DataSetFileImportNodeModel.DOWNLOADS_PATH_KEY, workingDirectory.getAbsolutePath()); - prepareSaveStringSetting(DataSetFileImportNodeModel.ABSOLUTE_FILE_PATH_KEY, - new File(workingDirectory, DATA_SET_CODE + "/" + FILE_PATH).getAbsolutePath()); - context.checking(new Expectations() - { - { - one(nodeSettingsRO).getBoolean(DataSetFileImportNodeModel.REUSE_FILE, false); - will(returnValue(true)); - - one(nodeSettingsWO).addBoolean(DataSetFileImportNodeModel.REUSE_FILE, true); - } - }); - - model.loadValidatedSettingsFrom(nodeSettingsRO); - model.saveSettingsTo(nodeSettingsWO); - - assertEquals(URL, model.getUrl()); - assertEquals(USER2, model.getUserId()); - assertEquals(MY_PASSWORD2, model.getPassword()); - context.assertIsSatisfied(); - } - - @Test - public void testLoadingAndSavingSettingsWithUserAndPassword() throws InvalidSettingsException - { - prepareLoadSaveStringSetting(AbstractOpenBisNodeModel.URL_KEY, URL); - prepareLoadSaveStringSetting(AbstractOpenBisNodeModel.CREDENTIALS_KEY, "", ""); - prepareLoadSaveStringSetting(AbstractOpenBisNodeModel.USER_KEY, USER); - prepareLoadSaveStringSetting(AbstractOpenBisNodeModel.PASSWORD_KEY, MY_PASSWORD, ""); - prepareLoadSaveStringSetting(DataSetFileImportNodeModel.DATA_SET_CODE_KEY, DATA_SET_CODE); - prepareLoadSaveStringSetting(DataSetFileImportNodeModel.FILE_PATH_KEY, FILE_PATH); - prepareLoadSaveStringSetting(DataSetFileImportNodeModel.DOWNLOADS_PATH_KEY, workingDirectory.getAbsolutePath()); - prepareSaveStringSetting(DataSetFileImportNodeModel.ABSOLUTE_FILE_PATH_KEY, - new File(workingDirectory, DATA_SET_CODE + "/" + FILE_PATH).getAbsolutePath()); - context.checking(new Expectations() - { - { - one(nodeSettingsRO).getBoolean(DataSetFileImportNodeModel.REUSE_FILE, false); - will(returnValue(true)); - - one(nodeSettingsWO).addBoolean(DataSetFileImportNodeModel.REUSE_FILE, true); - } - }); - - model.loadValidatedSettingsFrom(nodeSettingsRO); - model.saveSettingsTo(nodeSettingsWO); - - assertEquals(URL, model.getUrl()); - assertEquals(USER, model.getUserId()); - assertEquals(MY_PASSWORD, model.getPassword()); - context.assertIsSatisfied(); - } - - @Test - public void testConfigure() throws Exception - { - NodeSettings settings = createSettings(); - model.loadValidatedSettingsFrom(settings); - - PortObjectSpec[] portSpecs = model.configure(null); - - assertEquals("[text/plain]", ((URIPortObjectSpec) portSpecs[0]) - .getFileExtensions().toString()); - assertEquals(1, portSpecs.length); - context.assertIsSatisfied(); - } - - @Test - public void testExecuteReuseFile() throws Exception - { - NodeSettings settings = createSettings(); - settings.addBoolean(DataSetFileImportNodeModel.REUSE_FILE, true); - model.loadValidatedSettingsFrom(settings); - File file = new File(workingDirectory, DATA_SET_CODE + "/" + FILE_PATH); - file.getParentFile().mkdirs(); - FileUtilities.writeToFile(file, "hello world"); - - PortObject[] portObjects = model.execute(null, null); - - URIPortObject uriPortObject = (URIPortObject) portObjects[0]; - assertEquals("[text/plain]", uriPortObject.getSpec().getFileExtensions().toString()); - List<URIContent> uriContents = uriPortObject.getURIContents(); - assertEquals(file.toURI().toString(), uriContents.get(0).getURI().toString()); - assertEquals(1, uriContents.size()); - assertEquals(1, portObjects.length); - context.assertIsSatisfied(); - } - - @Test - public void testExecuteReuseFileButFileDoesNotExist() throws Exception - { - NodeSettings settings = createSettings(); - settings.addBoolean(DataSetFileImportNodeModel.REUSE_FILE, true); - model.loadValidatedSettingsFrom(settings); - File file = new File(workingDirectory, DATA_SET_CODE + "/" + FILE_PATH); - prepareGetDataSetFile(FILE_PATH, new ByteArrayInputStream("hello world".getBytes())); - - PortObject[] portObjects = model.execute(null, null); - - assertEquals("hello world", FileUtilities.loadToString(file).trim()); - URIPortObject uriPortObject = (URIPortObject) portObjects[0]; - assertEquals("[text/plain]", uriPortObject.getSpec().getFileExtensions().toString()); - List<URIContent> uriContents = uriPortObject.getURIContents(); - assertEquals(file.toURI().toString(), uriContents.get(0).getURI().toString()); - assertEquals(1, uriContents.size()); - assertEquals(1, portObjects.length); - assertEquals("{openbis.DATA_SET=DS-42, openbis.EXPERIMENT=/A/B/C, openbis.SAMPLE=/A/B}", - model.flowVariables.toString()); - context.assertIsSatisfied(); - } - - @Test - public void testExecuteDoNotReuseFile() throws Exception - { - NodeSettings settings = createSettings(); - settings.addBoolean(DataSetFileImportNodeModel.REUSE_FILE, false); - model.loadValidatedSettingsFrom(settings); - File file = new File(workingDirectory, DATA_SET_CODE + "/" + FILE_PATH); - file.getParentFile().mkdirs(); - FileUtilities.writeToFile(file, "hello world"); - StringBuilder builder = new StringBuilder(); - Random random = new Random(); - for (int i = 0; i < 1200; i++) - { - builder.append(random.nextInt(5)); - } - String exampleContent = builder.toString(); - prepareGetDataSetFile(FILE_PATH, new ByteArrayInputStream(exampleContent.getBytes())); - - PortObject[] portObjects = model.execute(null, null); - - assertEquals(exampleContent, FileUtilities.loadToString(file).trim()); - URIPortObject uriPortObject = (URIPortObject) portObjects[0]; - assertEquals("[text/plain]", uriPortObject.getSpec().getFileExtensions().toString()); - List<URIContent> uriContents = uriPortObject.getURIContents(); - assertEquals(file.toURI().toString(), uriContents.get(0).getURI().toString()); - assertEquals(1, uriContents.size()); - assertEquals(1, portObjects.length); - context.assertIsSatisfied(); - } - - private NodeSettings createSettings() - { - NodeSettings settings = new NodeSettings("test"); - settings.addString(AbstractOpenBisNodeModel.URL_KEY, URL); - settings.addString(AbstractOpenBisNodeModel.USER_KEY, USER); - settings.addString(AbstractOpenBisNodeModel.PASSWORD_KEY, MY_PASSWORD); - settings.addString(DataSetFileImportNodeModel.DATA_SET_CODE_KEY, DATA_SET_CODE); - settings.addString(DataSetFileImportNodeModel.FILE_PATH_KEY, FILE_PATH); - settings.addString(DataSetFileImportNodeModel.DOWNLOADS_PATH_KEY, workingDirectory.getAbsolutePath()); - return settings; - } - - private void prepareGetDataSetFile(final String filePath, final InputStream inputStream) - { - context.checking(new Expectations() - { - { - one(facadeFactory).createFacade(URL, USER, MY_PASSWORD); - will(returnValue(facade)); - - one(dataSetDss).getFile(filePath); - will(returnValue(inputStream)); - - one(facade).logout(); - } - }); - } - - private void prepareLoadSaveStringSetting(final String key, final String value) - throws InvalidSettingsException - { - context.checking(new Expectations() - { - { - one(nodeSettingsRO).getString(key); - will(returnValue(value)); - - one(nodeSettingsWO).addString(key, value); - } - }); - } - - private void prepareSaveStringSetting(final String key, final String value) - throws InvalidSettingsException - { - context.checking(new Expectations() - { - { - one(nodeSettingsWO).addString(key, value); - } - }); - } - - private void prepareLoadSaveStringSetting(final String key, final String value, - final String defaultValue) throws InvalidSettingsException - { - context.checking(new Expectations() - { - { - one(nodeSettingsRO).getString(key, defaultValue); - will(returnValue(value)); - - one(nodeSettingsWO).addString(key, value); - } - }); - } - -} diff --git a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeModelTest.java b/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeModelTest.java deleted file mode 100644 index 638edb94dae27630c010bd7b91432fcb2991ab1c..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/file/DataSetRegistrationNodeModelTest.java +++ /dev/null @@ -1,615 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.file; - -import java.io.File; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.NoSuchElementException; - -import org.apache.log4j.Level; -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.knime.core.data.uri.URIContent; -import org.knime.core.data.uri.URIPortObject; -import org.knime.core.node.InvalidSettingsException; -import org.knime.core.node.NodeSettingsRO; -import org.knime.core.node.NodeSettingsWO; -import org.knime.core.node.port.PortObject; -import org.knime.core.node.port.flowvariable.FlowVariablePortObject; -import org.knime.core.node.port.image.ImagePortObject; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase; -import ch.systemsx.cisd.common.filesystem.FileUtilities; -import ch.systemsx.cisd.common.logging.BufferedAppender; -import ch.systemsx.cisd.common.logging.LogInitializer; -import ch.systemsx.cisd.common.test.RecordingMatcher; -import ch.systemsx.cisd.openbis.dss.client.api.v1.DataSet; -import ch.systemsx.cisd.openbis.dss.client.api.v1.IOpenbisServiceFacade; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwnerType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType.DataSetTypeInitializer; -import ch.systemsx.cisd.openbis.knime.common.IOpenbisServiceFacadeFactory; -import ch.systemsx.cisd.openbis.knime.common.TestUtils; -import ch.systemsx.cisd.openbis.knime.common.Util; -import ch.systemsx.cisd.openbis.plugin.query.client.api.v1.IQueryApiFacade; - -/** - * @author Franz-Josef Elmer - */ -public class DataSetRegistrationNodeModelTest extends AbstractFileSystemTestCase -{ - private static final class MockDataSetRegistrationNodeModel extends DataSetRegistrationNodeModel - { - private final IQueryApiFacade queryFacade; - - private final Map<String, String> flowVariables; - - public MockDataSetRegistrationNodeModel(IQueryApiFacade queryFacade, - IOpenbisServiceFacadeFactory serviceFacadeFactory, Map<String, String> flowVariables) - { - super(serviceFacadeFactory); - this.queryFacade = queryFacade; - this.flowVariables = flowVariables; - } - - @Override - protected IQueryApiFacade createQueryFacade() - { - return queryFacade; - } - - @Override - protected String getStringFlowVariable(String variableName) - { - String value = flowVariables.get(variableName); - if (value == null) - { - throw new NoSuchElementException(variableName); - } - return value; - } - } - - private BufferedAppender logRecorder; - - private Mockery context; - - private IOpenbisServiceFacadeFactory facadeFactory; - - private IOpenbisServiceFacade serviceFacade; - - private IQueryApiFacade queryFacade; - - private MockDataSetRegistrationNodeModel model; - - private NodeSettingsRO nodeSettingsRO; - - private NodeSettingsWO nodeSettingsWO; - - private File file; - - private Map<String, String> flowVariables; - - private DataSetType dataSetType; - - @BeforeMethod - public void beforeMethod() throws Exception - { - LogInitializer.init(); - context = new Mockery(); - facadeFactory = context.mock(IOpenbisServiceFacadeFactory.class); - serviceFacade = context.mock(IOpenbisServiceFacade.class); - queryFacade = context.mock(IQueryApiFacade.class); - nodeSettingsRO = context.mock(NodeSettingsRO.class); - nodeSettingsWO = context.mock(NodeSettingsWO.class); - DataSetTypeInitializer dataSetTypeInitializer = new DataSetTypeInitializer(); - dataSetTypeInitializer.setCode("MY_TYPE"); - dataSetType = new DataSetType(dataSetTypeInitializer); - final byte[] bytes = Util.serializeDescription(dataSetType); - context.checking(new Expectations() - { - { - allowing(nodeSettingsRO).getByteArray(DataSetRegistrationNodeModel.DATA_SET_TYPE_KEY, null); - will(returnValue(bytes)); - - allowing(facadeFactory).createFacade(null, null, null); - will(returnValue(serviceFacade)); - - allowing(queryFacade).logout(); - allowing(serviceFacade).logout(); - } - }); - flowVariables = new HashMap<String, String>(); - model = new MockDataSetRegistrationNodeModel(queryFacade, facadeFactory, flowVariables); - file = new File(workingDirectory, "hello.txt"); - FileUtilities.writeToFile(file, "hello"); - logRecorder = new BufferedAppender("%-5p %c - %m%n", Level.DEBUG); - } - - @AfterMethod - public void afterMethod() - { - logRecorder.reset(); - // To following line of code should also be called at the end of each test method. - // Otherwise one do not known which test failed. - context.assertIsSatisfied(); - } - - @Test - public void testSaveAdditionalSettingsTo() throws Exception - { - prepareFileVariableOwnerAndType(DataSetOwnerType.SAMPLE, "/SPACE/SAMPLE1", "fname"); - preparePropertyTypeCodes("Name"); - preparePropertyValues("Albert"); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - context.checking(new Expectations() - { - { - one(nodeSettingsWO).addString(DataSetRegistrationNodeModel.FILE_VARIABLE_KEY, "fname"); - one(nodeSettingsWO).addString(DataSetRegistrationNodeModel.OWNER_TYPE_KEY, DataSetOwnerType.SAMPLE.name()); - one(nodeSettingsWO).addString(DataSetRegistrationNodeModel.OWNER_KEY, "/SPACE/SAMPLE1"); - one(nodeSettingsWO).addByteArray(DataSetRegistrationNodeModel.DATA_SET_TYPE_KEY, Util.serializeDescription(dataSetType)); - one(nodeSettingsWO).addStringArray(DataSetRegistrationNodeModel.PROPERTY_TYPE_CODES_KEY, "Name"); - one(nodeSettingsWO).addStringArray(DataSetRegistrationNodeModel.PROPERTY_VALUES_KEY, "Albert"); - } - }); - - model.saveAdditionalSettingsTo(nodeSettingsWO); - - context.assertIsSatisfied(); - } - - @Test - public void testExecuteWithInvalidNumberOfInputPorts() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.SAMPLE, "/SPACE/SAMPLE1"); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - logRecorder.resetLogContent(); - - try - { - model.execute(new PortObject[2], null); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) - { - assertEquals("Expecting exactly one port instead of 2.", ex.getMessage()); - } - - assertEquals("", logRecorder.getLogContent()); - context.assertIsSatisfied(); - } - - @Test - public void testExecuteWithInvalidInputPortType() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.SAMPLE, "/SPACE/SAMPLE1"); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - logRecorder.resetLogContent(); - - try - { - model.execute(new PortObject[] { new ImagePortObject() }, null); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) - { - assertEquals("Invalid port: " + ImagePortObject.class.getName() + ".", ex.getMessage()); - } - - assertEquals("", logRecorder.getLogContent()); - context.assertIsSatisfied(); - } - - @Test - public void testExecuteWithNoUriContent() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.SAMPLE, "/SPACE/SAMPLE1"); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - logRecorder.resetLogContent(); - - try - { - model.execute(new PortObject[] { new URIPortObject(Arrays.<URIContent> asList()) }, null); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) - { - assertEquals("Expecting at least on URI in input port.", ex.getMessage()); - } - - assertEquals("", logRecorder.getLogContent()); - context.assertIsSatisfied(); - } - - @Test - public void testExecuteWithUnspecifiedFileVariable() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.SAMPLE, "/SPACE/SAMPLE1"); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - logRecorder.resetLogContent(); - - try - { - model.execute(new PortObject[] { FlowVariablePortObject.INSTANCE }, null); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException ex) - { - assertEquals("Unspecified file variable.", ex.getMessage()); - } - - assertEquals("", logRecorder.getLogContent()); - context.assertIsSatisfied(); - } - - @Test - public void testExecuteForUnknownExperimentOwner() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.EXPERIMENT, "/SPACE/PROJECT/EXPERIMENT1"); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - context.checking(new Expectations() - { - { - one(serviceFacade).getExperiments(Arrays.asList("/SPACE/PROJECT/EXPERIMENT1")); - will(returnValue(Arrays.asList())); - } - }); - - try - { - URIContent content = new URIContent(file.toURI(), "txt"); - model.execute(new PortObject[] { new URIPortObject(Arrays.asList(content)) }, null); - } catch (IllegalArgumentException ex) - { - assertEquals("Error for data set owner of type experiment " - + "'/SPACE/PROJECT/EXPERIMENT1': Unknown experiment.", ex.getMessage()); - } - - context.assertIsSatisfied(); - } - - @Test - public void testExecuteForExperimentOwner() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.EXPERIMENT, "/SPACE/PROJECT/EXPERIMENT1"); - preparePropertyTypeCodes("GREETINGS"); - preparePropertyValues("HI"); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - final RecordingMatcher<NewDataSetDTO> dataSetMatcher = new RecordingMatcher<NewDataSetDTO>(); - final RecordingMatcher<File> fileMatcher = new RecordingMatcher<File>(); - context.checking(new Expectations() - { - { - one(serviceFacade).getExperiments(Arrays.asList("/SPACE/PROJECT/EXPERIMENT1")); - will(returnValue(Arrays.asList(TestUtils.experiment("/SPACE/PROJECT", "EXPERIMENT1")))); - - one(serviceFacade).putDataSet(with(dataSetMatcher), with(fileMatcher)); - } - }); - logRecorder.resetLogContent(); - - URIContent content = new URIContent(file.toURI(), "txt"); - URIContent content2 = new URIContent(file.getParentFile().toURI(), "txt"); - model.execute(new PortObject[] { new URIPortObject(Arrays.asList(content, content2)) }, null); - - assertEquals("NewDataSetDTO[NewDataSetMetadataDTO[data set type=MY_TYPE,property GREETINGS=HI]," - + "NewDataSetDTO.DataSetOwner[Experiment,/SPACE/PROJECT/EXPERIMENT1]," - + "[FileInfoDssDTO[hello.txt,hello.txt,5]]]", - dataSetMatcher.recordedObject().toString()); - assertEquals(file.getAbsolutePath(), fileMatcher.recordedObject().getAbsolutePath()); - assertEquals("WARN " + MockDataSetRegistrationNodeModel.class.getName() + " - 2 URIs instead of only one: [" - + "URI: " + file.toURI() + "; EXT: txt, URI: " + file.getParentFile().toURI() + "; EXT: txt]\n" - + "INFO " + MockDataSetRegistrationNodeModel.class.getName() + " - data set file: " - + file.getAbsolutePath(), logRecorder.getLogContent()); - context.assertIsSatisfied(); - } - - @Test - public void testExecuteForUnknownSampleOwner() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.SAMPLE, "/SPACE/SAMPLE1"); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - context.checking(new Expectations() - { - { - one(serviceFacade).getSamples(Arrays.asList("/SPACE/SAMPLE1")); - will(returnValue(Arrays.asList())); - } - }); - - try - { - URIContent content = new URIContent(file.toURI(), "txt"); - model.execute(new PortObject[] { new URIPortObject(Arrays.asList(content)) }, null); - } catch (IllegalArgumentException ex) - { - assertEquals("Error for data set owner of type sample " - + "'/SPACE/SAMPLE1': Unknown sample.", ex.getMessage()); - } - - context.assertIsSatisfied(); - } - - @Test - public void testExecuteForSampleOwnerNotLinkedToExperiment() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.SAMPLE, "/SPACE/SAMPLE1"); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - context.checking(new Expectations() - { - { - one(serviceFacade).getSamples(Arrays.asList("/SPACE/SAMPLE1")); - will(returnValue(Arrays.asList(TestUtils.sample("T", "S", "S", null)))); - } - }); - - try - { - URIContent content = new URIContent(file.toURI(), "txt"); - model.execute(new PortObject[] { new URIPortObject(Arrays.asList(content)) }, null); - } catch (IllegalArgumentException ex) - { - assertEquals("Error for data set owner of type sample " - + "'/SPACE/SAMPLE1': Not directly linked to an experiment.", ex.getMessage()); - } - - context.assertIsSatisfied(); - } - - @Test - public void testExecuteForSampleOwner() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.SAMPLE, "/SPACE/SAMPLE1"); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - final RecordingMatcher<NewDataSetDTO> dataSetMatcher = new RecordingMatcher<NewDataSetDTO>(); - final RecordingMatcher<File> fileMatcher = new RecordingMatcher<File>(); - context.checking(new Expectations() - { - { - one(serviceFacade).getSamples(Arrays.asList("/SPACE/SAMPLE1")); - will(returnValue(Arrays.asList(TestUtils.sample("T", "S", "S", "/S/P/E")))); - - one(serviceFacade).putDataSet(with(dataSetMatcher), with(fileMatcher)); - } - }); - logRecorder.resetLogContent(); - - URIContent content = new URIContent(file.toURI(), "txt"); - model.execute(new PortObject[] { new URIPortObject(Arrays.asList(content)) }, null); - - assertEquals("NewDataSetDTO[NewDataSetMetadataDTO[data set type=MY_TYPE]," - + "NewDataSetDTO.DataSetOwner[Sample,/SPACE/SAMPLE1],[FileInfoDssDTO[hello.txt,hello.txt,5]]]", - dataSetMatcher.recordedObject().toString()); - assertEquals(file.getAbsolutePath(), fileMatcher.recordedObject().getAbsolutePath()); - assertEquals("INFO " + MockDataSetRegistrationNodeModel.class.getName() + " - data set file: " - + file.getAbsolutePath(), logRecorder.getLogContent()); - context.assertIsSatisfied(); - } - - @Test - public void testExecuteForSampleOwnerForFileFromFlowVariable() throws Exception - { - flowVariables.put("file-name", file.getAbsolutePath()); - prepareFileVariableOwnerAndType(DataSetOwnerType.SAMPLE, "/SPACE/SAMPLE1", "file-name"); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - final RecordingMatcher<NewDataSetDTO> dataSetMatcher = new RecordingMatcher<NewDataSetDTO>(); - final RecordingMatcher<File> fileMatcher = new RecordingMatcher<File>(); - context.checking(new Expectations() - { - { - one(serviceFacade).getSamples(Arrays.asList("/SPACE/SAMPLE1")); - will(returnValue(Arrays.asList(TestUtils.sample("T", "S", "S", "/S/P/E")))); - - one(serviceFacade).putDataSet(with(dataSetMatcher), with(fileMatcher)); - } - }); - logRecorder.resetLogContent(); - - model.execute(new PortObject[] { FlowVariablePortObject.INSTANCE }, null); - - assertEquals("NewDataSetDTO[NewDataSetMetadataDTO[data set type=MY_TYPE]," - + "NewDataSetDTO.DataSetOwner[Sample,/SPACE/SAMPLE1],[FileInfoDssDTO[hello.txt,hello.txt,5]]]", - dataSetMatcher.recordedObject().toString()); - assertEquals(file.getAbsolutePath(), fileMatcher.recordedObject().getAbsolutePath()); - assertEquals("INFO " + MockDataSetRegistrationNodeModel.class.getName() + " - data set file: " - + file.getAbsolutePath(), logRecorder.getLogContent()); - context.assertIsSatisfied(); - } - - @Test - public void testExecuteForUnknownDataSetOwner() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.DATA_SET, "DS1"); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - context.checking(new Expectations() - { - { - one(serviceFacade).getDataSet("DS1"); - } - }); - logRecorder.resetLogContent(); - - try - { - URIContent content = new URIContent(file.toURI(), "txt"); - model.execute(new PortObject[] { new URIPortObject(Arrays.asList(content)) }, null); - } catch (IllegalArgumentException ex) - { - assertEquals("Error for data set owner of type data set " - + "'DS1': Unknown data set.", ex.getMessage()); - } - - context.assertIsSatisfied(); - } - - @Test - public void testExecuteForDataSetOwner() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.DATA_SET, " DS1 "); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - final RecordingMatcher<NewDataSetDTO> dataSetMatcher = new RecordingMatcher<NewDataSetDTO>(); - final RecordingMatcher<File> fileMatcher = new RecordingMatcher<File>(); - context.checking(new Expectations() - { - { - one(serviceFacade).getDataSet("DS1"); - will(returnValue(new DataSet(serviceFacade, null, TestUtils.dataSet("DS1"), null))); - - one(serviceFacade).putDataSet(with(dataSetMatcher), with(fileMatcher)); - } - }); - logRecorder.resetLogContent(); - - URIContent content = new URIContent(file.toURI(), "txt"); - model.execute(new PortObject[] { new URIPortObject(Arrays.asList(content)) }, null); - - assertEquals("NewDataSetDTO[NewDataSetMetadataDTO[data set type=MY_TYPE]," - + "NewDataSetDTO.DataSetOwner[Data Set,DS1],[FileInfoDssDTO[hello.txt,hello.txt,5]]]", - dataSetMatcher.recordedObject().toString()); - assertEquals(file.getAbsolutePath(), fileMatcher.recordedObject().getAbsolutePath()); - assertEquals("INFO " + MockDataSetRegistrationNodeModel.class.getName() + " - data set file: " - + file.getAbsolutePath(), logRecorder.getLogContent()); - context.assertIsSatisfied(); - } - - @Test - public void testExecuteForUnspecifiedDataSetOwner() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.DATA_SET, ""); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - logRecorder.resetLogContent(); - - try - { - URIContent content = new URIContent(file.toURI(), "txt"); - model.execute(new PortObject[] { new URIPortObject(Arrays.asList(content)) }, null); - } catch (IllegalArgumentException ex) - { - assertEquals("Owner data set hasn't been specified. " - + "Also flow variable 'openbis.DATA_SET' is undefined.", ex.getMessage()); - } - - context.assertIsSatisfied(); - } - - @Test - public void testExecuteForDataSetOwnerSpecifiedByFlowVariable() throws Exception - { - prepareOwnerAndType(DataSetOwnerType.DATA_SET, ""); - preparePropertyTypeCodes(); - preparePropertyValues(); - model.loadAdditionalValidatedSettingsFrom(nodeSettingsRO); - final RecordingMatcher<NewDataSetDTO> dataSetMatcher = new RecordingMatcher<NewDataSetDTO>(); - final RecordingMatcher<File> fileMatcher = new RecordingMatcher<File>(); - context.checking(new Expectations() - { - { - one(serviceFacade).getDataSet("DS1"); - will(returnValue(new DataSet(serviceFacade, null, TestUtils.dataSet("DS1"), null))); - - one(serviceFacade).putDataSet(with(dataSetMatcher), with(fileMatcher)); - } - }); - flowVariables.put(Util.VARIABLE_PREFIX + DataSetOwnerType.DATA_SET.name(), "DS1"); - logRecorder.resetLogContent(); - - URIContent content = new URIContent(file.toURI(), "txt"); - model.execute(new PortObject[] { new URIPortObject(Arrays.asList(content)) }, null); - - assertEquals("NewDataSetDTO[NewDataSetMetadataDTO[data set type=MY_TYPE]," - + "NewDataSetDTO.DataSetOwner[Data Set,DS1],[FileInfoDssDTO[hello.txt,hello.txt,5]]]", - dataSetMatcher.recordedObject().toString()); - assertEquals(file.getAbsolutePath(), fileMatcher.recordedObject().getAbsolutePath()); - assertEquals("INFO " + MockDataSetRegistrationNodeModel.class.getName() + " - data set file: " - + file.getAbsolutePath(), logRecorder.getLogContent()); - context.assertIsSatisfied(); - } - - private void prepareOwnerAndType(DataSetOwnerType ownerType, String owner) throws InvalidSettingsException - { - prepareFileVariableOwnerAndType(ownerType, owner, null); - } - - private void prepareFileVariableOwnerAndType(final DataSetOwnerType ownerType, final String owner, - final String fileVariable) throws InvalidSettingsException - { - context.checking(new Expectations() - { - { - one(nodeSettingsRO).getString(DataSetRegistrationNodeModel.OWNER_TYPE_KEY); - will(returnValue(ownerType == null ? null : ownerType.name())); - - one(nodeSettingsRO).getString(DataSetRegistrationNodeModel.OWNER_KEY); - will(returnValue(owner)); - - one(nodeSettingsRO).getString(DataSetRegistrationNodeModel.FILE_VARIABLE_KEY, null); - will(returnValue(fileVariable)); - } - }); - } - - private void preparePropertyTypeCodes(final String... propertyTypeCodes) throws InvalidSettingsException - { - context.checking(new Expectations() - { - { - one(nodeSettingsRO).getStringArray(DataSetRegistrationNodeModel.PROPERTY_TYPE_CODES_KEY, - new String[0]); - will(returnValue(propertyTypeCodes)); - } - }); - } - - private void preparePropertyValues(final String... propertyValues) throws InvalidSettingsException - { - context.checking(new Expectations() - { - { - one(nodeSettingsRO).getStringArray(DataSetRegistrationNodeModel.PROPERTY_VALUES_KEY, - new String[0]); - will(returnValue(propertyValues)); - } - }); - } -} diff --git a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/query/TableModelBuilderTest.java b/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/query/TableModelBuilderTest.java deleted file mode 100644 index 6b7d4bf6de1fba425986edcb6ae1464b381b2d97..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/query/TableModelBuilderTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2011 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import javax.swing.table.TableModel; - -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.DataSetInitializer; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.EntityRegistrationDetails; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.EntityRegistrationDetails.EntityRegistrationDetailsInitializer; -import ch.systemsx.cisd.openbis.knime.common.TableModelBuilder; - -/** - * @author Franz-Josef Elmer - */ -public class TableModelBuilderTest extends AssertJUnit -{ - - @Test - public void testTwoDataSetOfSameTypeNoSamples() - { - TableModelBuilder builder = new TableModelBuilder(); - builder.add(new DataSetBuilder("1-2").type("A").experiment("/A/B/C").property("A", "abc") - .getDataSet()); - builder.add(new DataSetBuilder("1-3").type("A").experiment("/A/B/D").property("B", "def") - .getDataSet()); - - TableModel tableModel = builder.getTableModel(); - - assertEquals("Code,Experiment,A,B\n" + "1-2,/A/B/C,abc,\n" + "1-3,/A/B/D,,def\n", - render(tableModel)); - } - - @Test - public void testTwoDataSetOfDifferentTypeWithSamples() - { - TableModelBuilder builder = new TableModelBuilder(); - builder.add(new DataSetBuilder("1-2").type("A").experiment("/A/B/C").sample("/A/1") - .getDataSet()); - builder.add(new DataSetBuilder("1-3").type("B").experiment("/A/B/D").getDataSet()); - - TableModel tableModel = builder.getTableModel(); - - assertEquals("Code,Type,Sample,Experiment\n" + "1-2,A,/A/1,/A/B/C\n" + "1-3,B,,/A/B/D\n", - render(tableModel)); - } - - private String render(TableModel tableModel) - { - StringBuilder builder = new StringBuilder(); - int rowCount = tableModel.getRowCount(); - int columnCount = tableModel.getColumnCount(); - for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) - { - if (columnIndex > 0) - { - builder.append(","); - } - builder.append(tableModel.getColumnName(columnIndex)); - } - builder.append("\n"); - for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) - { - for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) - { - if (columnIndex > 0) - { - builder.append(","); - } - builder.append(tableModel.getValueAt(rowIndex, columnIndex)); - } - builder.append("\n"); - } - return builder.toString(); - } - - private static final class DataSetBuilder - { - private DataSetInitializer initializer = new DataSetInitializer(); - - DataSetBuilder(String code) - { - initializer.setCode(code); - initializer.setRegistrationDetails(new EntityRegistrationDetails( - new EntityRegistrationDetailsInitializer())); - } - - DataSet getDataSet() - { - return new DataSet(initializer); - } - - DataSetBuilder type(String type) - { - initializer.setDataSetTypeCode(type); - return this; - } - - DataSetBuilder sample(String sampleIdentifier) - { - initializer.setSampleIdentifierOrNull(sampleIdentifier); - return this; - } - - DataSetBuilder experiment(String experimentIdentifier) - { - initializer.setExperimentIdentifier(experimentIdentifier); - return this; - } - - DataSetBuilder property(String key, String value) - { - initializer.getProperties().put(key, value); - return this; - } - - } - -} diff --git a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/query/UtilTest.java b/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/query/UtilTest.java deleted file mode 100644 index 8ca9469ef048ca035708b0857e5abfd934aa263a..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/query/UtilTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2011 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.query; - -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import ch.systemsx.cisd.openbis.knime.common.Util; -import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryDescription; - -/** - * @author Franz-Josef Elmer - */ -public class UtilTest extends AssertJUnit -{ - - @Test - public void testSerializationDeserializationOfQueryDescription() - { - QueryDescription queryDescription = new QueryDescription(); - queryDescription.setDescription("description"); - - byte[] serializedQueryDescription = Util.serializeDescription(queryDescription); - QueryDescription deserializedQueryDescription = Util.deserializeDescription(serializedQueryDescription); - - assertEquals(queryDescription.getDescription(), deserializedQueryDescription.getDescription()); - } - -} diff --git a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/server/AggregationCommandTest.java b/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/server/AggregationCommandTest.java deleted file mode 100644 index 3a26b82d1e3495be35638e633689eb908935b9d0..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/server/AggregationCommandTest.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.server; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.jmock.internal.NamedSequence; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISerializableComparable; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.StringTableCell; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelColumnHeader; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRow; -import ch.systemsx.cisd.openbis.generic.shared.managed_property.api.IRowBuilderAdaptor; -import ch.systemsx.cisd.openbis.generic.shared.managed_property.api.ISimpleTableModelBuilderAdaptor; - -/** - * @author Franz-Josef Elmer - */ -public class AggregationCommandTest extends AssertJUnit -{ - private static final class MockAggregationCommand extends AggregationCommand - { - private final Throwable aggregateThrowableOrNull; - - MockAggregationCommand(Throwable aggregateThrowableOrNull) - { - this.aggregateThrowableOrNull = aggregateThrowableOrNull; - } - - private ParameterDescriptionsBuilder recordedParametersBuilder; - - private Map<String, Object> recordedParameters; - - private ISimpleTableModelBuilderAdaptor recordedTableBuilder; - - @Override - protected void defineParameters(ParameterDescriptionsBuilder parameters) - { - this.recordedParametersBuilder = parameters; - } - - @Override - protected void aggregate(Map<String, Object> parameters, ISimpleTableModelBuilderAdaptor tableBuilder) - { - this.recordedParameters = parameters; - this.recordedTableBuilder = tableBuilder; - if (aggregateThrowableOrNull instanceof Error) - { - throw (Error) aggregateThrowableOrNull; - } - if (aggregateThrowableOrNull instanceof RuntimeException) - { - throw (RuntimeException) aggregateThrowableOrNull; - } - } - } - - private Mockery context; - - private Map<String, Object> parameters; - - private ISimpleTableModelBuilderAdaptor tableBuilder; - - private IRowBuilderAdaptor rowBuilder; - - @BeforeMethod - public void setUp() - { - context = new Mockery(); - tableBuilder = context.mock(ISimpleTableModelBuilderAdaptor.class); - rowBuilder = context.mock(IRowBuilderAdaptor.class); - parameters = new HashMap<String, Object>(); - } - - @AfterMethod - public void afterMethod() - { - // To following line of code should also be called at the end of each test method. - // Otherwise one do not known which test failed. - context.assertIsSatisfied(); - } - - @Test - public void testDefineParameters() - { - MockAggregationCommand command = new MockAggregationCommand(null); - parameters.put(Constants.REQUEST_KEY, Constants.GET_PARAMETER_DESCRIPTIONS_REQUEST); - context.checking(new Expectations() - { - { - one(tableBuilder).addHeader(Constants.PARAMETER_DESCRIPTION_NAME_COLUMN); - one(tableBuilder).addHeader(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN); - - one(tableBuilder).addRow(); - will(returnValue(rowBuilder)); - - one(rowBuilder).setCell(Constants.PARAMETER_DESCRIPTION_NAME_COLUMN, "Name"); - } - }); - - command.handleRequest(parameters, tableBuilder); - command.recordedParametersBuilder.parameter("Name"); - - assertEquals(null, command.recordedParameters); - assertEquals(null, command.recordedTableBuilder); - context.assertIsSatisfied(); - } - - @Test - public void testAggregate() - { - MockAggregationCommand command = new MockAggregationCommand(null); - - command.handleRequest(parameters, tableBuilder); - - assertEquals(null, command.recordedParametersBuilder); - assertSame(parameters, command.recordedParameters); - assertSame(tableBuilder, command.recordedTableBuilder); - context.assertIsSatisfied(); - } - - @Test - public void testAggregateFails() - { - final IllegalArgumentException nestedException = new IllegalArgumentException(); - final RuntimeException exception = new RuntimeException("Oohps!", nestedException); - MockAggregationCommand command = new MockAggregationCommand(exception); - final List<TableModelColumnHeader> headers = new ArrayList<TableModelColumnHeader>(Arrays.asList(new TableModelColumnHeader())); - List<ISerializableComparable> row = Arrays.<ISerializableComparable> asList(new StringTableCell("hi")); - final List<TableModelRow> rows = new ArrayList<TableModelRow>(Arrays.asList(new TableModelRow(row))); - final NamedSequence sequence = new NamedSequence("table"); - context.checking(new Expectations() - { - { - one(tableBuilder).getTableModel(); - will(returnValue(new TableModel(headers, rows))); - - one(tableBuilder).addHeader(Constants.EXCEPTION_COLUMN); - inSequence(sequence); - one(tableBuilder).addHeader(Constants.STACK_TRACE_CLASS_COLUMN); - inSequence(sequence); - one(tableBuilder).addHeader(Constants.STACK_TRACE_METHOD_NAME_COLUMN); - inSequence(sequence); - one(tableBuilder).addHeader(Constants.STACK_TRACE_FILE_NAME_COLUMN); - inSequence(sequence); - one(tableBuilder).addHeader(Constants.STACK_TRACE_LINE_NUMBER_COLUMN); - inSequence(sequence); - - one(tableBuilder).addFullRow(exception.toString(), "", "", "", ""); - inSequence(sequence); - for (StackTraceElement element : exception.getStackTrace()) - { - one(tableBuilder).addFullRow("", element.getClassName(), element.getMethodName(), - element.getFileName(), Integer.toString(element.getLineNumber())); - inSequence(sequence); - } - one(tableBuilder).addFullRow(nestedException.toString(), "", "", "", ""); - inSequence(sequence); - for (StackTraceElement element : nestedException.getStackTrace()) - { - one(tableBuilder).addFullRow("", element.getClassName(), element.getMethodName(), - element.getFileName(), Integer.toString(element.getLineNumber())); - inSequence(sequence); - } - } - }); - - command.handleRequest(parameters, tableBuilder); - - assertEquals(0, headers.size()); - assertEquals(0, rows.size()); - context.assertIsSatisfied(); - } - -} diff --git a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/server/ParameterDescriptionsBuilderTest.java b/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/server/ParameterDescriptionsBuilderTest.java deleted file mode 100644 index 14da20e320852f859ca3185acde4c5dc2fc21867..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceTest/java/ch/systemsx/cisd/openbis/knime/server/ParameterDescriptionsBuilderTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2013 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.openbis.knime.server; - -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import ch.systemsx.cisd.openbis.generic.shared.managed_property.api.IRowBuilderAdaptor; -import ch.systemsx.cisd.openbis.generic.shared.managed_property.api.ISimpleTableModelBuilderAdaptor; - -/** - * @author Franz-Josef Elmer - */ -public class ParameterDescriptionsBuilderTest extends AssertJUnit -{ - private Mockery context; - - private ISimpleTableModelBuilderAdaptor tableBuilder; - - private IRowBuilderAdaptor rowBuilder; - - private ParameterDescriptionsBuilder builder; - - @BeforeMethod - public void setUp() - { - context = new Mockery(); - tableBuilder = context.mock(ISimpleTableModelBuilderAdaptor.class); - rowBuilder = context.mock(IRowBuilderAdaptor.class); - context.checking(new Expectations() - { - { - one(tableBuilder).addHeader(Constants.PARAMETER_DESCRIPTION_NAME_COLUMN); - one(tableBuilder).addHeader(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN); - } - }); - builder = new ParameterDescriptionsBuilder(tableBuilder); - } - - @AfterMethod - public void afterMethod() - { - // To following line of code should also be called at the end of each test method. - // Otherwise one do not known which test failed. - context.assertIsSatisfied(); - } - - @Test - public void testAddParameter() - { - prepareAddRow("Name"); - - builder.parameter("Name"); - - context.assertIsSatisfied(); - } - - @Test - public void testAddParameterOfTypeText() - { - prepareAddRow("Variable"); - prepareSetType(FieldType.VARCHAR); - - builder.parameter("Variable").text(); - - context.assertIsSatisfied(); - } - - @Test - public void testAddParameterOfTypeExperiment() - { - prepareAddRow("Variable"); - prepareSetType(FieldType.EXPERIMENT); - - builder.parameter("Variable").experiment(); - - context.assertIsSatisfied(); - } - - @Test - public void testAddParameterOfTypeSample() - { - prepareAddRow("Variable"); - prepareSetType(FieldType.SAMPLE); - - builder.parameter("Variable").sample(); - - context.assertIsSatisfied(); - } - - @Test - public void testAddParameterOfTypeDataSet() - { - prepareAddRow("Variable"); - prepareSetType(FieldType.DATA_SET); - - builder.parameter("Variable").dataSet(); - - context.assertIsSatisfied(); - } - - @Test - public void testAddSameParameterTwice() - { - prepareAddRow("Variable"); - builder.parameter("Variable"); - - try - { - builder.parameter("Variable"); - fail("IllegalArgumentException expected."); - } catch (IllegalArgumentException ex) - { - assertEquals("There is already a parameter with name 'Variable'.", ex.getMessage()); - } - - context.assertIsSatisfied(); - } - - private void prepareAddRow(final String parameterName) - { - context.checking(new Expectations() - { - { - one(tableBuilder).addRow(); - will(returnValue(rowBuilder)); - - one(rowBuilder).setCell(Constants.PARAMETER_DESCRIPTION_NAME_COLUMN, parameterName); - } - }); - } - - private void prepareSetType(final FieldType fieldType) - { - context.checking(new Expectations() - { - { - one(rowBuilder).setCell(Constants.PARAMETER_DESCRIPTION_TYPE_COLUMN, fieldType.toString()); - } - }); - } - -} diff --git a/openbis_knime/sourceTest/java/tests.xml b/openbis_knime/sourceTest/java/tests.xml deleted file mode 100644 index d6fcc353a921992980028fa4851192497b6d8264..0000000000000000000000000000000000000000 --- a/openbis_knime/sourceTest/java/tests.xml +++ /dev/null @@ -1,13 +0,0 @@ -<suite name="All" verbose="1" > - <test name="All"> - <groups> - <run> - <exclude name="broken" /> - </run> - </groups> - <packages> - <package name="ch.systemsx.cisd.openbis.knime.*"> - </package> - </packages> - </test> -</suite> diff --git a/openbis_knime/targets/.gitignore b/openbis_knime/targets/.gitignore deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000