Revert "Separating ThingRecord object from Thingy"
This reverts commit df84c60d6a.
This commit is contained in:
parent
a37f69cc04
commit
5fd30d8d84
3 changed files with 20 additions and 67 deletions
|
|
@ -34,7 +34,6 @@ addEMSSubmissionTables($session);
|
||||||
configEMSActivities($session);
|
configEMSActivities($session);
|
||||||
removeOldWebGUICSS($session);
|
removeOldWebGUICSS($session);
|
||||||
addUSPSInternationalShippingDriver( $session );
|
addUSPSInternationalShippingDriver( $session );
|
||||||
changeThingyThingTables( $session );
|
|
||||||
|
|
||||||
# upgrade functions go here
|
# upgrade functions go here
|
||||||
|
|
||||||
|
|
@ -50,35 +49,6 @@ finish($session); # this line required
|
||||||
# print "DONE!\n" unless $quiet;
|
# print "DONE!\n" unless $quiet;
|
||||||
#}
|
#}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
# Changing Thingy's Thing tables to conform with CRUD
|
|
||||||
|
|
||||||
sub changeThingyThingTables {
|
|
||||||
my $session = shift;
|
|
||||||
my $db = $session->db;
|
|
||||||
print "\tChanging Thingy's Thing tables to conform with CRUD ... " unless $quiet;
|
|
||||||
my $things = $db->read('select thingId from Thingy_things');
|
|
||||||
while (my @thing = $things->array) {
|
|
||||||
my $tableName = 'Thingy_'.$thing[0];
|
|
||||||
if($db->quickArray('show tables like "'.$tableName.'"')){
|
|
||||||
# Change lastUpdated column
|
|
||||||
$db->write('ALTER TABLE `'.$tableName.'` CHANGE `lastUpdated` `lastUpdated_unix_time` int(11) NOT NULL');
|
|
||||||
$db->write('ALTER TABLE `'.$tableName.'` ADD `lastUpdated` DATETIME NOT NULL');
|
|
||||||
$db->write('UPDATE `'.$tableName.'` SET `lastUpdated`=FROM_UNIXTIME(lastUpdated_unix_time)');
|
|
||||||
$db->write('ALTER TABLE `'.$tableName.'` DROP `lastUpdated_unix_time`');
|
|
||||||
# Change dateCreated column
|
|
||||||
$db->write('ALTER TABLE `'.$tableName.'` CHANGE `dateCreated` `dateCreated_unix_time` int(11) NOT NULL');
|
|
||||||
$db->write('ALTER TABLE `'.$tableName.'` ADD `dateCreated` DATETIME NOT NULL');
|
|
||||||
$db->write('UPDATE `'.$tableName.'` SET `dateCreated`=FROM_UNIXTIME(dateCreated_unix_time)');
|
|
||||||
$db->write('ALTER TABLE `'.$tableName.'` DROP `dateCreated_unix_time`');
|
|
||||||
# Add sequencenumber column
|
|
||||||
$db->write('ALTER TABLE `'.$tableName.'` ADD `sequencenumber` int(11) NOT NULL');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print "DONE!\n" unless $quiet;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Describe what our function does
|
# Describe what our function does
|
||||||
sub removeOldWebGUICSS {
|
sub removeOldWebGUICSS {
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,7 @@ use WebGUI::Form::File;
|
||||||
use WebGUI::DateTime;
|
use WebGUI::DateTime;
|
||||||
use base 'WebGUI::Asset::Wobject';
|
use base 'WebGUI::Asset::Wobject';
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use WebGUI::Asset::Wobject::Thingy::ThingRecord;
|
|
||||||
|
|
||||||
my $THING_RECORD_CLASS = 'WebGUI::Asset::Wobject::Thingy::ThingRecord';
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -134,13 +132,12 @@ sub addThing {
|
||||||
|
|
||||||
$db->write("create table ".$db->dbh->quote_identifier("Thingy_".$newThingId)."(
|
$db->write("create table ".$db->dbh->quote_identifier("Thingy_".$newThingId)."(
|
||||||
thingDataId CHAR(22) binary not null,
|
thingDataId CHAR(22) binary not null,
|
||||||
dateCreated datetime not null,
|
dateCreated int not null,
|
||||||
createdById CHAR(22) not null,
|
createdById CHAR(22) not null,
|
||||||
updatedById CHAR(22) not null,
|
updatedById CHAR(22) not null,
|
||||||
updatedByName CHAR(255) not null,
|
updatedByName CHAR(255) not null,
|
||||||
lastUpdated datetime not null,
|
lastUpdated int not null,
|
||||||
ipAddress CHAR(255),
|
ipAddress CHAR(255),
|
||||||
sequenceNumber int,
|
|
||||||
primary key (thingDataId)
|
primary key (thingDataId)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
|
||||||
|
|
||||||
|
|
@ -483,8 +480,7 @@ sub deleteThingData {
|
||||||
$self->triggerWorkflow($onDeleteWorkflowId, $thingId,$thingDataId);
|
$self->triggerWorkflow($onDeleteWorkflowId, $thingId,$thingDataId);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $thingRecord = $THING_RECORD_CLASS->new($self->session,$thingDataId,$thingId);
|
$self->deleteCollateral("Thingy_".$thingId,"thingDataId",$thingDataId);
|
||||||
$thingRecord->delete;
|
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
@ -547,18 +543,23 @@ sub editThingDataSave {
|
||||||
my (%thingData,$fields,@errors,$hadErrors,$newThingDataId);
|
my (%thingData,$fields,@errors,$hadErrors,$newThingDataId);
|
||||||
my $i18n = WebGUI::International->new($session, 'Asset_Thingy');
|
my $i18n = WebGUI::International->new($session, 'Asset_Thingy');
|
||||||
|
|
||||||
=cut
|
|
||||||
if ($thingDataId eq "new"){
|
if ($thingDataId eq "new"){
|
||||||
$thingData{dateCreated} = time();
|
$thingData{dateCreated} = time();
|
||||||
$thingData{createdById} = $session->user->userId;
|
$thingData{createdById} = $session->user->userId;
|
||||||
$thingData{ipAddress} = $session->env->getIp;
|
$thingData{ipAddress} = $session->env->getIp;
|
||||||
}
|
}
|
||||||
=cut
|
else {
|
||||||
unless ($thingDataId eq "new") {
|
|
||||||
%thingData = $session->db->quickHash("select * from ".$session->db->dbh->quote_identifier("Thingy_".$thingId)
|
%thingData = $session->db->quickHash("select * from ".$session->db->dbh->quote_identifier("Thingy_".$thingId)
|
||||||
." where thingDataId = ?",[$thingDataId]);
|
." where thingDataId = ?",[$thingDataId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%thingData = ( %thingData,
|
||||||
|
thingDataId=>$thingDataId,
|
||||||
|
updatedById=>$session->user->userId,
|
||||||
|
updatedByName=>$session->user->username,
|
||||||
|
lastUpDated=>time(),
|
||||||
|
);
|
||||||
|
|
||||||
$fields = $session->db->read('select * from Thingy_fields where assetId = ? and thingId = ? order by sequenceNumber',
|
$fields = $session->db->read('select * from Thingy_fields where assetId = ? and thingId = ? order by sequenceNumber',
|
||||||
[$self->get("assetId"),$thingId]);
|
[$self->get("assetId"),$thingId]);
|
||||||
while (my $field = $fields->hashRef) {
|
while (my $field = $fields->hashRef) {
|
||||||
|
|
@ -591,24 +592,16 @@ sub editThingDataSave {
|
||||||
$thingData{$fieldName} = $fieldValue;
|
$thingData{$fieldName} = $fieldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#$newThingDataId = $self->setCollateral("Thingy_".$thingId,"thingDataId",\%thingData,0,0);
|
$newThingDataId = $self->setCollateral("Thingy_".$thingId,"thingDataId",\%thingData,0,0);
|
||||||
|
|
||||||
# trigger workflow
|
# trigger workflow
|
||||||
my $thingRecord;
|
|
||||||
if($thingDataId eq "new"){
|
if($thingDataId eq "new"){
|
||||||
#$self->session->errorHandler->info('creating thing record, thingId: '.$thingId);
|
|
||||||
$thingRecord = $THING_RECORD_CLASS->create($session,$thingId,\%thingData);
|
|
||||||
my ($onAddWorkflowId) = $session->db->quickArray("select onAddWorkflowId from Thingy_things where thingId=?"
|
my ($onAddWorkflowId) = $session->db->quickArray("select onAddWorkflowId from Thingy_things where thingId=?"
|
||||||
,[$thingId]);
|
,[$thingId]);
|
||||||
if ($onAddWorkflowId){
|
if ($onAddWorkflowId){
|
||||||
$self->triggerWorkflow($onAddWorkflowId,$thingId,$newThingDataId);
|
$self->triggerWorkflow($onAddWorkflowId,$thingId,$newThingDataId);
|
||||||
}
|
}
|
||||||
}
|
}else{
|
||||||
else{
|
|
||||||
$thingRecord = $THING_RECORD_CLASS->new($session,$thingDataId,$thingId);
|
|
||||||
#$self->session->errorHandler->info('updating properties');
|
|
||||||
$thingRecord->update(\%thingData);
|
|
||||||
#$self->session->errorHandler->info('properties updated');
|
|
||||||
my ($onEditWorkflowId) = $session->db->quickArray("select onEditWorkflowId from Thingy_things where thingId=?"
|
my ($onEditWorkflowId) = $session->db->quickArray("select onEditWorkflowId from Thingy_things where thingId=?"
|
||||||
,[$thingId]);
|
,[$thingId]);
|
||||||
if ($onEditWorkflowId){
|
if ($onEditWorkflowId){
|
||||||
|
|
@ -616,7 +609,7 @@ sub editThingDataSave {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return($thingRecord->getId,\@errors);
|
return($newThingDataId,\@errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -1153,17 +1146,12 @@ If a tmpl var hashref is supplied tmpl_var's will be appended to that.
|
||||||
sub getViewThingVars {
|
sub getViewThingVars {
|
||||||
my ($self, $thingId, $thingDataId,$var) = @_;
|
my ($self, $thingId, $thingDataId,$var) = @_;
|
||||||
my $db = $self->session->db;
|
my $db = $self->session->db;
|
||||||
my (@field_loop, @viewScreenTitleFields, $viewScreenTitle, %thingData);
|
my (@field_loop, @viewScreenTitleFields, $viewScreenTitle);
|
||||||
|
|
||||||
return undef unless ($thingId && $thingDataId);
|
return undef unless ($thingId && $thingDataId);
|
||||||
|
|
||||||
my $thingRecord = $THING_RECORD_CLASS->new($self->session,$thingDataId,$thingId);
|
my %thingData = $db->quickHash("select * from ".$db->dbh->quote_identifier("Thingy_".$thingId)
|
||||||
if (defined $thingRecord){
|
." where thingDataId = ?",[$thingDataId]);
|
||||||
%thingData = %{$thingRecord->get};
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (%thingData) {
|
if (%thingData) {
|
||||||
my $fields = $db->read('select * from Thingy_fields where assetId = ? and thingId = ? order by sequenceNumber',
|
my $fields = $db->read('select * from Thingy_fields where assetId = ? and thingId = ? order by sequenceNumber',
|
||||||
|
|
|
||||||
|
|
@ -283,14 +283,10 @@ cmp_deeply(
|
||||||
'Getting updated thing data: getViewThingVars returns correct field_loop with updated value.'
|
'Getting updated thing data: getViewThingVars returns correct field_loop with updated value.'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$thingy->deleteThingData($thingId,$newThingDataId);
|
$thingy->deleteThingData($thingId,$newThingDataId);
|
||||||
|
|
||||||
my @thingDataIds = @{WebGUI::Asset::Wobject::Thingy::ThingRecord->getAllIds($session)};
|
is($thingy->getViewThingVars($thingId,$newThingDataId),undef,'Thing data was succesfully deleted, getViewThingVars returns undef.');
|
||||||
|
|
||||||
is(WebGUI::Utility::isIn(@thingDataIds,$newThingDataId),'0','Thing data was succesfully deleted');
|
|
||||||
|
|
||||||
=cut
|
|
||||||
$json = $thingy->www_viewThingDataViaAjax($thingId,$newThingDataId);
|
$json = $thingy->www_viewThingDataViaAjax($thingId,$newThingDataId);
|
||||||
$dataFromJSON = JSON->new->decode($json);
|
$dataFromJSON = JSON->new->decode($json);
|
||||||
|
|
||||||
|
|
@ -303,7 +299,6 @@ cmp_deeply(
|
||||||
);
|
);
|
||||||
|
|
||||||
($newThingDataId,$errors) = $thingy->editThingDataSave($thingId,'new',{"field_".$fieldId => 'second test value'});
|
($newThingDataId,$errors) = $thingy->editThingDataSave($thingId,'new',{"field_".$fieldId => 'second test value'});
|
||||||
=cut
|
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue