Problem
Approach – Ansatz
Solution – Lösung
Lösung 1
Braucht 7 Minuten auf Testmodul
void collectBaselineInfo(Buffer buf, Skip skp)
{
Module m
Baseline b
ModName_ mn
for mn in skp do
{
m = read(fullName mn, false)
if ( !null m )
{
buf += name(mn)
b = getMostRecentBaseline(m);
if ( !null b )
{
buf += ( ", Baseline " major(b) "." minor(b) "\n")
}
else
{
buf += ", Baseline 0.0\n"
}
}
close m
}
}
string getTraceability(Module m)
{
Object o
Link l
ModName_ mn
Skip targetSkp = create
Skip sourceSkp = create
Buffer buf = create
// Collect targetmodules and sourcemodules
for o in m do
{
for l in o -> "*" do
{
mn = target l
put(targetSkp, mn, mn)
}
for mn in o <- "*" do
{
put(sourceSkp, mn, mn)
}
}
buf += "Out-Links\n"
collectBaselineInfo(buf, targetSkp)
buf += "\nIn-Links\n"
collectBaselineInfo(buf, sourceSkp)
string s = stringOf buf
delete buf
return s
}
Module m = current
print getTraceability(m)
Lösung 2
string getTraceabilityForModule(Module m)
{
Object obj;
Skip inLinkSkip=createString;
Skip outLinkSkip=createString;
filtering off;
for obj in m do
{
Link lnk;
for lnk in obj->"*" do
{
string tmn=fullName target(lnk);
Module openMod=read(tmn,false, true);
Baseline b = getMostRecentBaseline(openMod);
int majorBL=-1;
int minorBL=-1;
if(null b)
{
majorBL=0;
minorBL=0;
}
else
{
majorBL=major b;
minorBL=minor b;
}
outLinks=name(openMod) ", Baseline " majorBL "." minorBL "";
string dummy;
if(!find(outLinkSkip, outLinks, dummy))
{
put(outLinkSkip, outLinks, outLinks);
}
}
LinkRef lnkRef;
ModName_ otherMod = null;
for lnkRef in all(obj<-"*") do
{
otherMod = module (sourceVersion lnkRef);
if (!null otherMod)
{
if ((!isDeleted otherMod) && (null data(sourceVersion lnkRef)))
{
load((sourceVersion lnkRef),false);
}
}
}
for lnk in obj <- "*" do
{
Object src = source lnk;
Baseline b = getMostRecentBaseline(module src);
int majorBL=-1;
int minorBL=-1;
if(null b)
{
majorBL=0;
minorBL=0;
}
else
{
majorBL=major b;
minorBL=minor b;
}
inLinks=name(module src) ", Baseline " majorBL "." minorBL "";
string dummy2;
if(!find(inLinkSkip, inLinks, dummy2))
{
put(inLinkSkip, inLinks, inLinks);
}
}
}
string gesamtAusgabe="";
bool isFirst=true;
bool hasOutLinks=false;
for myIterator in outLinkSkip do
{
string myKey = (string key(outLinkSkip));
string myValue = "";
if(find(outLinkSkip , myKey, myValue))
{
if(isFirst)
{
gesamtAusgabe=gesamtAusgabe "{\\b Out-Links }" ;
isFirst=false;
}
gesamtAusgabe=gesamtAusgabe "\n" myKey;
hasOutLinks=true;
}
}
// Ne Zeile zwischen machen
if(hasOutLinks)
{
gesamtAusgabe=gesamtAusgabe "\n\n";
}
isFirst=true;
for myIterator in inLinkSkip do
{
string myKey = (string key(inLinkSkip));
string myValue = "";
if(find(inLinkSkip , myKey, myValue))
{
if(isFirst)
{
gesamtAusgabe=gesamtAusgabe "{\\b In-Links }" ;
isFirst=false;
}
gesamtAusgabe=gesamtAusgabe "\n" myKey
}
}
delete outLinkSkip;
delete inLinkSkip;
return gesamtAusgabe;
}