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
|
|
@ -20,9 +20,7 @@ use WebGUI::Form::File;
|
|||
use WebGUI::DateTime;
|
||||
use base 'WebGUI::Asset::Wobject';
|
||||
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)."(
|
||||
thingDataId CHAR(22) binary not null,
|
||||
dateCreated datetime not null,
|
||||
dateCreated int not null,
|
||||
createdById CHAR(22) not null,
|
||||
updatedById CHAR(22) not null,
|
||||
updatedByName CHAR(255) not null,
|
||||
lastUpdated datetime not null,
|
||||
lastUpdated int not null,
|
||||
ipAddress CHAR(255),
|
||||
sequenceNumber int,
|
||||
primary key (thingDataId)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
|
||||
|
||||
|
|
@ -483,8 +480,7 @@ sub deleteThingData {
|
|||
$self->triggerWorkflow($onDeleteWorkflowId, $thingId,$thingDataId);
|
||||
}
|
||||
|
||||
my $thingRecord = $THING_RECORD_CLASS->new($self->session,$thingDataId,$thingId);
|
||||
$thingRecord->delete;
|
||||
$self->deleteCollateral("Thingy_".$thingId,"thingDataId",$thingDataId);
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
|
@ -546,18 +542,23 @@ sub editThingDataSave {
|
|||
my $session = $self->session;
|
||||
my (%thingData,$fields,@errors,$hadErrors,$newThingDataId);
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Thingy');
|
||||
|
||||
=cut
|
||||
|
||||
if ($thingDataId eq "new"){
|
||||
$thingData{dateCreated} = time();
|
||||
$thingData{createdById} = $session->user->userId;
|
||||
$thingData{ipAddress} = $session->env->getIp;
|
||||
}
|
||||
=cut
|
||||
unless ($thingDataId eq "new") {
|
||||
else {
|
||||
%thingData = $session->db->quickHash("select * from ".$session->db->dbh->quote_identifier("Thingy_".$thingId)
|
||||
." 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',
|
||||
[$self->get("assetId"),$thingId]);
|
||||
|
|
@ -591,24 +592,16 @@ sub editThingDataSave {
|
|||
$thingData{$fieldName} = $fieldValue;
|
||||
}
|
||||
|
||||
#$newThingDataId = $self->setCollateral("Thingy_".$thingId,"thingDataId",\%thingData,0,0);
|
||||
$newThingDataId = $self->setCollateral("Thingy_".$thingId,"thingDataId",\%thingData,0,0);
|
||||
|
||||
# trigger workflow
|
||||
my $thingRecord;
|
||||
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=?"
|
||||
,[$thingId]);
|
||||
if ($onAddWorkflowId){
|
||||
$self->triggerWorkflow($onAddWorkflowId,$thingId,$newThingDataId);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$thingRecord = $THING_RECORD_CLASS->new($session,$thingDataId,$thingId);
|
||||
#$self->session->errorHandler->info('updating properties');
|
||||
$thingRecord->update(\%thingData);
|
||||
#$self->session->errorHandler->info('properties updated');
|
||||
}else{
|
||||
my ($onEditWorkflowId) = $session->db->quickArray("select onEditWorkflowId from Thingy_things where thingId=?"
|
||||
,[$thingId]);
|
||||
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 {
|
||||
my ($self, $thingId, $thingDataId,$var) = @_;
|
||||
my $db = $self->session->db;
|
||||
my (@field_loop, @viewScreenTitleFields, $viewScreenTitle, %thingData);
|
||||
my (@field_loop, @viewScreenTitleFields, $viewScreenTitle);
|
||||
|
||||
return undef unless ($thingId && $thingDataId);
|
||||
|
||||
my $thingRecord = $THING_RECORD_CLASS->new($self->session,$thingDataId,$thingId);
|
||||
if (defined $thingRecord){
|
||||
%thingData = %{$thingRecord->get};
|
||||
}
|
||||
else{
|
||||
return undef;
|
||||
}
|
||||
|
||||
my %thingData = $db->quickHash("select * from ".$db->dbh->quote_identifier("Thingy_".$thingId)
|
||||
." where thingDataId = ?",[$thingDataId]);
|
||||
|
||||
if (%thingData) {
|
||||
my $fields = $db->read('select * from Thingy_fields where assetId = ? and thingId = ? order by sequenceNumber',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue