diff --git a/SAS/OTB/GUI/src/gui/treeModel.java b/SAS/OTB/GUI/src/gui/treeModel.java index 0f59e88274577397eca47add05b2dc64e5b367f4..ab9a5931a613acc9a85d25914e3aee7489778efe 100644 --- a/SAS/OTB/GUI/src/gui/treeModel.java +++ b/SAS/OTB/GUI/src/gui/treeModel.java @@ -69,9 +69,9 @@ public class treeModel extends AbstractTableModel { if (itsDebugFlag) System.out.println("Collected tree list"); } for (int k=0; k< aTreeList.size();k++) { - if (itsDebugFlag) System.out.println("getTreeInfo(aTreeList.elementAt("+k+"))"); + if (itsDebugFlag) System.out.println("getTreeInfo(aTreeList.elementAt("+k+"),false)"); Integer i = new Integer((Integer)aTreeList.elementAt(k)); - jOTDBtree tInfo = aRemoteOTDB.getTreeInfo(i.intValue()); + jOTDBtree tInfo = aRemoteOTDB.getTreeInfo(i.intValue(), false); if (tInfo.treeID()==0) { if (itsDebugFlag) System.out.println("No such tree found!"); } else { diff --git a/SAS/OTB/OTBTest/nbproject/private/private.properties b/SAS/OTB/OTBTest/nbproject/private/private.properties index 4436718fcac4a3578b51e32e5158298d5bbcc2cb..a1d8b6b65a9e616d5fde1b185451224d46b83940 100644 --- a/SAS/OTB/OTBTest/nbproject/private/private.properties +++ b/SAS/OTB/OTBTest/nbproject/private/private.properties @@ -1,4 +1,4 @@ application.args= javac.debug=true javadoc.preview=true -user.properties.file=/export/home/coolen/.netbeans/4.1/build.properties +user.properties.file=/home/coolen/.netbeans/4.1/build.properties diff --git a/SAS/OTB/jOTDB/src/jOTDB/jOTDBadapter.java b/SAS/OTB/jOTDB/src/jOTDB/jOTDBadapter.java index aac297cc92257e816b77cf15c4ec1bcc7bcec2df..22c315140f7b29702891d78d4e664f9d43a140d8 100644 --- a/SAS/OTB/jOTDB/src/jOTDB/jOTDBadapter.java +++ b/SAS/OTB/jOTDB/src/jOTDB/jOTDBadapter.java @@ -49,11 +49,19 @@ public class jOTDBadapter extends UnicastRemoteObject implements jOTDBinterface } // get OTDBtree of one specific tree - public jOTDBtree getTreeInfo (int atreeID) throws RemoteException + public jOTDBtree getTreeInfo (int atreeID,boolean isMomID) throws RemoteException { - return adaptee.getTreeInfo (atreeID); + return adaptee.getTreeInfo (atreeID,isMomID); } + + + // To get a list of all StateChanges + public Vector getStateList (int treeID, boolean isMomID, String beginDate) throws RemoteException + { + return adaptee.getStateList (treeID, isMomID, beginDate); + } + // To get a list of all OTDB trees available in the database. public Vector getTreeList (short treeType, short classifiType) throws RemoteException { diff --git a/SAS/OTB/jOTDB/src/jOTDB/jOTDBconnection.java b/SAS/OTB/jOTDB/src/jOTDB/jOTDBconnection.java index 015a0e1acc273567e49c26abfa661e5f0f2b3f79..84a67c7f0a3ca9ee339f696532fa80fc163096d2 100644 --- a/SAS/OTB/jOTDB/src/jOTDB/jOTDBconnection.java +++ b/SAS/OTB/jOTDB/src/jOTDB/jOTDBconnection.java @@ -48,8 +48,11 @@ public class jOTDBconnection public native boolean connect(); // get OTDBtree of one specific tree - public native jOTDBtree getTreeInfo (int atreeID); + public native jOTDBtree getTreeInfo (int atreeID, boolean isMomID); + public native Vector getStateList(int atreeID, boolean isMomID ,String beginDate); + + // To get a list of all OTDB trees available in the database. public native Vector getTreeList(short treeType, short classifiType); diff --git a/SAS/OTB/jOTDB/src/jOTDB/jOTDBinterface.java b/SAS/OTB/jOTDB/src/jOTDB/jOTDBinterface.java index 45884c71f39df2602a37961e6d4b3901b76493b6..0d62f01a75f8dc14b405f9f06a7e804c1f98a0e4 100644 --- a/SAS/OTB/jOTDB/src/jOTDB/jOTDBinterface.java +++ b/SAS/OTB/jOTDB/src/jOTDB/jOTDBinterface.java @@ -38,10 +38,13 @@ public interface jOTDBinterface extends Remote public boolean connect () throws RemoteException; // get OTDBtree of one specific tree - public jOTDBtree getTreeInfo (int atreeID) throws RemoteException; + public jOTDBtree getTreeInfo (int atreeID,boolean isMomID) throws RemoteException; // To get a list of all OTDB trees available in the database. public Vector getTreeList (short treeType, short classifiType) throws RemoteException; + + // To get a list of all OTDB trees available in the database. + public Vector getStateList (int treeID, boolean isMomID, String beginDate) throws RemoteException; public String errorMsg () throws RemoteException; diff --git a/SAS/OTB/jOTDB/src/jOTDB/jOTDBserver.java b/SAS/OTB/jOTDB/src/jOTDB/jOTDBserver.java index e59f641b82afcb6e6e3fef2e52ff368c03cd5e3d..ef31d9da0c88ed6d53138a685def58539c066c86 100644 --- a/SAS/OTB/jOTDB/src/jOTDB/jOTDBserver.java +++ b/SAS/OTB/jOTDB/src/jOTDB/jOTDBserver.java @@ -51,19 +51,9 @@ public class jOTDBserver static { - try - { - System.out.println (InetAddress.getLocalHost().getHostName()); - System.setProperty ("java.rmi.server.hostname", InetAddress.getLocalHost().getHostName()); - } - catch (Exception e) - { - System.out.println ("Could not set the hostname!"); - System.exit (0); - } - System.loadLibrary("jotdb"); } + public static void main (String[] args) { @@ -75,18 +65,24 @@ public class jOTDBserver // System.setSecurityManager (new RMISecurityManager ()); // } - if (args.length < 3) + if (args.length < 4) { - System.out.println ("Usage: java -jar jOTDBserver.jar <username> <password> <database> <portnumber-OPTIONAL>"); + System.out.println ("Usage: java -jar jOTDBserver.jar <username> <password> <database> <hostname> <portnumber-OPTIONAL>"); System.exit(0); } + + String aHostName = new String(args[3]); + + System.out.println ("Running on: "+aHostName); + System.setProperty ("java.rmi.server.hostname", aHostName); + System.out.println ("jOTDBserver creating a local RMI registry..."); Registry localRegistry; - if (args.length == 3) + if (args.length == 4) localRegistry = LocateRegistry.createRegistry (Registry.REGISTRY_PORT); else { - Integer i = new Integer (args[3]); + Integer i = new Integer (args[4]); localRegistry = LocateRegistry.createRegistry (i.intValue()); } diff --git a/SAS/OTB/jOTDB/src/jOTDB/jOTDBtree.java b/SAS/OTB/jOTDB/src/jOTDB/jOTDBtree.java index d7f2f49e48d89c31b2145de0247db9dcb357d8cc..cb736095346454682b669355c4af057d88121ed7 100644 --- a/SAS/OTB/jOTDB/src/jOTDB/jOTDBtree.java +++ b/SAS/OTB/jOTDB/src/jOTDB/jOTDBtree.java @@ -23,25 +23,26 @@ package jOTDB; public class jOTDBtree implements java.io.Serializable { - public jOTDBtree (int treeID) - { + public jOTDBtree (int treeID) + { itsTreeID = treeID; - } + } - public int treeID() - { + public int treeID() + { return (itsTreeID); - } + } - public short classification; // development / test / operational - public String creator; - public String creationDate; - public short type; // hardware / VItemplate / VHtree - public short state; // idle / configure / ... / active / ... - // -- VIC only -- - public int originalTree; - public String campaign; - public String starttime; - public String stoptime; - private int itsTreeID; + public int momID; + public short classification; // development / test / operational + public String creator; + public String creationDate; + public short type; // hardware / VItemplate / VHtree + public short state; // idle / configure / ... / active / ... + // -- VIC only -- + public int originalTree; + public String campaign; + public String starttime; + public String stoptime; + private int itsTreeID; } diff --git a/SAS/OTB/jOTDB/src/jOTDB_jOTDBconnection.cc b/SAS/OTB/jOTDB/src/jOTDB_jOTDBconnection.cc index 2959539ed382dd3b159b2d02c921fbd4331deadb..c494b25c33ddb9b16d8d60e874d715a46cec02d1 100644 --- a/SAS/OTB/jOTDB/src/jOTDB_jOTDBconnection.cc +++ b/SAS/OTB/jOTDB/src/jOTDB_jOTDBconnection.cc @@ -22,7 +22,7 @@ //# Always #include <lofar_config.h> first! #include <lofar_config.h> -//# Includes +//# #include <Common/LofarLogger.h> #include <jni.h> #include <jOTDB/jOTDB_jOTDBconnection.h> @@ -33,6 +33,7 @@ #include <iostream> #include <jOTDB/jOTDB_jOTDBcommon.h> + using namespace boost::posix_time; using namespace LOFAR::OTDB; @@ -161,6 +162,57 @@ namespace LOFAR return(vecTreeIDs); } + jobject convertTreeState (JNIEnv *env, TreeState aTreeState) + { + jobject jTreeState; + jclass class_jTreeState = env->FindClass ("jOTDB/jTreeState"); + + + jfieldID fid_jTreeState_treeID = env->GetFieldID (class_jTreeState, "treeID", "I"); + jfieldID fid_jTreeState_momID = env->GetFieldID (class_jTreeState, "momID", "I"); + jfieldID fid_jTreeState_newState = env->GetFieldID (class_jTreeState, "newState", "S"); + jfieldID fid_jTreeState_username = env->GetFieldID (class_jTreeState, "username", "Ljava/lang/String;"); + jfieldID fid_jTreeState_timestamp = env->GetFieldID (class_jTreeState, "timestamp", "Ljava/lang/String;"); + + env->SetIntField (jTreeState, fid_jTreeState_treeID, aTreeState.treeID); + env->SetIntField (jTreeState, fid_jTreeState_momID, aTreeState.momID); + env->SetShortField (jTreeState, fid_jTreeState_newState, aTreeState.newState); + env->SetObjectField (jTreeState, fid_jTreeState_username, env->NewStringUTF(aTreeState.username.c_str())); + env->SetObjectField (jTreeState, fid_jTreeState_timestamp, env->NewStringUTF(to_simple_string(aTreeState.timestamp).c_str())); + + return jTreeState; + } + + /* + * Class: jOTDB_jOTDBconnection + * Method: getStateList + * Signature: (IZLjava/lang/String;)Ljava/util/Vector; + */ + JNIEXPORT jobject JNICALL Java_jOTDB_jOTDBconnection_getStateList + (JNIEnv *env, jobject, jint treeID, jboolean isMomID, jstring beginDate) + + { + const char* bd = env->GetStringUTFChars (beginDate, 0); + + vector<TreeState> states = OTDBconn->getStateList(treeID, isMomID,time_from_string(bd)); + vector<TreeState>::iterator statesIterator; + + // Construct java Vector + jobject statesVector; + jclass class_Vector = env->FindClass("java/util/Vector"); + jmethodID mid_Vector_cons = env->GetMethodID(class_Vector, "<init>", "()V"); + statesVector = env->NewObject(class_Vector, mid_Vector_cons); + jmethodID mid_Vector_add = env->GetMethodID(class_Vector, "add", "(Ljava/lang/Object;)Z"); + + for (statesIterator = states.begin(); statesIterator != states.end(); statesIterator++) + { + env->CallObjectMethod(statesVector, mid_Vector_add,convertTreeState(env, *statesIterator )); + } + + return(statesVector); + } + + /* * Class: jOTDB_jOTDBconnection * Method: errorMsg @@ -189,5 +241,9 @@ namespace LOFAR { return OTDBconn; } + + + + } // namespace jOTDB } // namespace LOFAR diff --git a/SAS/OTB/jOTDB/src/jOTDB_jOTDBconnection.h b/SAS/OTB/jOTDB/src/jOTDB_jOTDBconnection.h index 6daffbb2e13fc642fff5b96d834bce46a4c9bb36..0581b46f0d7a76fbd9179ff5506ce99a9b049021 100644 --- a/SAS/OTB/jOTDB/src/jOTDB_jOTDBconnection.h +++ b/SAS/OTB/jOTDB/src/jOTDB_jOTDBconnection.h @@ -7,14 +7,7 @@ #ifdef __cplusplus extern "C" { #endif - - namespace LOFAR - { - - namespace jOTDB - { - - /* +/* * Class: jOTDB_jOTDBconnection * Method: initOTDBconnection * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V @@ -41,10 +34,18 @@ JNIEXPORT jboolean JNICALL Java_jOTDB_jOTDBconnection_connect /* * Class: jOTDB_jOTDBconnection * Method: getTreeInfo - * Signature: (I)LjOTDB/jOTDBtree; + * Signature: (IZ)LjOTDB/jOTDBtree; */ JNIEXPORT jobject JNICALL Java_jOTDB_jOTDBconnection_getTreeInfo - (JNIEnv *, jobject, jint); + (JNIEnv *, jobject, jint, jboolean); + +/* + * Class: jOTDB_jOTDBconnection + * Method: getStateList + * Signature: (IZLjava/lang/String;)Ljava/util/Vector; + */ +JNIEXPORT jobject JNICALL Java_jOTDB_jOTDBconnection_getStateList + (JNIEnv *, jobject, jint, jboolean, jstring); /* * Class: jOTDB_jOTDBconnection @@ -70,10 +71,6 @@ JNIEXPORT jstring JNICALL Java_jOTDB_jOTDBconnection_errorMsg JNIEXPORT jint JNICALL Java_jOTDB_jOTDBconnection_getAuthToken (JNIEnv *, jobject); - } - - } - #ifdef __cplusplus } #endif