Skip to content

Commit

Permalink
Removing the use of constants in entities. added conversion of data t…
Browse files Browse the repository at this point in the history
…ype string to owa_column and owa_db. supports #634
  • Loading branch information
padams committed Jun 28, 2020
1 parent 973e9bf commit 19b1461
Show file tree
Hide file tree
Showing 29 changed files with 394 additions and 931 deletions.
10 changes: 5 additions & 5 deletions modules/base/classes/column.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,26 @@ function getDefinition() {

$definition = '';

$definition .= $this->get('data_type');
$definition .= constant( $this->get('data_type') );

// Check for auto increment
if ($this->get('auto_increment') == true):
$definition .= ' '.OWA_DTD_AUTO_INCREMENT;
$definition .= ' '. constant('OWA_DTD_AUTO_INCREMENT');
endif;

// Check for auto Not null
if ($this->get('is_not_null') == true):
$definition .= ' '.OWA_DTD_NOT_NULL;
$definition .= ' ' . constant('OWA_DTD_NOT_NULL');
endif;

// Check for unique
if ($this->get('is_unique') == true):
$definition .= ' '.OWA_DTD_UNIQUE;
$definition .= ' ' . constant('OWA_DTD_UNIQUE');
endif;

// check for primary key
if ($this->get('is_primary_key') == true):
$definition .= ' '.OWA_DTD_PRIMARY_KEY;
$definition .= ' ' . constant('OWA_DTD_PRIMARY_KEY');
//$definition .= sprintf(", INDEX (%s)", $this->get('name'));
endif;

Expand Down
66 changes: 33 additions & 33 deletions modules/base/classes/factTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,88 +36,88 @@ function __construct() {

$columns = array();

$columns['id'] = new owa_dbColumn('id', OWA_DTD_BIGINT);
$columns['id'] = new owa_dbColumn('id', 'OWA_DTD_BIGINT');
$columns['id']->setPrimaryKey();

$columns['visitor_id'] = new owa_dbColumn('visitor_id', OWA_DTD_BIGINT);
$columns['visitor_id'] = new owa_dbColumn('visitor_id', 'OWA_DTD_BIGINT');
$columns['visitor_id']->setForeignKey('base.visitor');

$columns['session_id'] = new owa_dbColumn('session_id', OWA_DTD_BIGINT);
$columns['session_id'] = new owa_dbColumn('session_id', 'OWA_DTD_BIGINT');
$columns['session_id']->setForeignKey('base.session');
$columns['session_id']->setIndex();

$columns['site_id'] = new owa_dbColumn('site_id', OWA_DTD_VARCHAR255);
$columns['site_id'] = new owa_dbColumn('site_id', 'OWA_DTD_VARCHAR255');
$columns['site_id']->setForeignKey('base.site', 'site_id');
$columns['site_id']->setIndex();

$columns['referer_id'] = new owa_dbColumn('referer_id', OWA_DTD_BIGINT);
$columns['referer_id'] = new owa_dbColumn('referer_id', 'OWA_DTD_BIGINT');
$columns['referer_id']->setForeignKey('base.referer');

$columns['ua_id'] = new owa_dbColumn('ua_id', OWA_DTD_BIGINT);
$columns['ua_id'] = new owa_dbColumn('ua_id', 'OWA_DTD_BIGINT');
$columns['ua_id']->setForeignKey('base.ua');

$columns['host_id'] = new owa_dbColumn('host_id', OWA_DTD_BIGINT);
$columns['host_id'] = new owa_dbColumn('host_id', 'OWA_DTD_BIGINT');
$columns['host_id']->setForeignKey('base.host');

$columns['os_id'] = new owa_dbColumn('os_id', OWA_DTD_BIGINT);
$columns['os_id'] = new owa_dbColumn('os_id', 'OWA_DTD_BIGINT');
$columns['os_id']->setForeignKey('base.os');

$columns['location_id'] = new owa_dbColumn('location_id', OWA_DTD_BIGINT);
$columns['location_id'] = new owa_dbColumn('location_id', 'OWA_DTD_BIGINT');
$columns['location_id']->setForeignKey('base.location_dim');

$columns['referring_search_term_id'] = new owa_dbColumn('referring_search_term_id', OWA_DTD_BIGINT);
$columns['referring_search_term_id'] = new owa_dbColumn('referring_search_term_id', 'OWA_DTD_BIGINT');
$columns['referring_search_term_id']->setForeignKey('base.search_term_dim');

$columns['timestamp'] = new owa_dbColumn('timestamp', OWA_DTD_INT);
$columns['timestamp'] = new owa_dbColumn('timestamp', 'OWA_DTD_INT');

$columns['yyyymmdd'] = new owa_dbColumn('yyyymmdd', OWA_DTD_INT);
$columns['yyyymmdd'] = new owa_dbColumn('yyyymmdd', 'OWA_DTD_INT');
$columns['yyyymmdd']->setIndex();

$columns['year'] = new owa_dbColumn('year', OWA_DTD_INT);
$columns['month'] = new owa_dbColumn('month', OWA_DTD_INT);
$columns['day'] = new owa_dbColumn('day', OWA_DTD_TINYINT2);
$columns['dayofweek'] = new owa_dbColumn('dayofweek', OWA_DTD_VARCHAR10);
$columns['dayofyear'] = new owa_dbColumn('dayofyear', OWA_DTD_INT);
$columns['weekofyear'] = new owa_dbColumn('weekofyear', OWA_DTD_INT);
$columns['year'] = new owa_dbColumn('year', 'OWA_DTD_INT');
$columns['month'] = new owa_dbColumn('month', 'OWA_DTD_INT');
$columns['day'] = new owa_dbColumn('day', 'OWA_DTD_TINYINT2');
$columns['dayofweek'] = new owa_dbColumn('dayofweek', 'OWA_DTD_VARCHAR10');
$columns['dayofyear'] = new owa_dbColumn('dayofyear', 'OWA_DTD_INT');
$columns['weekofyear'] = new owa_dbColumn('weekofyear', 'OWA_DTD_INT');

$columns['last_req'] = new owa_dbColumn( 'last_req', OWA_DTD_BIGINT );
$columns['last_req'] = new owa_dbColumn( 'last_req', 'OWA_DTD_BIGINT' );

$columns['ip_address'] = new owa_dbColumn('ip_address', OWA_DTD_VARCHAR255);
$columns['ip_address'] = new owa_dbColumn('ip_address', 'OWA_DTD_VARCHAR255');

$columns['is_new_visitor'] = new owa_dbColumn('is_new_visitor', OWA_DTD_BOOLEAN);
$columns['is_new_visitor'] = new owa_dbColumn('is_new_visitor', 'OWA_DTD_BOOLEAN');

$columns['is_repeat_visitor'] = new owa_dbColumn('is_repeat_visitor', OWA_DTD_BOOLEAN);
$columns['is_repeat_visitor'] = new owa_dbColumn('is_repeat_visitor', 'OWA_DTD_BOOLEAN');

$columns['language'] = new owa_dbColumn('language', OWA_DTD_VARCHAR255);
$columns['language'] = new owa_dbColumn('language', 'OWA_DTD_VARCHAR255');

$columns['days_since_prior_session'] = new owa_dbColumn( 'days_since_prior_session', OWA_DTD_INT );
$columns['days_since_prior_session'] = new owa_dbColumn( 'days_since_prior_session', 'OWA_DTD_INT' );

$columns['days_since_first_session'] = new owa_dbColumn( 'days_since_first_session', OWA_DTD_INT );
$columns['days_since_first_session'] = new owa_dbColumn( 'days_since_first_session', 'OWA_DTD_INT' );

$columns['num_prior_sessions'] = new owa_dbColumn( 'num_prior_sessions', OWA_DTD_INT );
$columns['num_prior_sessions'] = new owa_dbColumn( 'num_prior_sessions', 'OWA_DTD_INT' );

$columns['medium'] = new owa_dbColumn( 'medium', OWA_DTD_VARCHAR255 );
$columns['medium'] = new owa_dbColumn( 'medium', 'OWA_DTD_VARCHAR255' );

$columns['source_id'] = new owa_dbColumn( 'source_id', OWA_DTD_BIGINT );
$columns['source_id'] = new owa_dbColumn( 'source_id', 'OWA_DTD_BIGINT' );
$columns['source_id']->setForeignKey('base.source_dim');

$columns['ad_id'] = new owa_dbColumn( 'ad_id', OWA_DTD_BIGINT );
$columns['ad_id'] = new owa_dbColumn( 'ad_id', 'OWA_DTD_BIGINT' );
$columns['ad_id']->setForeignKey('base.ad_dim');

$columns['campaign_id'] = new owa_dbColumn( 'campaign_id', OWA_DTD_BIGINT );
$columns['campaign_id'] = new owa_dbColumn( 'campaign_id', 'OWA_DTD_BIGINT' );
$columns['campaign_id']->setForeignKey( 'base.campaign_dim' );

$columns['user_name'] = new owa_dbColumn( 'user_name', OWA_DTD_VARCHAR255 );
$columns['user_name'] = new owa_dbColumn( 'user_name', 'OWA_DTD_VARCHAR255' );

// custom variable columns
$cv_max = owa_coreAPI::getSetting( 'base', 'maxCustomVars' );
for ($i = 1; $i <= $cv_max;$i++) {

$cvar_name_col = 'cv'.$i.'_name';
$columns[$cvar_name_col] = new owa_dbColumn( $cvar_name_col, OWA_DTD_VARCHAR255 );
$columns[$cvar_name_col] = new owa_dbColumn( $cvar_name_col, 'OWA_DTD_VARCHAR255' );

$cvar_value_col = 'cv'.$i.'_value';
$columns[$cvar_value_col] = new owa_dbColumn( $cvar_value_col, OWA_DTD_VARCHAR255 );
$columns[$cvar_value_col] = new owa_dbColumn( $cvar_value_col, 'OWA_DTD_VARCHAR255' );
}

return $columns;
Expand Down
10 changes: 5 additions & 5 deletions modules/base/entities/action_fact.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ function __construct() {
$this->setProperty($pcolumn);
}

$document_id = new owa_dbColumn('document_id', OWA_DTD_BIGINT);
$document_id = new owa_dbColumn('document_id', 'OWA_DTD_BIGINT');
$document_id->setForeignKey('base.document');
$this->setProperty($document_id);

$action_name = new owa_dbColumn('action_name', OWA_DTD_VARCHAR255);
$action_name = new owa_dbColumn('action_name', 'OWA_DTD_VARCHAR255');
$this->setProperty($action_name);

$action_label = new owa_dbColumn('action_label', OWA_DTD_VARCHAR255);
$action_label = new owa_dbColumn('action_label', 'OWA_DTD_VARCHAR255');
$this->setProperty($action_label);

$action_group = new owa_dbColumn('action_group', OWA_DTD_VARCHAR255);
$action_group = new owa_dbColumn('action_group', 'OWA_DTD_VARCHAR255');
$this->setProperty($action_group);

$numeric_value = new owa_dbColumn('numeric_value', OWA_DTD_INT);
$numeric_value = new owa_dbColumn('numeric_value', 'OWA_DTD_INT');
$this->setProperty($numeric_value);
}
}
Expand Down
6 changes: 3 additions & 3 deletions modules/base/entities/ad_dim.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ function __construct() {
$this->setCachable();
// properties
$this->properties['id'] = new owa_dbColumn;
$this->properties['id']->setDataType(OWA_DTD_BIGINT);
$this->properties['id']->setDataType('OWA_DTD_BIGINT');
$this->properties['id']->setPrimaryKey();
$this->properties['name'] = new owa_dbColumn;
$this->properties['name']->setDataType(OWA_DTD_VARCHAR255);
$this->properties['name']->setDataType('OWA_DTD_VARCHAR255');
$this->properties['type'] = new owa_dbColumn;
$this->properties['type']->setDataType(OWA_DTD_VARCHAR255);
$this->properties['type']->setDataType('OWA_DTD_VARCHAR255');
}
}

