| 1 | # Copyrights 2009-2015 by [Mark Overmeer]. | ||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.02. | ||||||||||||||
| 5 | 7 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 7 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | package BPM::XPDL; | ||||||||||||||
| 9 | 7 | ▶ | use vars '$VERSION'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 7 | $VERSION = '0.93'; | |||||||||||||
| 11 | |||||||||||||||
| 12 | 7 | ▶ | use base 'XML::Compile::Cache'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | |||||||||||||||
| 14 | 7 | ▶ | use XML::Compile::Util qw/type_of_node unpack_type pack_type/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 15 | 7 | ▶ | use Log::Report 'business-xpdl', syntax => 'SHORT'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 16 | 7 | ▶ | use BPM::XPDL::Util; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 17 | |||||||||||||||
| 18 | |||||||||||||||
| 19 | # map namespace always to the newest implementation of the protocol | ||||||||||||||
| 20 | 7 | my %ns2version = | |||||||||||||
| 21 | ( &NS_XPDL_009 => '0.09' | ||||||||||||||
| 22 | , &NS_XPDL_10 => '1.0' | ||||||||||||||
| 23 | , &NS_XPDL_20 => '2.0' | ||||||||||||||
| 24 | , &NS_XPDL_21 => '2.1' | ||||||||||||||
| 25 | , &NS_XPDL_22 => '2.2' | ||||||||||||||
| 26 | ); | ||||||||||||||
| 27 | |||||||||||||||
| 28 | 7 | my %info = | |||||||||||||
| 29 | ( '0.01' => { } # not usable | ||||||||||||||
| 30 | , '0.09' => | ||||||||||||||
| 31 | { prefixes => { '' => NS_XPDL_009 } | ||||||||||||||
| 32 | } | ||||||||||||||
| 33 | , '1.0' => | ||||||||||||||
| 34 | { prefixes => { '' => NS_XPDL_10 } | ||||||||||||||
| 35 | } | ||||||||||||||
| 36 | , '2.0alpha-21' => | ||||||||||||||
| 37 | { prefixes => { '' => NS_XPDL_20 } | ||||||||||||||
| 38 | } | ||||||||||||||
| 39 | , '2.0alpha-24' => | ||||||||||||||
| 40 | { prefixes => { '' => NS_XPDL_20 } | ||||||||||||||
| 41 | } | ||||||||||||||
| 42 | , '2.0' => # alpha namespace used for final product | ||||||||||||||
| 43 | { prefixes => { '' => NS_XPDL_20 } | ||||||||||||||
| 44 | } | ||||||||||||||
| 45 | , '2.1' => | ||||||||||||||
| 46 | { prefixes => { '' => NS_XPDL_21 } | ||||||||||||||
| 47 | } | ||||||||||||||
| 48 | , '2.2' => | ||||||||||||||
| 49 | { prefixes => { '' => NS_XPDL_22 } | ||||||||||||||
| 50 | } | ||||||||||||||
| 51 | ); | ||||||||||||||
| 52 | |||||||||||||||
| 53 | #-------- | ||||||||||||||
| 54 | |||||||||||||||
| 55 | |||||||||||||||
| 56 | sub new($) | ||||||||||||||
| 57 | 6 | ▶ | { my $class = shift; | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 58 | 6 | $class->SUPER::new(direction => 'RW', @_); | |||||||||||||
| 59 | } | ||||||||||||||
| 60 | |||||||||||||||
| 61 | sub init($) | ||||||||||||||
| 62 | 6 | ▶ | { my ($self, $args) = @_; | ||||||||||||
|
Subroutine
init: called CC=10 SCAR=23.7
Pod
undocumented
| |||||||||||||||
| 63 | $args->{allow_undeclared} = 1 | ||||||||||||||
| 64 | 6 | ▶ | unless exists $args->{allow_undeclared}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 65 | |||||||||||||||
| 66 | 6 | $self->SUPER::init($args); | |||||||||||||
| 67 | |||||||||||||||
| 68 | 6 | $self->anyElement('ATTEMPT'); | |||||||||||||
| 69 | 6 | $self->addCompileOptions(RW => sloppy_floats => 1, sloppy_integers => 1); | |||||||||||||
| 70 | 6 | $self->addCompileOptions(READERS => mixed_elements => 'XML_NODE'); | |||||||||||||
| 71 | |||||||||||||||
| 72 | my $version = $args->{version} | ||||||||||||||
| 73 | 6 | ▶ | or error __x"XPDL object requires an explicit version"; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 74 | |||||||||||||||
| 75 | 6 | ▶ | unless(exists $info{$version}) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 76 | 0 | ▶ | { exists $ns2version{$version} | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 77 | or error __x"XPDL version {v} not recognized", v => $version; | ||||||||||||||
| 78 | 0 | $version = $ns2version{$version}; | |||||||||||||
| 79 | } | ||||||||||||||
| 80 | 6 | $self->{version} = $version; | |||||||||||||
| 81 | 6 | my $info = $info{$version}; | |||||||||||||
| 82 | 6 | $self->{namespace} = $info->{prefixes}{''}; | |||||||||||||
| 83 | |||||||||||||||
| 84 | 6 | my $prefix_keys = $self->{prefixed} = delete $args->{prefix_keys}; | |||||||||||||
| 85 | |||||||||||||||
| 86 | 6 | $self->addPrefixes($info->{prefixes}); | |||||||||||||
| 87 | 6 | ▶ | $self->addKeyRewrite('PREFIXES(xpdl)') if $prefix_keys; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 88 | |||||||||||||||
| 89 | 6 | (my $xsd = __FILE__) =~ s!\.pm!/xsd!; | |||||||||||||
| 90 | 7 | ▶ | my @xsds = glob "$xsd/xpdl-$version/*"; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 91 | |||||||||||||||
| 92 | # support deprecated versions | ||||||||||||||
| 93 | 6 | ▶ | if($version gt '1.0') # $version is a version label, not number | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 94 | 4 | { trace "loading deprecated xpdl 1.0"; | |||||||||||||
| 95 | 4 | $self->addPrefixes(xpdl10 => NS_XPDL_10); | |||||||||||||
| 96 | 4 | push @xsds, glob "$xsd/xpdl-1.0/*"; | |||||||||||||
| 97 | 4 | ▶ | $self->addKeyRewrite('PREFIXES(xpdl10)') if $prefix_keys; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 98 | |||||||||||||||
| 99 | # this trick is needed because the StartMode element became an | ||||||||||||||
| 100 | # attribute in the same structure | ||||||||||||||
| 101 | 4 | $self->addKeyRewrite( | |||||||||||||
| 102 | { pack_type(NS_XPDL_10, 'StartMode' ) => 'dep_StartMode' | ||||||||||||||
| 103 | , pack_type(NS_XPDL_10, 'FinishMode') => 'dep_FinishMode'} ); | ||||||||||||||
| 104 | } | ||||||||||||||
| 105 | |||||||||||||||
| 106 | 6 | ▶ | if($version ge '2.1') | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 107 | 1 | { trace "loading deprecated xpdl 2.0"; | |||||||||||||
| 108 | 1 | $self->addPrefixes(xpdl20 => NS_XPDL_20); | |||||||||||||
| 109 | 1 | push @xsds, glob "$xsd/xpdl-2.0/*"; | |||||||||||||
| 110 | 1 | ▶ | $self->addKeyRewrite('PREFIXES(xpdl20)') if $prefix_keys; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 111 | } | ||||||||||||||
| 112 | |||||||||||||||
| 113 | 6 | $self->importDefinitions(\@xsds); | |||||||||||||
| 114 | 6 | $self; | |||||||||||||
| 115 | } | ||||||||||||||
| 116 | |||||||||||||||
| 117 | |||||||||||||||
| 118 | sub from($@) | ||||||||||||||
| 119 | 5 | ▶ | { my ($thing, $source, %args) = @_; | ||||||||||||
|
Subroutine
from: called CC=9 SCAR=22.2
Pod
documented
| |||||||||||||||
| 120 | |||||||||||||||
| 121 | 5 | my $xml = XML::Compile->dataToXML($source); | |||||||||||||
| 122 | 5 | my $top = type_of_node $xml; | |||||||||||||
| 123 | 5 | my ($ns, $topname) = unpack_type $top; | |||||||||||||
| 124 | 5 | ▶ | my $version = $ns2version{$ns} | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 125 | or error __x"unknown XPDL version with namespace {ns}", ns => $ns; | ||||||||||||||
| 126 | |||||||||||||||
| 127 | 5 | ▶ | $topname eq 'Package' | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 128 | or error __x"file does not contain a Package but {local}" | ||||||||||||||
| 129 | , local => $topname; | ||||||||||||||
| 130 | |||||||||||||||
| 131 | 5 | my ($self, $convert); | |||||||||||||
| 132 | 5 | ▶ | if(ref $thing) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 133 | { # instance method | ||||||||||||||
| 134 | 3 | $self = $thing; | |||||||||||||
| 135 | |||||||||||||||
| 136 | ! $self->{prefixed} | ||||||||||||||
| 137 | 3 | ▶ | or error __x"cannot use prefixed_keys with version conversion"; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 138 | |||||||||||||||
| 139 | 3 | $convert = 1; | |||||||||||||
| 140 | } | ||||||||||||||
| 141 | else | ||||||||||||||
| 142 | { # class method: can determine version myself | ||||||||||||||
| 143 | 2 | $self = $thing->new(version => $version, %args); | |||||||||||||
| 144 | 2 | $convert = 0; | |||||||||||||
| 145 | } | ||||||||||||||
| 146 | |||||||||||||||
| 147 | 5 | ▶ | my $r = $self->reader($top, %args) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 148 | or error __x"root node `{top}' not recognized", top => $top; | ||||||||||||||
| 149 | |||||||||||||||
| 150 | 5 | my $data = $r->($xml); | |||||||||||||
| 151 | |||||||||||||||
| 152 | 5 | ▶ | if($convert) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 153 | { # upgrade structures. Even when the versions match, they may | ||||||||||||||
| 154 | # contain deprecated structures which can be removed. | ||||||||||||||
| 155 | 3 | ▶ | $self->convert10to20($data) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 156 | if $self->version gt '1.0'; | ||||||||||||||
| 157 | |||||||||||||||
| 158 | 3 | ▶ | $self->convert20to21($data) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 159 | if $self->version gt '2.0'; | ||||||||||||||
| 160 | } | ||||||||||||||
| 161 | |||||||||||||||
| 162 | 5 | (pack_type($self->namespace, 'Package'), , $data); | |||||||||||||
| 163 | } | ||||||||||||||
| 164 | |||||||||||||||
| 165 | sub convert10to20($) | ||||||||||||||
| 166 | 3 | ▶ | { my ($self, $data) = @_; | ||||||||||||
|
Subroutine
convert10to20: called CC=41 SCAR=38.1
Pod
undocumented
| |||||||||||||||
| 167 | |||||||||||||||
| 168 | 3 | trace "Convert xpdl version from 1.0 to 2.0"; | |||||||||||||
| 169 | |||||||||||||||
| 170 | # The conversions to be made are described in the XPDL specification | ||||||||||||||
| 171 | # documents. However, be aware that there are considerable additions. | ||||||||||||||
| 172 | |||||||||||||||
| 173 | 3 | my $ns = $self->namespace; | |||||||||||||
| 174 | 3 | ▶ | my $prefix | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 175 | = $ns eq NS_XPDL_20 ? 'xpdl20' | ||||||||||||||
| 176 | : $ns eq NS_XPDL_21 ? 'xpdl21' | ||||||||||||||
| 177 | : panic; | ||||||||||||||
| 178 | |||||||||||||||
| 179 | # do not walk more than one HASH level at a time, to avoid creation | ||||||||||||||
| 180 | # of unused HASHes. | ||||||||||||||
| 181 | 3 | ▶ | my $wfps = $data->{WorkflowProcesses} || {}; | ||||||||||||
|
Condition50%1/2
$data->{'WorkflowProcesses'} || {}
MC/DC0%0/1
$data->{'WorkflowProcesses'} || {}
$data->{'WorkflowProcesses'}
Truth table50%1/2
A
A= $data->{'WorkflowProcesses'}
| |||||||||||||||
| 182 | 3 | ▶ | foreach my $wfp (@{$wfps->{WorkflowProcess} || []}) | ||||||||||||
|
Condition50%1/2
$wfps->{'WorkflowProcess'} || []
MC/DC0%0/1
$wfps->{'WorkflowProcess'} || []
$wfps->{'WorkflowProcess'}
Truth table50%1/2
A
A= $wfps->{'WorkflowProcess'}
| |||||||||||||||
| 183 | { | ||||||||||||||
| 184 | 5 | ▶ | my $acts = $wfp->{Activities} || {}; | ||||||||||||
|
Condition50%1/2
$wfp->{'Activities'} || {}
MC/DC0%0/1
$wfp->{'Activities'} || {}
$wfp->{'Activities'}
Truth table50%1/2
A
A= $wfp->{'Activities'}
| |||||||||||||||
| 185 | 5 | ▶ | foreach my $act (@{$acts->{Activity} || []}) | ||||||||||||
|
Condition50%1/2
$acts->{'Activity'} || []
MC/DC0%0/1
$acts->{'Activity'} || []
$acts->{'Activity'}
Truth table50%1/2
A
A= $acts->{'Activity'}
| |||||||||||||||
| 186 | { # Start/Finish mode from element -> attribute | ||||||||||||||
| 187 | 34 | ▶ | if(my $sm = delete $act->{dep_StartMode}) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 188 | 1 | { (my $mode, undef) = %$sm; # only 1 key-value pair! | |||||||||||||
| 189 | 1 | $act->{StartMode} = $mode; | |||||||||||||
| 190 | } | ||||||||||||||
| 191 | 34 | ▶ | if(my $fm = delete $act->{dep_FinishMode}) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 192 | 0 | { (my $mode, undef) = %$fm; | |||||||||||||
| 193 | 0 | $act->{dep_FinishMode} = $mode; | |||||||||||||
| 194 | } | ||||||||||||||
| 195 | |||||||||||||||
| 196 | # BlockId -> ActivitySetId | ||||||||||||||
| 197 | 34 | ▶ | if(my $ba = $act->{BlockActivity}) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 198 | { # rename option BlockId into ActivitySetId | ||||||||||||||
| 199 | $ba->{ActivitySetId} = delete $ba->{BlockId} | ||||||||||||||
| 200 | 1 | ▶ | if $ba->{BlockId}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 201 | } | ||||||||||||||
| 202 | |||||||||||||||
| 203 | # DeadlineCondition -> DeadlineDuration | ||||||||||||||
| 204 | 34 | ▶ | foreach my $dead (@{$act->{Deadline} || []}) | ||||||||||||
|
Condition100%2/2
$act->{'Deadline'} || []
MC/DC100%1/1
$act->{'Deadline'} || []
$act->{'Deadline'}
Truth table100%2/2
A
A= $act->{'Deadline'}
| |||||||||||||||
| 205 | { $dead->{DeadlineDuration} = delete $dead->{DeadlineCondition} | ||||||||||||||
| 206 | 3 | ▶ | if $dead->{DeadlineCondition}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 207 | } | ||||||||||||||
| 208 | |||||||||||||||
| 209 | # Remove Tool attribute "Type" | ||||||||||||||
| 210 | 34 | ▶ | if(my $impl = $act->{Implementation}) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 211 | 23 | ▶ | { if(my $tools = $impl->{Tool}) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 212 | 2 | { delete $_->{Type} for @$tools; | |||||||||||||
| 213 | } | ||||||||||||||
| 214 | } | ||||||||||||||
| 215 | } | ||||||||||||||
| 216 | |||||||||||||||
| 217 | # remove Index attribute to FormalParameter | ||||||||||||||
| 218 | 5 | ▶ | my $fps = $wfp->{FormalParameters} || {}; | ||||||||||||
|
Condition100%2/2
$wfp->{'FormalParameters'} || {}
MC/DC100%1/1
$wfp->{'FormalParameters'} || {}
$wfp->{'FormalParameters'}
Truth table100%2/2
A
A= $wfp->{'FormalParameters'}
| |||||||||||||||
| 219 | 5 | ▶ | foreach my $param (@{$fps->{FormalParameter} || []}) | ||||||||||||
|
Condition100%2/2
$fps->{'FormalParameter'} || []
MC/DC100%1/1
$fps->{'FormalParameter'} || []
$fps->{'FormalParameter'}
Truth table100%2/2
A
A= $fps->{'FormalParameter'}
| |||||||||||||||
| 220 | 10 | { delete $param->{Index}; | |||||||||||||
| 221 | } | ||||||||||||||
| 222 | |||||||||||||||
| 223 | 5 | ▶ | my $appls = $wfp->{Applications} || {}; | ||||||||||||
|
Condition100%2/2
$wfp->{'Applications'} || {}
MC/DC100%1/1
$wfp->{'Applications'} || {}
$wfp->{'Applications'}
Truth table100%2/2
A
A= $wfp->{'Applications'}
| |||||||||||||||
| 224 | 5 | ▶ | foreach my $appl (@{$appls->{Application} || []}) | ||||||||||||
|
Condition100%2/2
$appls->{'Application'} || []
MC/DC100%1/1
$appls->{'Application'} || []
$appls->{'Application'}
Truth table100%2/2
A
A= $appls->{'Application'}
| |||||||||||||||
| 225 | 15 | ▶ | { my $afps = $appl->{FormalParameters} || {}; | ||||||||||||
|
Condition100%2/2
$appl->{'FormalParameters'} || {}
MC/DC100%1/1
$appl->{'FormalParameters'} || {}
$appl->{'FormalParameters'}
Truth table100%2/2
A
A= $appl->{'FormalParameters'}
| |||||||||||||||
| 226 | 15 | ▶ | for my $param (@{$afps->{FormalParameter}||[]}) | ||||||||||||
|
Condition100%2/2
$afps->{'FormalParameter'} || []
MC/DC100%1/1
$afps->{'FormalParameter'} || []
$afps->{'FormalParameter'}
Truth table100%2/2
A
A= $afps->{'FormalParameter'}
| |||||||||||||||
| 227 | 26 | { delete $param->{Index}; | |||||||||||||
| 228 | } | ||||||||||||||
| 229 | } | ||||||||||||||
| 230 | |||||||||||||||
| 231 | # Condition/Xpression to Condition/Expression | ||||||||||||||
| 232 | 5 | ▶ | my $trs = $wfp->{Transitions} || {}; | ||||||||||||
|
Condition50%1/2
$wfp->{'Transitions'} || {}
MC/DC0%0/1
$wfp->{'Transitions'} || {}
$wfp->{'Transitions'}
Truth table50%1/2
A
A= $wfp->{'Transitions'}
| |||||||||||||||
| 233 | 5 | ▶ | for my $trans (@{$trs->{Transition} || []}) | ||||||||||||
|
Condition50%1/2
$trs->{'Transition'} || []
MC/DC0%0/1
$trs->{'Transition'} || []
$trs->{'Transition'}
Truth table50%1/2
A
A= $trs->{'Transition'}
| |||||||||||||||
| 234 | 38 | ▶ | { my $cond = $trans->{Condition} or next; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 235 | 12 | foreach ($cond->getChildrenByLocalName('Xpression')) | |||||||||||||
| 236 | 1 | { $_->setNodeName('Expression'); | |||||||||||||
| 237 | 1 | $_->setNamespace($ns, $prefix, 1); | |||||||||||||
| 238 | } | ||||||||||||||
| 239 | } | ||||||||||||||
| 240 | |||||||||||||||
| 241 | 5 | ▶ | my $sets = $wfp->{ActivitySets} || {}; | ||||||||||||
|
Condition50%1/2
$wfp->{'ActivitySets'} || {}
MC/DC0%0/1
$wfp->{'ActivitySets'} || {}
$wfp->{'ActivitySets'}
Truth table50%1/2
A
A= $wfp->{'ActivitySets'}
| |||||||||||||||
| 242 | 5 | ▶ | foreach my $set (@{$sets->{ActivitySet} || []}) | ||||||||||||
|
Condition100%2/2
$sets->{'ActivitySet'} || []
MC/DC100%1/1
$sets->{'ActivitySet'} || []
$sets->{'ActivitySet'}
Truth table100%2/2
A
A= $sets->{'ActivitySet'}
| |||||||||||||||
| 243 | 2 | ▶ | { my $strans = $set->{Transitions} || {}; | ||||||||||||
|
Condition50%1/2
$set->{'Transitions'} || {}
MC/DC0%0/1
$set->{'Transitions'} || {}
$set->{'Transitions'}
Truth table50%1/2
A
A= $set->{'Transitions'}
| |||||||||||||||
| 244 | 2 | ▶ | foreach my $trans (@{$strans->{Transition} || []}) | ||||||||||||
|
Condition50%1/2
$strans->{'Transition'} || []
MC/DC0%0/1
$strans->{'Transition'} || []
$strans->{'Transition'}
Truth table50%1/2
A
A= $strans->{'Transition'}
| |||||||||||||||
| 245 | 2 | ▶ | { my $cond = $trans->{Condition} or next; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 246 | 2 | foreach ($cond->getChildrenByLocalName('Xpression')) | |||||||||||||
| 247 | 1 | { $_->setNodeName('Expression'); | |||||||||||||
| 248 | 1 | $_->setNamespace($ns, $prefix, 1); | |||||||||||||
| 249 | } | ||||||||||||||
| 250 | } | ||||||||||||||
| 251 | } | ||||||||||||||
| 252 | |||||||||||||||
| 253 | # Order in WorkflowProcess changed. This is a no-op for X::C | ||||||||||||||
| 254 | } | ||||||||||||||
| 255 | |||||||||||||||
| 256 | 3 | $data->{PackageHeader}{XPDLVersion} = '2.0'; | |||||||||||||
| 257 | 3 | $data; | |||||||||||||
| 258 | } | ||||||||||||||
| 259 | |||||||||||||||
| 260 | sub convert20to21($) | ||||||||||||||
| 261 | 1 | ▶ | { my ($self, $data) = @_; | ||||||||||||
|
Subroutine
convert20to21: called CC=24 SCAR=34.4
Pod
undocumented
| |||||||||||||||
| 262 | |||||||||||||||
| 263 | 1 | trace "Convert xpdl version from 2.0 to 2.1"; | |||||||||||||
| 264 | |||||||||||||||
| 265 | # Tool has been removed from the spec. However, it can still be | ||||||||||||||
| 266 | # used in the old namespace, and I do not know how to convert it | ||||||||||||||
| 267 | # to 2.1 structures (yet) | ||||||||||||||
| 268 | |||||||||||||||
| 269 | 1 | my $ns = $self->namespace; | |||||||||||||
| 270 | 1 | ▶ | my $prefix | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 271 | = $ns eq NS_XPDL_21 ? 'xpdl21' | ||||||||||||||
| 272 | : panic; | ||||||||||||||
| 273 | |||||||||||||||
| 274 | |||||||||||||||
| 275 | # do not walk more than one HASH level at a time, to avoid creation | ||||||||||||||
| 276 | # of unused HASHes. | ||||||||||||||
| 277 | 1 | ▶ | my $wfps = $data->{WorkflowProcesses} || {}; | ||||||||||||
|
Condition50%1/2
$data->{'WorkflowProcesses'} || {}
MC/DC0%0/1
$data->{'WorkflowProcesses'} || {}
$data->{'WorkflowProcesses'}
Truth table50%1/2
A
A= $data->{'WorkflowProcesses'}
| |||||||||||||||
| 278 | 1 | ▶ | foreach my $wfp (@{$wfps->{WorkflowProcess} || []}) | ||||||||||||
|
Condition50%1/2
$wfps->{'WorkflowProcess'} || []
MC/DC0%0/1
$wfps->{'WorkflowProcess'} || []
$wfps->{'WorkflowProcess'}
Truth table50%1/2
A
A= $wfps->{'WorkflowProcess'}
| |||||||||||||||
| 279 | { | ||||||||||||||
| 280 | 1 | ▶ | my $acts = $wfp->{Activities} || {}; | ||||||||||||
|
Condition50%1/2
$wfp->{'Activities'} || {}
MC/DC0%0/1
$wfp->{'Activities'} || {}
$wfp->{'Activities'}
Truth table50%1/2
A
A= $wfp->{'Activities'}
| |||||||||||||||
| 281 | 1 | ▶ | foreach my $act (@{$acts->{Activity} || []}) | ||||||||||||
|
Condition50%1/2
$acts->{'Activity'} || []
MC/DC0%0/1
$acts->{'Activity'} || []
$acts->{'Activity'}
Truth table50%1/2
A
A= $acts->{'Activity'}
| |||||||||||||||
| 282 | { # Rewrite Tool to Task/TaskApplication | ||||||||||||||
| 283 | 1 | ▶ | if(my $impl = $act->{Implementation}) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 284 | 1 | ▶ | { foreach my $tool (@{delete $impl->{Tool} || []}) | ||||||||||||
|
Condition50%1/2
delete $impl->{'Tool'} || []
MC/DC0%0/1
delete $impl->{'Tool'} || []
delete $impl->{'Tool'}
Truth table50%1/2
A
A= delete $impl->{'Tool'}
| |||||||||||||||
| 285 | 1 | { my %task = %$tool; | |||||||||||||
| 286 | 1 | delete $task{PackageRef}; # ?relocate info? | |||||||||||||
| 287 | 1 | delete $task{ExtendedAttributes}; # ?into DataMapping? | |||||||||||||
| 288 | 1 | delete $task{Type}; # shouldn't be there, rem in 2.0 | |||||||||||||
| 289 | 1 | $impl->{Task}{TaskApplication} = \%task; | |||||||||||||
| 290 | } | ||||||||||||||
| 291 | } | ||||||||||||||
| 292 | } | ||||||||||||||
| 293 | |||||||||||||||
| 294 | # Condition/Xpression to Condition/Expression | ||||||||||||||
| 295 | 1 | ▶ | my $trs = $wfp->{Transitions} || {}; | ||||||||||||
|
Condition50%1/2
$wfp->{'Transitions'} || {}
MC/DC0%0/1
$wfp->{'Transitions'} || {}
$wfp->{'Transitions'}
Truth table50%1/2
A
A= $wfp->{'Transitions'}
| |||||||||||||||
| 296 | 1 | ▶ | for my $trans (@{$trs->{Transition} || []}) | ||||||||||||
|
Condition50%1/2
$trs->{'Transition'} || []
MC/DC0%0/1
$trs->{'Transition'} || []
$trs->{'Transition'}
Truth table50%1/2
A
A= $trs->{'Transition'}
| |||||||||||||||
| 297 | 1 | ▶ | { my $cond = $trans->{Condition} or next; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 298 | 1 | foreach ($cond->getChildrenByLocalName('Expression')) | |||||||||||||
| 299 | 1 | { $_->setNamespace($ns, $prefix, 1); | |||||||||||||
| 300 | } | ||||||||||||||
| 301 | } | ||||||||||||||
| 302 | |||||||||||||||
| 303 | 1 | ▶ | my $sets = $wfp->{ActivitySets} || {}; | ||||||||||||
|
Condition50%1/2
$wfp->{'ActivitySets'} || {}
MC/DC0%0/1
$wfp->{'ActivitySets'} || {}
$wfp->{'ActivitySets'}
Truth table50%1/2
A
A= $wfp->{'ActivitySets'}
| |||||||||||||||
| 304 | 1 | ▶ | foreach my $set (@{$sets->{ActivitySet} || []}) | ||||||||||||
|
Condition50%1/2
$sets->{'ActivitySet'} || []
MC/DC0%0/1
$sets->{'ActivitySet'} || []
$sets->{'ActivitySet'}
Truth table50%1/2
A
A= $sets->{'ActivitySet'}
| |||||||||||||||
| 305 | 1 | ▶ | { my $strans = $set->{Transitions} || {}; | ||||||||||||
|
Condition50%1/2
$set->{'Transitions'} || {}
MC/DC0%0/1
$set->{'Transitions'} || {}
$set->{'Transitions'}
Truth table50%1/2
A
A= $set->{'Transitions'}
| |||||||||||||||
| 306 | 1 | ▶ | foreach my $trans (@{$strans->{Transition} || []}) | ||||||||||||
|
Condition50%1/2
$strans->{'Transition'} || []
MC/DC0%0/1
$strans->{'Transition'} || []
$strans->{'Transition'}
Truth table50%1/2
A
A= $strans->{'Transition'}
| |||||||||||||||
| 307 | 1 | ▶ | { my $cond = $trans->{Condition} or next; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 308 | 1 | foreach ($cond->getChildrenByLocalName('Expression')) | |||||||||||||
| 309 | 1 | { $_->setNamespace($ns, $prefix, 1); | |||||||||||||
| 310 | } | ||||||||||||||
| 311 | } | ||||||||||||||
| 312 | } | ||||||||||||||
| 313 | } | ||||||||||||||
| 314 | |||||||||||||||
| 315 | 1 | $data->{PackageHeader}{XPDLVersion} = '2.1'; | |||||||||||||
| 316 | 1 | $data; | |||||||||||||
| 317 | } | ||||||||||||||
| 318 | |||||||||||||||
| 319 | #---------- | ||||||||||||||
| 320 | |||||||||||||||
| 321 | |||||||||||||||
| 322 | 6 | ▶ | sub version() {shift->{version}} | ||||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 323 | 9 | ▶ | sub namespace() {shift->{namespace}} | ||||||||||||
|
Subroutine
namespace: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 324 | |||||||||||||||
| 325 | #-------- | ||||||||||||||
| 326 | |||||||||||||||
| 327 | sub create($) | ||||||||||||||
| 328 | 3 | ▶ | { my ($self, $data) = @_; | ||||||||||||
|
Subroutine
create: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||
| 329 | 3 | my $doc = XML::LibXML::Document->new('1.0', 'UTF-8'); | |||||||||||||
| 330 | 3 | ▶ | my $wr = $self->writer('Package') | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 331 | or panic "cannot find Package type"; | ||||||||||||||
| 332 | |||||||||||||||
| 333 | 3 | my $root = $wr->($doc, $data); | |||||||||||||
| 334 | 3 | $doc->setDocumentElement($root); | |||||||||||||
| 335 | 3 | $doc; | |||||||||||||
| 336 | } | ||||||||||||||
| 337 | |||||||||||||||
| 338 | 7 | 1; | |||||||||||||