DumontEXE 0.0.1
cmcMeInfo.cpp
00001 /* ***************************************************************************
00002 **
00003 ** Copyright (C) 2007 Lorimark Solutions, LLC. All rights reserved.
00004 **
00005 ** This file is part of the DumontEXE Scripting Extension Kit
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://dumont.showoff-db.org/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://dumont.showoff-db.org/licensing.html 
00017 ** or contact the sales department at sales@lorimarksolutions.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ** author: Mark Petryk ~ Lorimark Solutions, LLC
00023 ** **************************************************************************/
00024 
00025 #include "cmcMeInfo.h"
00026 #include "cmcDatabase.h"
00027 #include "cmcConversation.h"
00028 #include "cmcFieldDefs.h"
00029 
00030 namespace cmcDatabaseApi {
00031 
00032 // ******************************************************************** */
00033 
00034 cmcMeInfo::cmcMeInfo( const cmcMeInfo & copy )
00035 : cmcObject()
00036 {
00037 }
00038 
00039 cmcMeInfo::cmcMeInfo( cmcApplication * application, cmcObject * parent )
00040 : cmcObject( "MeInfo", application, parent )
00041 {
00042 }
00043 
00044 cmcMeInfo::~cmcMeInfo()
00045 {
00046 }
00047 
00048 QString cmcMeInfo::categoryName(void)
00049 {
00050   if( m_categoryName == "" )
00051   {
00052     QStringList pref = db()-> cv()-> getPreference("Me").split(vbCrLf);
00053     if( pref.count() > 0 ) m_categoryName = pref[0];
00054     if( pref.count() > 1 ) m_meItem = pref[1];
00055   }
00056 
00057   if( m_categoryName == "" )
00058   {
00059     qDebug( "MeInfo::categoryName - not set up" );
00060   }
00061 
00062   return( m_categoryName );
00063 }
00064 
00065 cmcCategoryDef * cmcMeInfo::categoryDef()
00066 {
00067   if( !m_categoryDef )
00068   {
00069     if( categoryName() != "" )
00070     {
00071       m_categoryDef = app()-> categoryDef( categoryName() );
00072    }
00073     else
00074     {
00075       qDebug( "MeInfo::categoryDef - not set up" );
00076     }
00077   }
00078 
00079   return( m_categoryDef );
00080 
00081 }
00082 
00083 
00084 QString cmcMeInfo::key()
00085 {
00086   if( m_key == "meKey?" || m_key == "" )
00087   {
00088     if( categoryDef() )
00089     {
00090       m_key = field( categoryDef()-> keyFieldName() );
00091     }
00092 
00093     if( m_key == "" ) 
00094     {
00095       m_key = "meKey?";
00096     }
00097   }
00098 
00099   return( m_key );
00100 }
00101 
00102 QString cmcMeInfo::cfy()
00103 {
00104   if( m_cfy == "" )
00105   {
00106     if( categoryDef() )
00107     {
00108       if( categoryDef()-> hasClarifyField() )
00109       {
00110         m_cfy = field( categoryDef()-> cfyFieldName() );
00111       }
00112     }
00113   }
00114 
00115   return( m_cfy );
00116 
00117 }
00118 
00119 QString cmcMeInfo::var()
00120 {
00121   if( m_var == "" )
00122   {
00123     if( categoryDef() )
00124     {
00125       if( categoryDef()-> hasVarField() )
00126       {
00127         m_var = field( categoryDef()-> varFieldName() );
00128       }
00129     }
00130   }
00131 
00132   return( m_var );
00133 }
00134 
00135 QString cmcMeInfo::logon()
00136 {
00137   if( m_logon == "" )
00138   {
00139     if( categoryDef() )
00140     {
00141        QStringList list = categoryDef()-> fieldDefs()-> list().filter( "logon", Qt::CaseInsensitive );
00142        if( list.count() > 0 )
00143        {
00144          m_logon = field( list[0] );
00145        }
00146     }
00147   }
00148 
00149   return( m_logon );
00150 }
00151 
00152 QString cmcMeInfo::abbreviation()
00153 {
00154   if( m_abbreviation == "XXX" || m_abbreviation == "" )
00155   {
00156     if( categoryDef() )
00157     {
00158       QStringList         list = categoryDef()-> fieldDefs()-> list().filter( "abbreviation", Qt::CaseInsensitive );
00159       if( !list.count() ) list = categoryDef()-> fieldDefs()-> list().filter( "initials",     Qt::CaseInsensitive );
00160       if(  list.count() ) m_abbreviation = field( list[0] );
00161     }
00162 
00163     if( m_abbreviation == "" )
00164     {
00165       if( var().contains("Abbreviation") )
00166       {
00167         m_abbreviation = cmcObject::var( var(), "Abbreviation" );
00168       }
00169       else if( key().length() == 3 )
00170       {
00171         m_abbreviation = key();
00172       }
00173       else
00174       {
00175         m_abbreviation = "XXX";
00176         qDebug( "MeInfo::abbreviation - not set up" );
00177       }
00178     }
00179   }
00180 
00181   return( m_abbreviation );
00182 
00183 }
00184 
00185 QString cmcMeInfo::thid()
00186 {
00187   if( m_thid == "" )
00188   {
00189     if( categoryDef() )
00190     {
00191       if( categoryDef()-> fieldDefs()-> contains( "thid" ) )
00192       {
00193         m_thid = field( "thid" );
00194       }
00195       else if( categoryDef()-> fieldDefs()-> contains( "cmcID" ) )
00196       {
00197         m_thid = field( "cmcID" );
00198       }
00199       else if( var().contains("thid") )
00200       {
00201         m_thid = cmcObject::var( var(), "thid" );
00202       }
00203       else if( var().contains("cmcID") )
00204       {
00205         m_thid = cmcObject::var( var(), "cmcID" );
00206       }
00207     }
00208   }
00209 
00210   return( m_thid );
00211 }
00212 
00213 QString cmcMeInfo::guid()
00214 {
00215   if( m_guid == "" )
00216   {
00217     if( categoryDef() )
00218     {
00219       if( categoryDef()-> fieldDefs()-> contains( "guid" ) )
00220       {
00221         m_guid = field( "guid" );
00222       }
00223       else if( var().contains("guid") )
00224       {
00225         m_guid = cmcObject::var( var(), "guid" );
00226       }
00227     }
00228   }
00229 
00230   return( m_guid );
00231 
00232 }
00233 
00234 QString cmcMeInfo::id()
00235 {
00236   QString retVal = abbreviation();
00237 
00238   if( thid() != "" &&
00239       thid() != "nothing" )
00240   {
00241     retVal += ":" + thid();
00242   }
00243 
00244   return( retVal );
00245 }
00246 
00247 /*
00248 ** I'm going to inject a small note on field mapping.  The field map 
00249 **  definition that Dumont wants to have is "meEmail".  IF that field
00250 **  map definition doesn't exist in the globalVar space, then Dumont
00251 **  will assume the meEmail value should be "employeeEmail".  Dumont
00252 **  is going to then look for the -Me- field name "employeeEmail" and
00253 **  return the value of that back to the caller.  
00254 **
00255 ** If your -Me- category does not contain a field "employeeEmail" for
00256 **  the employee email addresses, but that field is stored under a 
00257 **  different name, you can remap it by setting "meEmail" in one of the
00258 **  global storage spaces somewhere.  This is typically done in the
00259 **  dumontGlobal.ini file (in the Dumont category).  In that category
00260 **  item you should set a value "meEmail=SMS Alarm" which is the name
00261 **  of the field *i* was using on one of my databases.  "SMS Alarm" was
00262 **  a field that carried the employees palm or treo wireless email unit
00263 **  and basically got turned in to employee email addresses.
00264 **
00265 */
00266 QString cmcMeInfo::email()
00267 {
00268 //  if( m_email == "" )
00269 //      m_email = db()-> defaultVar( db()-> globalVar( "meEmail" ), "employeeEmail" );
00270 //  return( db()-> defaultVar( db()-> cv()-> getMeField(m_email), "me@email.unknown" ) );
00271   return( QString() );
00272 }  
00273 
00274 QString cmcMeInfo::field( const QString & fieldName )
00275 {
00276   QString retVal;
00277 
00278   if( categoryDef() )
00279   {
00280     retVal = db()-> cv()-> getMeField( fieldName );
00281   }
00282 
00283   return( retVal );
00284 }
00285 
00286 QString cmcMeInfo::varField( const QString & fieldName )
00287 {
00288   return( cmcObject::var( var(), fieldName ) );
00289 }
00290 
00291 
00292 
00293 
00294 } // endnamespace cmcDatabaseApi
00295 
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties




~ ~ ~ ~ ~ ~
Source Code without Comments is like a Cranberry Garland
without the berries. Comment your Code!
 
Commence Database User Support Group Forum
http://newsgroup.showoff-db.org/
~ ~ ~ ~ ~ ~
Author: Mark Petryk
Lorimark Solutions, LLC
mark@lorimarksolutions.com