Expand Down
4 changes: 2 additions & 2 deletions modules/base/entities/campaign_dim.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ function __construct() {
$this->setCachable();
// properties
$this->properties['id'] = new owa_dbColumn;
$this->properties['id']->setDataType(OWA_DTD_BIGINT);
$this->properties['id']->setDataType('OWA_DTD_BIGINT');
$this->properties['id']->setPrimaryKey();
$this->properties['name'] = new owa_dbColumn;
$this->properties['name']->setDataType(OWA_DTD_VARCHAR255);
$this->properties['name']->setDataType('OWA_DTD_VARCHAR255');
}
}

Expand Down
123 changes: 29 additions & 94 deletions modules/base/entities/click.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,142 +44,77 @@ function __construct() {
$this->setProperty($pcolumn);
}

// move to abstract
//$this->properties['id'] = new owa_dbColumn;
//$this->properties['id']->setDataType(OWA_DTD_BIGINT);
//$this->properties['id']->setPrimaryKey();


// drop
$this->properties['last_impression_id'] = new owa_dbColumn;
$this->properties['last_impression_id']->setDataType(OWA_DTD_BIGINT);

// move to abstract
//$visitor_id = new owa_dbColumn('visitor_id', OWA_DTD_BIGINT);
//$visitor_id->setForeignKey('base.visitor');
//$this->setProperty($visitor_id);

