Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
awit-frameworks
awit-perl-toolkit
Commits
9e5bee47
Commit
9e5bee47
authored
Apr 18, 2017
by
Nigel Kukard
Browse files
Added _property_id support so we can reliable get the ID property
parent
60e2a1b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/AWITPT/DataObj.pm
View file @
9e5bee47
...
...
@@ -222,6 +222,11 @@ Below is a list of supported options:
=over
=item *
B<DATAOBJ_PROPERTY_ID>
This is the unique ID property of the object, only ONE of these can be specified!
=item *
B<DATAOBJ_PROPERTY_NOLOAD>
...
...
@@ -1204,7 +1209,8 @@ sub _init
$self
->
{'
_options
'}
=
0
;
$self
->
{'
_relations
'}
=
{
};
$self
->
{'
_relations_map
'}
=
{
};
$self
->
{'
_properties
'}
=
{};
$self
->
{'
_properties
'}
=
{
};
$self
->
{'
_property_id
'}
=
undef
;
# If we have an odd number of params, chop off the first one as our options
if
(
@params
%
2
)
{
...
...
@@ -1218,6 +1224,19 @@ sub _init
$self
->
_log
(
DATAOBJ_LOG_DEBUG2
,"
- Processing property '%s'
",
$propertyName
);
# Process options if we have any
if
(
defined
(
my
$options
=
$propertyConfig
->
{'
options
'}))
{
# Check if this is an ID property, if it is, set the internal attribute
if
(
$options
&
DATAOBJ_PROPERTY_ID
==
DATAOBJ_PROPERTY_ID
)
{
if
(
defined
(
$self
->
{'
_property_id
'}))
{
$self
->
_log
(
DATAOBJ_LOG_ERROR
,
"
Multiple properties with DATAOBJ_PROPERTY_ID set, ignoring for property '%s'
",
$propertyName
);
}
else
{
$self
->
{'
_property_id
'}
=
$propertyName
;
}
}
}
# Check format of property
if
(
!
(
$propertyName
=~
/^[A-Z][A-Za-z0-9]+$/
))
{
$self
->
_log
(
DATAOBJ_LOG_ERROR
,"
Property '%s' has an invalid name
",
$propertyName
);
...
...
@@ -1443,6 +1462,17 @@ sub _error
# Return the DATAOBJ_PROPERTY_ID property
sub
_property_id
{
my
$self
=
shift
;
return
$self
->
{'
_property_id
'};
}
# Return the property hash of a given property
sub
_propertyByName
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment