DumontEXE 0.0.1
cmcCategoryDef.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 <QVariant>
00026 
00027 #include "cmcConversation.h"
00028 #include "cmcCategoryDef.h"
00029 #include "cmcCategoryDefs.h"
00030 #include "cmcFieldDefs.h"
00031 #include "cmcFieldDef.h"
00032 #include "cmcConnectionDefs.h"
00033 #include "cmcFormDefs.h"
00034 #include "cmcViewDefs.h"
00035 
00036 namespace cmcDatabaseApi {
00037 
00038 cmcCategoryDef::cmcCategoryDef( const cmcCategoryDef & copy ):
00039   cmcObject( copy )
00040 {
00041 }
00042 
00043 cmcCategoryDef::cmcCategoryDef( const QString & categoryName, cmcApplication * application, cmcCategoryDefs * parent ):
00044   cmcObject( categoryName, application, parent )
00045 {
00046 //  fieldDefs();
00047 //  connectionDefs();
00048 //  formDefs();
00049 //  viewDefs();
00050 
00051 }
00052 
00053 
00054 cmcCategoryDef::~cmcCategoryDef()
00055 {
00056 //  TRACE_FUNCTION
00057 }
00058 
00059 QString cmcCategoryDef::categoryName() 
00060 { 
00061   return(name()); 
00062 }
00063 
00064 QString cmcCategoryDef::catName(  )
00065 {
00066   /*
00067   ** Simplify the category name by removing leading and trailing spaces
00068   **  and converting all double-space to single-space.
00069   **
00070   */
00071   QString retVal = name().simplified();
00072 
00073   /*
00074   ** Remove any single-space to nothing.
00075   **
00076   */
00077   retVal = retVal.replace(" ","");
00078 
00079   /*
00080   ** Make sure the first character is lower-case.
00081   **
00082   */
00083   retVal = retVal.left(1).toLower() + retVal.right( retVal.length() - 1 );
00084 
00085   /*
00086   ** Return the simplified category name.
00087   **
00088   */
00089   return( retVal );
00090 
00091 }
00092 
00093 QStringList cmcCategoryDef::stringList()
00094 {
00095   if(     m_definition.count() == 0 )
00096           m_definition = cv()-> getCategoryDefinition( name() ).split("\r\n");
00097   return( m_definition );
00098 }
00099 
00100 QString cmcCategoryDef::string()
00101 {
00102   return( m_definition.join("\r\n") );
00103 }
00104 
00105 long cmcCategoryDef::maxItems()
00106 {
00107   return( stringList()[0].toLong() );
00108 }
00109 
00110 bool cmcCategoryDef::isShared()
00111 {
00112 //  qDebug( "stringList %s", qPrintable(cv()-> getCategoryDefinition( name())) );
00113   if( stringList()[1].mid(6,1) == "1" ) return(true);
00114   return(false);
00115 }
00116 
00117 bool cmcCategoryDef::duplicatesAllowed()
00118 {
00119   if( stringList()[1].mid(8,1) == "1" ) return(true);
00120   return(false);
00121 }
00122 
00123 
00124 bool cmcCategoryDef::hasClarifyField()
00125 {
00126   if( stringList()[1].mid(9,1) == "1" )  return(true);
00127   return(false);
00128 }
00129 
00130 bool cmcCategoryDef::hasCfyField()
00131 {
00132   return( hasClarifyField() );
00133 }
00134 
00135 bool cmcCategoryDef::hasVarField()
00136 {
00137   return( fieldDefs()-> list().contains( varFieldName() ) );
00138 }
00139 
00140 bool cmcCategoryDef::hasThidField()
00141 {
00142   return( fieldDefs()-> list().contains( thidFieldName() ) );
00143 }
00144 
00145 bool cmcCategoryDef::hasGuidField()
00146 {
00147   return( fieldDefs()-> list().contains( guidFieldName() ) );
00148 }
00149 
00150 QString cmcCategoryDef::keyFieldName(  )
00151 {
00152   return( fieldDefs()-> get(0)-> name() );
00153 }
00154 
00155 QString cmcCategoryDef::clarifyFieldName()
00156 {
00157   return( cfyFieldName() );
00158 }
00159 
00160 QString cmcCategoryDef::cfyFieldName()
00161 {
00162   QString retVal = stringList()[3];
00163 
00164   /*
00165   ** If this category doesn't have a clarify field
00166   **  defined, then check for a couple of other options.
00167   **
00168   */
00169   if( retVal == "" ) 
00170     if( fieldDefs()-> contains( "Clarify" ) )
00171       retVal = "Clarify";
00172 
00173   if( retVal == "" )
00174     if( fieldDefs()-> contains( catName() + "Cfy" ) )
00175       retVal = catName() + "Cfy";
00176 
00177   return( retVal );
00178 
00179 }
00180 
00181 QString cmcCategoryDef::cfySeparator(  )
00182 {
00183   return( stringList()[2] );
00184 }
00185 
00186 QString cmcCategoryDef::clarifySeparator()
00187 {
00188   return( cfySeparator() );
00189 }
00190 
00191 QString cmcCategoryDef::thidFieldName(  )
00192 {
00193   return( property( "thidFieldName", catName() + "Thid" ).toString() );
00194 }
00195 
00196 void cmcCategoryDef::setThidFieldName( const QString & name )
00197 {
00198   setProperty( "thidFieldName", name );
00199 }
00200 
00201 void cmcCategoryDef::rstThidFieldName(  )
00202 {
00203   setProperty( "thidFieldName", catName() + "Thid" );
00204 }
00205 
00206 QString cmcCategoryDef::guidFieldName(  )
00207 {
00208   return( property( "guidFieldName", catName() + "Guid" ).toString() );
00209 }
00210 
00211 void cmcCategoryDef::setGuidFieldName( const QString & name )
00212 {
00213   setProperty( "guidFieldName", name );
00214 }
00215 
00216 void cmcCategoryDef::rstGuidFieldName(  )
00217 {
00218   setProperty( "guidFieldName", catName() + "Guid" );
00219 }
00220 
00221 QString cmcCategoryDef::varFieldName(  )
00222 {
00223   return( property( "varFieldName", catName() + "Var" ).toString() );
00224 }
00225 
00226 void cmcCategoryDef::setVarFieldName( const QString & name )
00227 {
00228   setProperty( "varFieldName", name );
00229 }
00230 
00231 void cmcCategoryDef::rstVarFieldName(  )
00232 {
00233   setProperty( "varFieldName", catName() + "Var" );
00234 }
00235 
00236 bool cmcCategoryDef::isPublished()
00237 {
00238   return( property( "isPublished", true ).toBool() );
00239 }
00240 
00241 void cmcCategoryDef::setIsPublished( bool state )
00242 {
00243   setProperty( "isPublished", state );
00244 }
00245 
00246 void cmcCategoryDef::rstIsPublished(  )
00247 {
00248   setProperty( "isPublished", true );
00249 }
00250 
00251 long cmcCategoryDef::colCount()
00252 {
00253   return( columnCount() );
00254 }
00255 
00256 long cmcCategoryDef::columnCount()
00257 {
00258   return( fieldDefs()-> count() + connectionDefs()-> count() );
00259 }
00260 
00261 cmcFieldDefs * cmcCategoryDef::fieldDefs()
00262 {
00263   if( !m_cmcFieldDefs )
00264        m_cmcFieldDefs = new cmcFieldDefs(this);
00265   return( m_cmcFieldDefs );
00266 }
00267 
00268 cmcFieldDef * cmcCategoryDef::fieldDef( const QString & name )
00269 {
00270   return( fieldDefs()-> get( name ) );
00271 }
00272 
00273 cmcFieldDef * cmcCategoryDef::fieldDef( long index )
00274 {
00275   return( fieldDefs()-> get( index ) );
00276 }
00277 
00278 cmcConnectionDefs * cmcCategoryDef::connectionDefs()
00279 {
00280   if(    !m_cmcConnectionDefs )
00281           m_cmcConnectionDefs = new cmcConnectionDefs(this);
00282   return( m_cmcConnectionDefs );
00283 }
00284 
00285 cmcConnectionDef * cmcCategoryDef::connectionDef( const QString & name )
00286 {
00287   return( connectionDefs()-> get( name ) );
00288 }
00289 
00290 cmcConnectionDef * cmcCategoryDef::connectionDef( long index )
00291 {
00292   return( connectionDefs()-> get( index ) );
00293 }
00294 
00295 
00296 
00297 cmcFormDefs * cmcCategoryDef::formDefs()
00298 {
00299   if(    !m_cmcFormDefs )
00300           m_cmcFormDefs = new cmcFormDefs(this);
00301   return( m_cmcFormDefs );
00302 }
00303 
00304 cmcFormDef * cmcCategoryDef::formDef( const QString & name )
00305 {
00306   return( formDefs()-> get( name ) );
00307 }
00308 
00309 cmcFormDef * cmcCategoryDef::formDef( long index )
00310 {
00311   return( formDefs()-> get( index ) );
00312 }
00313 
00314 
00315 
00316 
00317 cmcViewDefs * cmcCategoryDef::viewDefs()
00318 {
00319   if(    !m_cmcViewDefs )
00320           m_cmcViewDefs = new cmcViewDefs(this);
00321   return( m_cmcViewDefs );
00322 }
00323 
00324 cmcViewDef * cmcCategoryDef::viewDef( const QString & name )
00325 {
00326   return( viewDefs()-> get( name ) );
00327 }
00328 
00329 cmcViewDef * cmcCategoryDef::viewDef( long index )
00330 {
00331   return( viewDefs()-> get( index ) );
00332 }
00333 
00334 
00335 
00336 bool cmcCategoryDef::isConnection( QString fieldName )
00337 {
00338   return( connectionDefs()-> contains( fieldName ) );
00339 }
00340 
00341 bool cmcCategoryDef::isField( QString fieldName )
00342 {
00343   return( fieldDefs()-> contains( fieldName ) );
00344 }
00345 
00346 
00347 
00348 
00349 } // endnamespace Commence
00350 
 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