fixed: Thingy: field sequence not imported correctly for existing Thingies
This commit is contained in:
parent
4f0ea8d9ad
commit
539957df52
3 changed files with 28 additions and 7 deletions
|
|
@ -8,6 +8,7 @@
|
|||
- fixed: Thingy: "add" and "edit" permission problem
|
||||
- fixed: EMail field rejects some valid email addresses
|
||||
- fixed: Calendar date localization can be broken
|
||||
- fixed: Thingy: field sequence not imported correctly for existing Thingies
|
||||
|
||||
7.5.9
|
||||
- fixed: Collaboration System attachments follow site's max size instead of CS's
|
||||
|
|
|
|||
|
|
@ -425,6 +425,11 @@ If this collateral data set is not grouped by assetId, but by another column the
|
|||
|
||||
If you've specified a setName you may also set a value for that set. Defaults to the value for this id from the wobject properties.
|
||||
|
||||
=head3 updateSequence
|
||||
|
||||
If set to "1" an update of existing collateral data will also update the sequence number. This option is used when
|
||||
importing collateral data in a package. Defaults to "0".
|
||||
|
||||
=cut
|
||||
|
||||
sub setCollateral {
|
||||
|
|
@ -436,11 +441,13 @@ sub setCollateral {
|
|||
my $useAssetId = shift;
|
||||
my $setName = shift || "assetId";
|
||||
my $setValue = shift || $self->get($setName);
|
||||
my $updateSequence = shift;
|
||||
my $db = $self->session->db;
|
||||
my ($key, $seq, $dbkeys, $dbvalues);
|
||||
my $counter = 0;
|
||||
my $sql;
|
||||
if ($properties->{$keyName} eq "new" || $properties->{$keyName} eq "") {
|
||||
|
||||
if ($properties->{$keyName} eq "new" || $properties->{$keyName} eq "") {
|
||||
$properties->{$keyName} = $self->session->id->generate();
|
||||
$sql = "insert into ".$db->dbh->quote_identifier($table)." (";
|
||||
my $dbkeys = "";
|
||||
|
|
@ -468,7 +475,7 @@ sub setCollateral {
|
|||
} else {
|
||||
$sql = "update ".$db->dbh->quote_identifier($table)." set ";
|
||||
foreach my $key (keys %{$properties}) {
|
||||
unless ($key eq "sequenceNumber") {
|
||||
unless ($key eq "sequenceNumber" && $updateSequence ne "1") {
|
||||
$sql .= ',' if ($counter++ > 0);
|
||||
$sql .= $db->dbh->quote_identifier($key)."=".$db->quote($properties->{$key});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,6 +253,10 @@ The id of the field that should be deleted.
|
|||
|
||||
The id of the thing to which the field to be deleted belongs.
|
||||
|
||||
=head3 keepSequenceNumbers
|
||||
|
||||
Boolean indicating that the sequence numbers should not be changed. This is used by importAssetCollateralData.
|
||||
|
||||
=cut
|
||||
|
||||
sub deleteField {
|
||||
|
|
@ -260,12 +264,20 @@ sub deleteField {
|
|||
my $self = shift;
|
||||
my $fieldId = shift;
|
||||
my $thingId = shift;
|
||||
my $keepSequenceNumbers = shift;
|
||||
my $db = $self->session->db;
|
||||
my $error = $self->session->errorHandler;
|
||||
my $deletedSequenceNumber;
|
||||
|
||||
my ($deletedSequenceNumber) = $db->quickArray("select sequenceNumber from Thingy_fields where fieldId = ?",[$fieldId]);
|
||||
if ($keepSequenceNumbers ne "1"){
|
||||
($deletedSequenceNumber) = $db->quickArray("select sequenceNumber from Thingy_fields where fieldId = ?"
|
||||
,[$fieldId]);
|
||||
}
|
||||
$self->deleteCollateral("Thingy_fields","fieldId",$fieldId);
|
||||
$db->write("update Thingy_fields set sequenceNumber = sequenceNumber -1 where sequenceNumber > ?",[$deletedSequenceNumber]);
|
||||
if ($keepSequenceNumbers ne "1"){
|
||||
$db->write("update Thingy_fields set sequenceNumber = sequenceNumber -1 where sequenceNumber > ?"
|
||||
,[$deletedSequenceNumber]);
|
||||
}
|
||||
|
||||
my ($columnExists) = $db->quickArray("show columns from ".$db->dbh->quote_identifier("Thingy_".$thingId)
|
||||
." like ".$db->quote("field_".$fieldId));
|
||||
|
|
@ -792,9 +804,10 @@ sub importAssetCollateralData {
|
|||
my ($fieldIdExists) = $session->db->quickArray("select fieldId from Thingy_fields where fieldId = ? and thingId = ? ",[$field->{fieldId},$field->{thingId}]);
|
||||
if ($assetExists && $fieldIdExists){
|
||||
# update existing field
|
||||
$error->info("Updating Field, label: ".$field->{label}.", id: ".$field->{fieldId});
|
||||
$error->info("Updating Field, label: ".$field->{label}.", id: ".$field->{fieldId}.",seq :"
|
||||
.$field->{sequenceNumber});
|
||||
$self->_updateFieldType($field->{fieldType},$field->{fieldId},$field->{thingId},$field->{assetId},$dbDataType);
|
||||
$self->setCollateral("Thingy_fields","fieldId",$field,1,0);
|
||||
$self->setCollateral("Thingy_fields","fieldId",$field,1,0,"","",1);
|
||||
}
|
||||
else{
|
||||
# Add field as Collateral, retain fieldId.
|
||||
|
|
@ -807,7 +820,7 @@ sub importAssetCollateralData {
|
|||
while (my $fieldInDataBase = $fieldsInDatabase->hashRef) {
|
||||
if (!WebGUI::Utility::isIn($fieldInDataBase->{fieldId},@importFields)){
|
||||
# delete field
|
||||
$self->deleteField($fieldInDataBase->{fieldId},$fieldInDataBase->{thingId});
|
||||
$self->deleteField($fieldInDataBase->{fieldId},$fieldInDataBase->{thingId},"1");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue