You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by ch...@apache.org on 2012/10/25 23:04:49 UTC
svn commit: r1402328 - in /incubator/ctakes/trunk: ./
ctakes-dictionary-lookup/desc/analysis_engine/
ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/
ctakes-distribution/src/main/bin/ ctakes-drug-ner/desc/analysis_engine/ ...
Author: chenpei
Date: Thu Oct 25 21:04:48 2012
New Revision: 1402328
URL: http://svn.apache.org/viewvc?rev=1402328&view=rev
Log:
CTAKES-28 - UMLS username and password could be passed in as a system property or env variable.
-Added a simple util class called EnvironmentVariable .getEnv(name) will attempt to read the variables
from system properties, environment variable, then context.
-Renamed variable name to ctakes.umlsuser and ctakes.umlspw to avoid any potential clashes in the future.
-Updated any references that used to use those parameters.
-Added a note to the startup scripts and README for users
Feel free to use this/edit consolidated mechanism so it will be easier for maintenance if we decide to change things.
Added:
incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/env/
incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/env/EnvironmentVariable.java (with props)
Modified:
incubator/ctakes/trunk/README
incubator/ctakes/trunk/ctakes-dictionary-lookup/desc/analysis_engine/DictionaryLookupAnnotatorUMLS.xml
incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java
incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCPE.bat
incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCPE.sh
incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCVD.bat
incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCVD.sh
incubator/ctakes/trunk/ctakes-drug-ner/desc/analysis_engine/DictionaryLookupAnnotatorUMLS.xml
incubator/ctakes/trunk/ctakes-side-effect/desc/analysis_engine/DictionaryLookupAnnotator_sideEffectUMLS.xml
incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java
Modified: incubator/ctakes/trunk/README
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/README?rev=1402328&r1=1402327&r2=1402328&view=diff
==============================================================================
--- incubator/ctakes/trunk/README (original)
+++ incubator/ctakes/trunk/README Thu Oct 25 21:04:48 2012
@@ -15,4 +15,11 @@ or Collection Processing Engine
Run bin/runctakesCVD/CPE.sh.bat
Load AE (analysis engine)
Select desc/ctakes-clinical-pipeline/desc/analysis_engine/AggregatePlaintextProcessor
-Enter note and run analysis engine.
\ No newline at end of file
+Enter note and run analysis engine.
+
+Notes
+-----------
+If you plan to use the UMLS Resources, set/export env variables
+export ctakes.umlsuser=[username], ctakes.umlspw=[password]
+or add the system properties to the java args
+-Dctakes.umlsuser=[username] -Dctakes.umlspw=[password]
\ No newline at end of file
Modified: incubator/ctakes/trunk/ctakes-dictionary-lookup/desc/analysis_engine/DictionaryLookupAnnotatorUMLS.xml
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-dictionary-lookup/desc/analysis_engine/DictionaryLookupAnnotatorUMLS.xml?rev=1402328&r1=1402327&r2=1402328&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-dictionary-lookup/desc/analysis_engine/DictionaryLookupAnnotatorUMLS.xml (original)
+++ incubator/ctakes/trunk/ctakes-dictionary-lookup/desc/analysis_engine/DictionaryLookupAnnotatorUMLS.xml Thu Oct 25 21:04:48 2012
@@ -38,7 +38,7 @@
<mandatory>false</mandatory>
</configurationParameter>
<configurationParameter>
- <name>UMLSAddr</name>
+ <name>ctakes.umlsaddr</name>
<description>
A UMLS is required to use the UMLS Dictionary.
Address to verify UMLS License. If you do not have one,
@@ -49,21 +49,21 @@
<mandatory>true</mandatory>
</configurationParameter>
<configurationParameter>
- <name>UMLSVendor</name>
+ <name>ctakes.umlsvendor</name>
<description>UMLS Vendor ID</description>
<type>String</type>
<multiValued>false</multiValued>
<mandatory>true</mandatory>
</configurationParameter>
<configurationParameter>
- <name>UMLSUser</name>
+ <name>ctakes.umlsuser</name>
<description>UMLS User Name</description>
<type>String</type>
<multiValued>false</multiValued>
<mandatory>true</mandatory>
</configurationParameter>
<configurationParameter>
- <name>UMLSPW</name>
+ <name>ctakes.umlspw</name>
<description>UMLS Password</description>
<type>String</type>
<multiValued>false</multiValued>
@@ -78,25 +78,25 @@
</value>
</nameValuePair>
<nameValuePair>
- <name>UMLSAddr</name>
+ <name>ctakes.umlsaddr</name>
<value>
- <string>https://uts-ws.nlm.nih.gov/restful/isValidUMLSUser</string>
+ <string>https://uts-ws.nlm.nih.gov/restful/isValidctakes.umlsuser</string>
</value>
</nameValuePair>
<nameValuePair>
- <name>UMLSVendor</name>
+ <name>ctakes.umlsvendor</name>
<value>
<string>NLM-6515182895</string>
</value>
</nameValuePair>
<nameValuePair>
- <name>UMLSUser</name>
+ <name>ctakes.umlsuser</name>
<value>
<string>YOUR_UMLS_USERNAME_HERE</string>
</value>
</nameValuePair>
<nameValuePair>
- <name>UMLSPW</name>
+ <name>ctakes.umlspw</name>
<value>
<string>YOUR_UMLS_PASSWORD_HERE</string>
</value>
Modified: incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java?rev=1402328&r1=1402327&r2=1402328&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java (original)
+++ incubator/ctakes/trunk/ctakes-dictionary-lookup/src/main/java/org/apache/ctakes/dictionary/lookup/ae/UmlsDictionaryLookupAnnotator.java Thu Oct 25 21:04:48 2012
@@ -27,6 +27,7 @@ import java.net.URLEncoder;
import java.util.HashSet;
import java.util.Set;
+import org.apache.ctakes.utils.env.EnvironmentVariable;
import org.apache.log4j.Logger;
import org.apache.uima.UimaContext;
import org.apache.uima.resource.ResourceInitializationException;
@@ -42,14 +43,13 @@ public class UmlsDictionaryLookupAnnotat
* Performs a check for user's UMLS licence at init time via their RESTful API
* User's will need to configure their UMLS username/password in their config
*/
- private final static String UMLSADDR_PARAM = "UMLSAddr";
- private final static String UMLSVENDOR_PARAM = "UMLSVendor";
- private final static String UMLSUSER_PARAM = "UMLSUser";
- private final static String UMLSPW_PARAM = "UMLSPW";
+ private final static String UMLSADDR_PARAM = "ctakes.umlsaddr";
+ private final static String UMLSVENDOR_PARAM = "ctakes.umlsvendor";
+ private final static String UMLSUSER_PARAM = "ctakes.umlsuser";
+ private final static String UMLSPW_PARAM = "ctakes.umlspw";
private Logger iv_logger = Logger.getLogger(getClass().getName());
- private UimaContext iv_context;
- private Set iv_lookupSpecSet = new HashSet();
+
private String UMLSAddr;
private String UMLSVendor;
private String UMLSUser;
@@ -59,15 +59,14 @@ public class UmlsDictionaryLookupAnnotat
throws ResourceInitializationException
{
super.initialize(aContext);
- iv_context = aContext;
try {
- UMLSAddr = (String) iv_context.getConfigParameterValue(UMLSADDR_PARAM);
- UMLSVendor = (String) iv_context.getConfigParameterValue(UMLSVENDOR_PARAM);
- UMLSUser = (String) iv_context.getConfigParameterValue(UMLSUSER_PARAM);
- UMLSPW = (String) iv_context.getConfigParameterValue(UMLSPW_PARAM);
+ UMLSAddr = EnvironmentVariable.getEnv(UMLSADDR_PARAM, aContext);
+ UMLSVendor = EnvironmentVariable.getEnv(UMLSVENDOR_PARAM, aContext);
+ UMLSUser = EnvironmentVariable.getEnv(UMLSUSER_PARAM, aContext);
+ UMLSPW = EnvironmentVariable.getEnv(UMLSPW_PARAM, aContext);
- iv_logger.info("Using " + UMLSADDR_PARAM + ":" + UMLSAddr + ":" + UMLSUser);
+ iv_logger.info("Using " + UMLSADDR_PARAM + ": " + UMLSAddr + ": " + UMLSUser);
if(!isValidUMLSUser(UMLSAddr, UMLSVendor, UMLSUser, UMLSPW))
{
iv_logger.error("Error: Invalid UMLS License. A UMLS License is required to use the UMLS dictionary lookup. \n" +
Modified: incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCPE.bat
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCPE.bat?rev=1402328&r1=1402327&r2=1402328&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCPE.bat (original)
+++ incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCPE.bat Thu Oct 25 21:04:48 2012
@@ -18,6 +18,10 @@
@REM
@REM Requires JAVA JDK 1.6+
+@REM If you plan to use the UMLS Resources, set/export env variables
+@REM set ctakes.umlsuser=[username], ctakes.umlspw=[password]
+@REM or add the properties
+@REM -Dctakes.umlsuser=[username] -Dctakes.umlspw=[password]
@REM Guess CTAKES_HOME if not defined
set CURRENT_DIR=%cd%
Modified: incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCPE.sh
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCPE.sh?rev=1402328&r1=1402327&r2=1402328&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCPE.sh (original)
+++ incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCPE.sh Thu Oct 25 21:04:48 2012
@@ -18,6 +18,10 @@
#
# Requires JAVA JDK 1.6+
+# If you plan to use the UMLS Resources, set/export env variables
+# export ctakes.umlsuser=[username], ctakes.umlspw=[password]
+# or add the properties
+# -Dctakes.umlsuser=[username] -Dctakes.umlspw=[password]
PRG="$0"
while [ -h "$PRG" ]; do
Modified: incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCVD.bat
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCVD.bat?rev=1402328&r1=1402327&r2=1402328&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCVD.bat (original)
+++ incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCVD.bat Thu Oct 25 21:04:48 2012
@@ -18,6 +18,10 @@
@REM
@REM Requires JAVA JDK 1.6+
+@REM If you plan to use the UMLS Resources, set/export env variables
+@REM set ctakes.umlsuser=[username], ctakes.umlspw=[password]
+@REM or add the properties
+@REM -Dctakes.umlsuser=[username] -Dctakes.umlspw=[password]
@REM Guess CTAKES_HOME if not defined
set CURRENT_DIR=%cd%
Modified: incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCVD.sh
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCVD.sh?rev=1402328&r1=1402327&r2=1402328&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCVD.sh (original)
+++ incubator/ctakes/trunk/ctakes-distribution/src/main/bin/runctakesCVD.sh Thu Oct 25 21:04:48 2012
@@ -17,6 +17,12 @@
# under the License.
#
+# Requires JAVA JDK 1.6+
+# If you plan to use the UMLS Resources, set/export env variables
+# export ctakes.umlsuser=[username], ctakes.umlspw=[password]
+# or add the properties
+# -Dctakes.umlsuser=[username] -Dctakes.umlspw=[password]
+
PRG="$0"
while [ -h "$PRG" ]; do
ls=`ls -ld "$PRG"`
Modified: incubator/ctakes/trunk/ctakes-drug-ner/desc/analysis_engine/DictionaryLookupAnnotatorUMLS.xml
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-drug-ner/desc/analysis_engine/DictionaryLookupAnnotatorUMLS.xml?rev=1402328&r1=1402327&r2=1402328&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-drug-ner/desc/analysis_engine/DictionaryLookupAnnotatorUMLS.xml (original)
+++ incubator/ctakes/trunk/ctakes-drug-ner/desc/analysis_engine/DictionaryLookupAnnotatorUMLS.xml Thu Oct 25 21:04:48 2012
@@ -38,7 +38,7 @@
<mandatory>false</mandatory>
</configurationParameter>
<configurationParameter>
- <name>UMLSAddr</name>
+ <name>ctakes.umlsaddr</name>
<description>
A UMLS is required to use the UMLS Dictionary.
Address to verify UMLS License. If you do not have one,
@@ -49,21 +49,21 @@
<mandatory>true</mandatory>
</configurationParameter>
<configurationParameter>
- <name>UMLSVendor</name>
+ <name>ctakes.umlsvendor</name>
<description>UMLS Vendor ID</description>
<type>String</type>
<multiValued>false</multiValued>
<mandatory>true</mandatory>
</configurationParameter>
<configurationParameter>
- <name>UMLSUser</name>
+ <name>ctakes.umlsuser</name>
<description>UMLS User Name</description>
<type>String</type>
<multiValued>false</multiValued>
<mandatory>true</mandatory>
</configurationParameter>
<configurationParameter>
- <name>UMLSPW</name>
+ <name>ctakes.umlspw</name>
<description>UMLS Password</description>
<type>String</type>
<multiValued>false</multiValued>
@@ -78,25 +78,25 @@
</value>
</nameValuePair>
<nameValuePair>
- <name>UMLSAddr</name>
+ <name>ctakes.umlsaddr</name>
<value>
- <string>https://uts-ws.nlm.nih.gov/restful/isValidUMLSUser</string>
+ <string>https://uts-ws.nlm.nih.gov/restful/isValidctakes.umlsuser</string>
</value>
</nameValuePair>
<nameValuePair>
- <name>UMLSVendor</name>
+ <name>ctakes.umlsvendor</name>
<value>
<string>NLM-6515182895</string>
</value>
</nameValuePair>
<nameValuePair>
- <name>UMLSUser</name>
+ <name>ctakes.umlsuser</name>
<value>
<string>YOUR_UMLS_USERNAME_HERE</string>
</value>
</nameValuePair>
<nameValuePair>
- <name>UMLSPW</name>
+ <name>ctakes.umlspw</name>
<value>
<string>YOUR_UMLS_PASSWORD_HERE</string>
</value>
Modified: incubator/ctakes/trunk/ctakes-side-effect/desc/analysis_engine/DictionaryLookupAnnotator_sideEffectUMLS.xml
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-side-effect/desc/analysis_engine/DictionaryLookupAnnotator_sideEffectUMLS.xml?rev=1402328&r1=1402327&r2=1402328&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-side-effect/desc/analysis_engine/DictionaryLookupAnnotator_sideEffectUMLS.xml (original)
+++ incubator/ctakes/trunk/ctakes-side-effect/desc/analysis_engine/DictionaryLookupAnnotator_sideEffectUMLS.xml Thu Oct 25 21:04:48 2012
@@ -38,7 +38,7 @@
<mandatory>false</mandatory>
</configurationParameter>
<configurationParameter>
- <name>UMLSAddr</name>
+ <name>ctakes.umlsaddr</name>
<description>
A UMLS is required to use the UMLS Dictionary.
Address to verify UMLS License. If you do not have one,
@@ -49,21 +49,21 @@
<mandatory>true</mandatory>
</configurationParameter>
<configurationParameter>
- <name>UMLSVendor</name>
+ <name>ctakes.umlsvendor</name>
<description>UMLS Vendor ID</description>
<type>String</type>
<multiValued>false</multiValued>
<mandatory>true</mandatory>
</configurationParameter>
<configurationParameter>
- <name>UMLSUser</name>
+ <name>ctakes.umlsuser</name>
<description>UMLS User Name</description>
<type>String</type>
<multiValued>false</multiValued>
<mandatory>true</mandatory>
</configurationParameter>
<configurationParameter>
- <name>UMLSPW</name>
+ <name>ctakes.umlspw</name>
<description>UMLS Password</description>
<type>String</type>
<multiValued>false</multiValued>
@@ -78,25 +78,25 @@
</value>
</nameValuePair>
<nameValuePair>
- <name>UMLSAddr</name>
+ <name>ctakes.umlsaddr</name>
<value>
- <string>https://uts-ws.nlm.nih.gov/restful/isValidUMLSUser</string>
+ <string>https://uts-ws.nlm.nih.gov/restful/isValidctakes.umlsuser</string>
</value>
</nameValuePair>
<nameValuePair>
- <name>UMLSVendor</name>
+ <name>ctakes.umlsvendor</name>
<value>
<string>NLM-6515182895</string>
</value>
</nameValuePair>
<nameValuePair>
- <name>UMLSUser</name>
+ <name>ctakes.umlsuser</name>
<value>
<string>YOUR_UMLS_USERNAME_HERE</string>
</value>
</nameValuePair>
<nameValuePair>
- <name>UMLSPW</name>
+ <name>ctakes.umlspw</name>
<value>
<string>YOUR_UMLS_PASSWORD_HERE</string>
</value>
Modified: incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java?rev=1402328&r1=1402327&r2=1402328&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java (original)
+++ incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/Evaluation_ImplBase.java Thu Oct 25 21:04:48 2012
@@ -247,13 +247,13 @@ public abstract class Evaluation_ImplBas
}
aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(
UmlsDictionaryLookupAnnotator.class,
- "UMLSAddr",
- "https://uts-ws.nlm.nih.gov/restful/isValidUMLSUser",
- "UMLSVendor",
+ "ctakes.umlsaddr",
+ "https://uts-ws.nlm.nih.gov/restful/isValidctakes.umlsuser",
+ "ctakes.umlsvendor",
"NLM-6515182895",
- "UMLSUser",
+ "ctakes.umlsuser",
umlsUser,
- "UMLSPW",
+ "ctakes.umlspw",
umlsPassword,
"LookupDescriptor",
ExternalResourceFactory.createExternalResourceDescription(
Added: incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/env/EnvironmentVariable.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/env/EnvironmentVariable.java?rev=1402328&view=auto
==============================================================================
--- incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/env/EnvironmentVariable.java (added)
+++ incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/env/EnvironmentVariable.java Thu Oct 25 21:04:48 2012
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ctakes.utils.env;
+
+import org.apache.uima.UimaContext;
+
+public class EnvironmentVariable {
+
+ /**
+ * @param name
+ * @param context
+ * @return String value Get Environment Variable values will attempt to get
+ * it from System Proerties, then Environment, then uima context
+ */
+ public static String getEnv(String name, UimaContext context) {
+ String value = null;
+ if (name != null && name.trim().length() > 0) {
+ //Attempt to get it from system properites, env variables
+ value = getEnv(name);
+ if (value == null) {
+ // Attempt to get it from UIMA Context
+ value = (String) context.getConfigParameterValue(name);
+ }
+ }
+ return value;
+ }
+
+ /**
+ * @param name
+ * @return value Get Environment Variable values will attempt to get it from
+ * System Proerties, then Environment
+ */
+ public static String getEnv(String name) {
+ String value = null;
+ if (name != null && name.trim().length() > 0) {
+ // Attempt to get it from System Properties
+ value = System.getProperty(name);
+ if (value == null) {
+ // Attempt ot get it from Env Variables
+ value = System.getenv(name);
+ }
+ }
+ return value;
+ }
+}
Propchange: incubator/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/env/EnvironmentVariable.java
------------------------------------------------------------------------------
svn:mime-type = text/plain