I am trying to apply some rules to auto populate a resultant "Acceptance" attribute value. |
Re: Attribute embedded DXL
1. Make sure the module is open for editing: //Open module for reading m = read(...) //Open module for editing m = edit(...)
//Extract attribute definitions
AttrDef ad
for ad in m do{
//Check if object
if(ad.object){
//modifications go here
}
}
//Save changes
save(m)
//Close module
close(m)
|
Re: Attribute embedded DXL meherts - Tue Jun 22 14:55:16 EDT 2010
1. Make sure the module is open for editing: //Open module for reading m = read(...) //Open module for editing m = edit(...)
//Extract attribute definitions
AttrDef ad
for ad in m do{
//Check if object
if(ad.object){
//modifications go here
}
}
//Save changes
save(m)
//Close module
close(m)
The rule for each object needs to be read from its "Rule" attribute.
Module m = current
Object o
stream rule = write tempFileName
for o in m do {
clear rule
out << o."Rule" "" //Object rule eg if (o."Compliance Statement"" == "Partially Complies") { o."Acceptance" = "Rejected"}
#include tempFileName
}
|
Re: Attribute embedded DXL Martin_Hunter - Wed Jun 23 09:50:56 EDT 2010
The rule for each object needs to be read from its "Rule" attribute.
Module m = current
Object o
stream rule = write tempFileName
for o in m do {
clear rule
out << o."Rule" "" //Object rule eg if (o."Compliance Statement"" == "Partially Complies") { o."Acceptance" = "Rejected"}
#include tempFileName
}
This is not going to work! The #include is done only once before you run the script (like in C by the preprocessor) and if you change the file during the run of the script you won't get any changes.
Object o
string s = "print identifier o \"\n\""
for o in current Module do {
eval_ "Object o = (addr_ " ((addr_ o) int) ") Object\n" s
}
Object o = (addr_ 12345) Object
// your code
print identifier o "\n"
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Attribute embedded DXL
Seems strange to put DXL code in an attribute. I didn't try it but am sure Malias' solution will work.
string NameAttrAcceptance = "Acceptence"
void AutoSetAcceptance(Object obj)
{ if (null obj) return
Rule = probeAttr_(obj, "MyRulesAttr")
if (null Rule)
{ Accept = probeAttr_(obj, NameAttrAcceptance)
if (null Accept) then do something manual for this object
}
elseif (Rule == "Check Compliance")
{ if (o."Compliance Statement"" == "Partially Complies")
{ oNameAttrAcceptance = "Rejected"
}
else ???
}
elseif (Rule == "Check Comments)
{ if (null (o."Comments" ""))
{ oNameAttrAcceptance = "Rejected"
}
else ???
}
elseif (Rule == "Check something else")
{...
}
else
{ deal with illegal rule, like suggesting this DXL be updated
}
}
|
Re: Attribute embedded DXL llandale - Wed Jun 23 17:30:46 EDT 2010
Seems strange to put DXL code in an attribute. I didn't try it but am sure Malias' solution will work.
string NameAttrAcceptance = "Acceptence"
void AutoSetAcceptance(Object obj)
{ if (null obj) return
Rule = probeAttr_(obj, "MyRulesAttr")
if (null Rule)
{ Accept = probeAttr_(obj, NameAttrAcceptance)
if (null Accept) then do something manual for this object
}
elseif (Rule == "Check Compliance")
{ if (o."Compliance Statement"" == "Partially Complies")
{ oNameAttrAcceptance = "Rejected"
}
else ???
}
elseif (Rule == "Check Comments)
{ if (null (o."Comments" ""))
{ oNameAttrAcceptance = "Rejected"
}
else ???
}
elseif (Rule == "Check something else")
{...
}
else
{ deal with illegal rule, like suggesting this DXL be updated
}
}
|
Re: Attribute embedded DXL Mathias Mamsch - Wed Jun 23 17:45:37 EDT 2010 Now my Recognition is just fine, just not my Recall. Had someone else written "Malius Mamsch" I probably would recognize it as wrong.
Yup, 'Mathias' does sound a bit 'Quaker' compared to 'Malius'. lol |