Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

XmlJob.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_IDash_XmlJob_h
00002 #define Impala_Core_IDash_XmlJob_h
00003 
00004 #include "Util/XmlDoc.h"
00005 #include "Persistency/XmlFileReader.h"
00006 
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace IDash
00012 {
00013 
00014 
00015 class XmlJob : public Util::XmlDoc
00016 {
00017 public:
00018 
00019     XmlJob(String id, String video, String querySet, String status,
00020            String statusDetails, String progressPercentage)
00021     {
00022         mId = id;
00023         mVideo = video;
00024         mQuerySet = querySet;
00025         mStatus = status;
00026         mStatusDetails = statusDetails;
00027         mProgressPercentage = progressPercentage;
00028     }
00029 
00030     XmlJob(String docName, Util::IOBuffer* ioBuf)
00031     {
00032         ReadData(docName, ioBuf);
00033     }
00034 
00035     virtual
00036     ~XmlJob()
00037     {
00038     }
00039 
00040     // inquiry
00041 
00042     bool
00043     Valid() const
00044     {
00045         return mValid;
00046     }
00047 
00048     String
00049     GetId()
00050     {
00051         return mId;
00052     }
00053 
00054     String
00055     GetVideo()
00056     {
00057         return mVideo;
00058     }
00059 
00060     String
00061     GetAnnotationSet()
00062     {
00063         return mAnnotationSet;
00064     }
00065 
00066     String
00067     GetQuerySet()
00068     {
00069         return mQuerySet;
00070     }
00071 
00072     String
00073     GetStatus()
00074     {
00075         return mStatus;
00076     }
00077 
00078     String
00079     GetStatusDetails()
00080     {
00081         return mStatusDetails;
00082     }
00083 
00084     String
00085     GetProgressPercentage()
00086     {
00087         return mProgressPercentage;
00088     }
00089 
00090     // I/O
00091 
00092     void
00093     Export(Util::IOBuffer* ioBuf)
00094     {
00095         ioBuf->Puts("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>");
00096         ioBuf->Puts("<job xmlns=\"http://www.i-dash.eu/ActionData\"");
00097         ioBuf->Puts("     xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"");
00098         ioBuf->Puts("     xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
00099         ioBuf->Puts("     xmlns:xlink=\"http://www.w3.org/1999/xlink\"");
00100         ioBuf->Puts("     xsi:schemaLocation=\"http://www.i-dash.eu/ActionData http://www.i-dash.eu/Schemas/ActionData/Job.xsd\">");
00101         ioBuf->Puts("  <id>" + mId + "</id>");
00102         ioBuf->Puts("  <video xlink:type=\"simple\" xlink:href=\"" + mVideo + "\" entityType=\"Video\"/>");
00103         ioBuf->Puts("  <querySet xlink:type=\"simple\" xlink:href=\"" + mQuerySet + "\" entityType=\"QuerySet\"/>");
00104         ioBuf->Puts("  <status>" + mStatus  + "</status>");
00105         ioBuf->Puts("  <statusDetails>" + mStatusDetails  + "</statusDetails>");
00106         ioBuf->Puts("  <progressPercentage>" + mProgressPercentage + "</progressPercentage>");
00107         ioBuf->Puts("</job>");
00108     }
00109 
00110     String
00111     Export()
00112     {
00113         Util::IOBuffer ioBuf(2048);
00114         Export(&ioBuf);
00115         String res((char*) ioBuf.GetBuffer(), ioBuf.GetPosition());
00116         return res;
00117     }
00118 
00119 private:
00120 
00121     /* sample file:
00122 
00123 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
00124 <job xmlns="http://www.i-dash.eu/ActionData"
00125      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
00126      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
00127      xmlns:xlink="http://www.w3.org/1999/xlink"
00128      xsi:schemaLocation="http://www.i-dash.eu/ActionData http://www.i-dash.eu/Schemas/ActionData/Job.xsd">
00129   <id>id_value</id>
00130   <video xlink:type="simple" xlink:href="http://dummy_url_to/video1" entityType="Video"/>
00131   <annotationSet xlink:href="http://dummy_url_to/videos/all/frames/?keyword=k" entityType="AnnotationSet" />
00132   <querySet xlink:type="simple" xlink:href="http://dummy_url_to/querySet" entityType="QuerySet"/>
00133   <compareEntity xlink:type="simple" xlink:href="http://dummy_url_to/video2" entityType="Video"/>
00134   <probabilityThreshold>0.95</probabilityThreshold>
00135   <status>initial</status>
00136   <statusDetails/>
00137   <progressPercentage />
00138 </job>
00139 
00140     */
00141 
00142     void
00143     ReadData(String docName, Util::IOBuffer* ioBuf)
00144     {
00145         mValid = false;
00146         Persistency::XmlFileReader reader;
00147         DOMDocument* doc = reader.Read(docName, ioBuf);
00148         if (!doc)
00149             return;
00150         DOMNode* job = GetChildNode(doc, "job", true);
00151         DOMNode* id = GetChildNode(job, "id", true);
00152         mId = GetElementValue(id);
00153         ILOG_DEBUG("id = " << mId);
00154 
00155         DOMNode* video = GetChildNode(job, "video", true);
00156         mVideo = GetAttributeValue(video, "xlink:href");
00157         ILOG_DEBUG("video = " << mVideo);
00158 
00159         DOMNode* annotationSet = GetChildNode(job, "annotationSet", false);
00160         if (annotationSet)
00161             mAnnotationSet = GetAttributeValue(annotationSet, "xlink:href");
00162         ILOG_DEBUG("annotationSet = " << mAnnotationSet);
00163 
00164         DOMNode* querySet = GetChildNode(job, "querySet", true);
00165         mQuerySet = GetAttributeValue(querySet, "xlink:href");
00166         ILOG_DEBUG("querySet = " << mQuerySet);
00167 
00168         DOMNode* status = GetChildNode(job, "status", true);
00169         mStatus = GetElementValue(status);
00170         ILOG_DEBUG("status = " << mStatus);
00171 
00172         DOMNode* statusDetails = GetChildNode(job, "statusDetails", false);
00173         if (statusDetails)
00174             mStatusDetails = GetElementValue(statusDetails);
00175         ILOG_DEBUG("statusDetails = " << mStatusDetails);
00176 
00177         DOMNode* progress = GetChildNode(job, "progressPercentage", true);
00178         if (progress)
00179             mProgressPercentage = GetElementValue(progress);
00180         ILOG_DEBUG("progress = " << mProgressPercentage);
00181         mValid = true;
00182     }
00183 
00184     // data
00185 
00186     String mId;
00187     String mVideo;
00188     String mAnnotationSet;
00189     String mQuerySet;
00190     String mStatus;
00191     String mStatusDetails;
00192     String mProgressPercentage;
00193     bool   mValid;
00194 
00195     ILOG_VAR_DEC;
00196 
00197 };
00198 
00199 ILOG_VAR_INIT(XmlJob, Impala.Core.IDash);
00200 
00201 } // namespace IDash
00202 } // namespace Core
00203 } // namespace Impala
00204 
00205 #endif

Generated on Fri Mar 19 09:31:11 2010 for ImpalaSrc by  doxygen 1.5.1