// move to abstract
//$session_id = new owa_dbColumn('session_id', OWA_DTD_BIGINT);
//$session_id->setForeignKey('base.session');
//$this->setProperty($session_id);
$this->properties['last_impression_id']->setDataType('OWA_DTD_BIGINT');

$document_id = new owa_dbColumn('document_id', OWA_DTD_BIGINT);
$document_id = new owa_dbColumn('document_id', 'OWA_DTD_BIGINT');
$document_id->setForeignKey('base.document');
$this->setProperty($document_id);

$this->properties['target_id'] = new owa_dbColumn;
$this->properties['target_id']->setDataType(OWA_DTD_BIGINT);
$this->properties['target_id']->setDataType('OWA_DTD_BIGINT');

$this->properties['target_url'] = new owa_dbColumn;
$this->properties['target_url']->setDataType(OWA_DTD_VARCHAR255);

// move to abstract
//$this->properties['timestamp'] = new owa_dbColumn;
//$this->properties['timestamp']->setDataType(OWA_DTD_INT);
/*
$this->properties['year'] = new owa_dbColumn;
$this->properties['year']->setDataType(OWA_DTD_INT);
$this->properties['month'] = new owa_dbColumn;
$this->properties['month']->setDataType(OWA_DTD_INT);
$this->properties['day'] = new owa_dbColumn;
$this->properties['day']->setDataType(OWA_DTD_INT);
$this->properties['dayofyear'] = new owa_dbColumn;
$this->properties['dayofyear']->setDataType(OWA_DTD_INT);
$this->properties['weekofyear'] = new owa_dbColumn;
$this->properties['weekofyear']->setDataType(OWA_DTD_INT);
*/
$this->properties['target_url']->setDataType('OWA_DTD_VARCHAR255');

// drop these soon
$this->properties['hour'] = new owa_dbColumn;
$this->properties['hour']->setDataType(OWA_DTD_TINYINT2);
$this->properties['hour']->setDataType('OWA_DTD_TINYINT2');
$this->properties['minute'] = new owa_dbColumn;
$this->properties['minute']->setDataType(OWA_DTD_TINYINT2);
$this->properties['minute']->setDataType('OWA_DTD_TINYINT2');
$this->properties['second'] = new owa_dbColumn;
$this->properties['second']->setDataType(OWA_DTD_INT);
$this->properties['second']->setDataType('OWA_DTD_INT');
$this->properties['msec'] = new owa_dbColumn;
$this->properties['msec']->setDataType(OWA_DTD_VARCHAR255);
$this->properties['msec']->setDataType('OWA_DTD_VARCHAR255');

$this->properties['click_x'] = new owa_dbColumn;
$this->properties['click_x']->setDataType(OWA_DTD_INT);
$this->properties['click_x']->setDataType('OWA_DTD_INT');
$this->properties['click_y'] = new owa_dbColumn;
$this->properties['click_y']->setDataType(OWA_DTD_INT);
$this->properties['click_y']->setDataType('OWA_DTD_INT');
$this->properties['page_width'] = new owa_dbColumn;
$this->properties['page_width']->setDataType(OWA_DTD_INT);
$this->properties['page_width']->setDataType('OWA_DTD_INT');
$this->properties['page_height'] = new owa_dbColumn;
$this->properties['page_height']->setDataType(OWA_DTD_INT);
$this->properties['page_height']->setDataType('OWA_DTD_INT');
$this->properties['position'] = new owa_dbColumn;
$this->properties['position']->setDataType(OWA_DTD_INT);
$this->properties['position']->setDataType('OWA_DTD_INT');
$this->properties['approx_position'] = new owa_dbColumn;
$this->properties['approx_position']->setDataType(OWA_DTD_BIGINT);
$this->properties['approx_position']->setDataType('OWA_DTD_BIGINT');
$this->properties['dom_element_x'] = new owa_dbColumn;
$this->properties['dom_element_x']->setDataType(OWA_DTD_INT);
$this->properties['dom_element_x']->setDataType('OWA_DTD_INT');
$this->properties['dom_element_y'] = new owa_dbColumn;
$this->properties['dom_element_y']->setDataType(OWA_DTD_INT);
$this->properties['dom_element_y']->setDataType('OWA_DTD_INT');
$this->properties['dom_element_name'] = new owa_dbColumn;
$this->properties['dom_element_name']->setDataType(OWA_DTD_VARCHAR255);
$this->properties['dom_element_name']->setDataType('OWA_DTD_VARCHAR255');
$this->properties['dom_element_id'] = new owa_dbColumn;
$this->properties['dom_element_id']->setDataType(OWA_DTD_VARCHAR255);
$this->properties['dom_element_id']->setDataType('OWA_DTD_VARCHAR255');
$this->properties['dom_element_value'] = new owa_dbColumn;
$this->properties['dom_element_value']->setDataType(OWA_DTD_VARCHAR255);
$this->properties['dom_element_value']->setDataType('OWA_DTD_VARCHAR255');
$this->properties['dom_element_tag'] = new owa_dbColumn;
$this->properties['dom_element_tag']->setDataType(OWA_DTD_VARCHAR255);
$this->properties['dom_element_tag']->setDataType('OWA_DTD_VARCHAR255');
$this->properties['dom_element_text'] = new owa_dbColumn;
$this->properties['dom_element_text']->setDataType(OWA_DTD_VARCHAR255);
$this->properties['dom_element_text']->setDataType('OWA_DTD_VARCHAR255');
$this->properties['dom_element_class'] = new owa_dbColumn;
$this->properties['dom_element_class']->setDataType(OWA_DTD_VARCHAR255);
$this->properties['dom_element_class']->setDataType('OWA_DTD_VARCHAR255');
$this->properties['dom_element_parent_id'] = new owa_dbColumn;
$this->properties['dom_element_parent_id']->setDataType(OWA_DTD_VARCHAR255);
$this->properties['dom_element_parent_id']->setDataType('OWA_DTD_VARCHAR255');

// drop
$this->properties['tag_id'] = new owa_dbColumn;
$this->properties['tag_id']->setDataType(OWA_DTD_BIGINT);
$this->properties['tag_id']->setDataType('OWA_DTD_BIGINT');

//drop
$this->properties['placement_id'] = new owa_dbColumn;
$this->properties['placement_id']->setDataType(OWA_DTD_BIGINT);

// move to abstract
//$this->properties['campaign_id'] = new owa_dbColumn;
//$this->properties['campaign_id']->setDataType(OWA_DTD_BIGINT);
$this->properties['placement_id']->setDataType('OWA_DTD_BIGINT');

//drop
$this->properties['ad_group_id'] = new owa_dbColumn;
$this->properties['ad_group_id']->setDataType(OWA_DTD_BIGINT);

// move to abstract
//$this->properties['ad_id'] = new owa_dbColumn;
//$this->properties['ad_id']->setDataType(OWA_DTD_BIGINT);

// move to absctract
//$site_id = new owa_dbColumn('site_id', OWA_DTD_VARCHAR255);
//$site_id->setForeignKey('base.site', 'site_id');
//$this->setProperty($site_id);

// move to absctract
//$ua_id = new owa_dbColumn('ua_id', OWA_DTD_BIGINT);
//$ua_id->setForeignKey('base.ua');
//$this->setProperty($ua_id);

// move to abstract
//$this->properties['ip_address'] = new owa_dbColumn;
//$this->properties['ip_address']->setDataType(OWA_DTD_VARCHAR255);
$this->properties['ad_group_id']->setDataType('OWA_DTD_BIGINT');

// drop
$this->properties['host'] = new owa_dbColumn;
$this->properties['host']->setDataType(OWA_DTD_VARCHAR255);

// move to abstract
//wrong data type
//$host_id = new owa_dbColumn('host_id', OWA_DTD_VARCHAR255);
//$host_id->setForeignKey('base.host');
//$this->setProperty($host_id);

// move to abstract
//$yyyymmdd = new owa_dbColumn;
//$yyyymmdd->setName('yyyymmdd');
//$yyyymmdd->setDataType(OWA_DTD_INT);
//$yyyymmdd->setIndex();
//$this->setProperty($yyyymmdd);

$this->properties['host']->setDataType('OWA_DTD_VARCHAR255');
}
}

Expand Down

0 comments on commit 19b1461

Please sign in to comment.