<commit_before># OpenXPKI::Server::Workflow::Activity
# Written by <NAME> for the OpenXPKI project 2005
# Rewritten by <NAME> for the OpenXPKI project 2007
# Copyright (c) 2005-2007 by The OpenXPKI Project
package OpenXPKI::Server::Workflow::Activity;

use strict;
use base qw( Workflow::Action );

use OpenXPKI::Debug;
use OpenXPKI::Server::Context qw( CTX );
use OpenXPKI::Exception;
use OpenXPKI::Server::Workflow::Pause;
use Workflow::Exception qw( workflow_error );
use Data::Dumper;

__PACKAGE__->mk_accessors( qw( resulting_state workflow _map ) );

sub init {
    my ( $self, $wf, $params ) = @_;
    ##! 1: 'start ' . $params->{name}
    ##! 64: 'self: ' . Dumper $self
    ##! 64: 'params: ' . Dumper $params
    ##! 64: 'wf: ' . Dumper $wf

    # FIXME - this is a bit of a hack - we're peeking into Workflow's
    # internal structures here. Workflow should provide a way to get
    # the resulting state for an activity itself.
    $self->resulting_state($wf->{_states}->{$wf->state()}->{_actions}->{$params->{name}}->{resulting_state});
    ##! 16: 'Workflow :'.ref $wf
    ##! 16: 'resulting_state: ' . $self->resulting_state()
    $self->{PKI_REALM} = CTX('session')->get_pki_realm();
    ##! 16: 'self->{PKI_REALM} = ' . $self->{PKI_REALM}
    
    $self->workflow( $wf );

    
    # copy the source params
    my $params_merged = { % { $params }};
    
    # init the _map parameters
    my $_map = {};
    
    foreach my $key (keys %{$params}) {
        if ($key !~ /^_map_(.*)/) { next; }
        
        # Remove map key from the hash
        delete $params_merged->{$key};
        
        my $name = $1;
        my $val = $params->{$key};
        $_map->{$name} = $params->{$key};
        ##! 8: 'Found param ' . $name . ' - value : ' . $params->{$key}

=begin disabled-by-oli

        if ($val =~ /^\$(\S+)/) {
            # copy from context
            $_map->{$name} = ['ctx', $1];
                
        } else { # }if ($val =~ /^\&(\S+)/) {
            # TT parser           
            $_map->{$name} = ['tt', $val ];
        #} else { 
        #    
        #    # static value, add to plain params hash 
        #    $params_merged->{$name} = $val;
        } 

=end disabled-by-oli

    }
       
    # call Workflow::Action's init()
    $self->SUPER::init($wf, $params_merged);

    $self->_map( $_map );
    
    ##! 32: 'merged params ' . Dumper  $params_merged
    ##! 32: 'map ' . Dumper  $_map    <commit_msg>Fix broken comment caused by merge<commit_after># OpenXPKI::Server::Workflow::Activity
# Written by <NAME> for the OpenXPKI project 2005
# Rewritten by <NAME> for the OpenXPKI project 2007
# Copyright (c) 2005-2007 by The OpenXPKI Project
package OpenXPKI::Server::Workflow::Activity;

use strict;
use base qw( Workflow::Action );

use OpenXPKI::Debug;
use OpenXPKI::Server::Context qw( CTX );
use OpenXPKI::Exception;
use OpenXPKI::Server::Workflow::Pause;
use Workflow::Exception qw( workflow_error );
use Data::Dumper;

__PACKAGE__->mk_accessors( qw( resulting_state workflow _map ) );

sub init {
    my ( $self, $wf, $params ) = @_;
    ##! 1: 'start ' . $params->{name}
    ##! 64: 'self: ' . Dumper $self
    ##! 64: 'params: ' . Dumper $params
    ##! 64: 'wf: ' . Dumper $wf

    # FIXME - this is a bit of a hack - we're peeking into Workflow's
    # internal structures here. Workflow should provide a way to get
    # the resulting state for an activity itself.
    $self->resulting_state($wf->{_states}->{$wf->state()}->{_actions}->{$params->{name}}->{resulting_state});
    ##! 16: 'Workflow :'.ref $wf
    ##! 16: 'resulting_state: ' . $self->resulting_state()
    $self->{PKI_REALM} = CTX('session')->get_pki_realm();
    ##! 16: 'self->{PKI_REALM} = ' . $self->{PKI_REALM}
    
    $self->workflow( $wf );

    
    # copy the source params
    my $params_merged = { % { $params }};
    
    # init the _map parameters
    my $_map = {};
    
    foreach my $key (keys %{$params}) {
        if ($key !~ /^_map_(.*)/) { next; }
        
        # Remove map key from the hash
        delete $params_merged->{$key};
        
        my $name = $1;
        my $val = $params->{$key};
        $_map->{$name} = $params->{$key};
        ##! 8: 'Found param ' . $name . ' - value : ' . $params->{$key}

=cut disabled-by-oli

        if ($val =~ /^\$(\S+)/) {
            # copy from context
            $_map->{$name} = ['ctx', $1];
                
        } else { # }if ($val =~ /^\&(\S+)/) {
            # TT parser           
            $_map->{$name} = ['tt', $val ];
        #} else { 
        #    
        #    # static value, add to plain params hash 
        #    $params_merged->{$name} = $val;
        } 

=cut disabled-by-oli

    }
       
    # call Workflow::Action's init()
    $self->SUPER::init($wf, $params_merged);

    $self->_map( $_map );
    
    ##! 32: 'merged params ' . Dumper  $params_merged
    ##! 32: 'map ' . Dumper  $_map    
{'fraction_non_alphanumeric': 0.18192893401015228, 'fraction_numerical': 0.014619289340101522, 'mean_word_length': 2.3464673913043477, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1684206', 'n_tokens_mistral': 1830, 'n_tokens_neox': 1705, 'n_words': 427}