Skip to content

Commit

Permalink
Issue #816: add object dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
bschmalhofer committed Feb 22, 2021
1 parent bb3fb03 commit 10420cd
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 42 deletions.
22 changes: 12 additions & 10 deletions Kernel/System/Console/Command/Maint/Elasticsearch/Migration.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ use parent qw(Kernel::System::Console::BaseCommand);
## nofilter(TidyAll::Plugin::OTOBO::Perl::ForeachToFor)

our @ObjectDependencies = (
'Kernel::System::Elasticsearch',
'Kernel::Config',
'Kernel::System::CustomerCompany',
'Kernel::System::CustomerUser',
'Kernel::System::Elasticsearch',
'Kernel::System::GeneralCatalog',
'Kernel::System::GenericInterface::Webservice',
'Kernel::System::ITSMConfigItem',
'Kernel::System::Package',
'Kernel::System::Ticket',
'Kernel::System::Ticket::Article',
'Kernel::System::Package',
);

sub Configure {
Expand Down Expand Up @@ -110,7 +112,7 @@ sub Run {

if ( $Targets =~ /t|i/ ) {
$Self->CreateAttachmentPipeline(
ESObject => $ESObject,
ESObject => $ESObject,
);
}

Expand Down Expand Up @@ -521,16 +523,16 @@ sub MigrateConfigItems {

# check whether ITSMConfigurationManagment is installed
my $PackageObject = $Kernel::OM->Get('Kernel::System::Package');
my $IsInstalled = $PackageObject->PackageIsInstalled(
Name => 'ITSMConfigurationManagement',
my $IsInstalled = $PackageObject->PackageIsInstalled(
Name => 'ITSMConfigurationManagement',
);
if ( !$IsInstalled ) {
$Self->Print("<green>Skipping ITSMConfigItems (ITSMConfigurationManagment not installed)...</green>\n");
return 1;
}

my $GeneralCatalogObject = $Kernel::OM->Get('Kernel::System::GeneralCatalog');
my $ConfigItemObject = $Kernel::OM->Get('Kernel::System::ITSMConfigItem');
my $ConfigItemObject = $Kernel::OM->Get('Kernel::System::ITSMConfigItem');

my $ClassList = $Kernel::OM->Get('Kernel::System::GeneralCatalog')->ItemList(
Class => 'ITSM::ConfigItem::Class',
Expand All @@ -541,7 +543,7 @@ sub MigrateConfigItems {

my @ActiveClasses;
CLASS:
for my $Class ( keys %{ $ClassList } ) {
for my $Class ( keys %{$ClassList} ) {
next CLASS if $ExcludedClasses->{$Class};
push @ActiveClasses, $Class;
}
Expand Down Expand Up @@ -604,14 +606,14 @@ sub MigrateConfigItems {
return 1 if !@ActiveClasses;

my $ConfigItems = $ConfigItemObject->ConfigItemSearch(
ClassIDs => [ @ActiveClasses ],
ClassIDs => [@ActiveClasses],
);

my $Count = 0;
my $CICount = scalar( @{ $ConfigItems } );
my $CICount = scalar( @{$ConfigItems} );

my $Errors = 0;
for my $ConfigItemID ( @{ $ConfigItems } ) {
for my $ConfigItemID ( @{$ConfigItems} ) {

$Count++;

Expand Down
3 changes: 2 additions & 1 deletion Kernel/System/MigrateFromOTRS/CloneDB/Backend.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ use Kernel::System::ObjectManager;
use Kernel::System::VariableCheck qw(:all);

our @ObjectDependencies = (
'Kernel::Language',
'Kernel::System::DB',
'Kernel::System::Log',
'Kernel::System::Main',
'Kernel::System::Log',
);

=head1 NAME
Expand Down
6 changes: 4 additions & 2 deletions Kernel/System/MigrateFromOTRS/CloneDB/Driver/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ use Kernel::System::VariableCheck qw(:all);

our @ObjectDependencies = (
'Kernel::Config',
'Kernel::Language',
'Kernel::System::Cache',
'Kernel::System::DB',
'Kernel::System::DateTime',
'Kernel::System::Encode',
'Kernel::System::Log',
'Kernel::System::DateTime',
'Kernel::System::Main',
'Kernel::System::MigrateFromOTRS::Base',
'Kernel::System::Cache',
);

=head1 NAME
Expand Down
1 change: 1 addition & 0 deletions Kernel/System/MigrateFromOTRS/OTOBOACLDeploy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use parent qw(Kernel::System::MigrateFromOTRS::Base);
# OTOBO modules

our @ObjectDependencies = (
'Kernel::Config',
'Kernel::System::ACL::DB::ACL',
'Kernel::System::Cache',
'Kernel::System::DateTime',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ use parent qw(Kernel::System::MigrateFromOTRS::Base);
use Kernel::System::VariableCheck qw(:all);

our @ObjectDependencies = (
'Kernel::System::GenericInterface::Webservice',
'Kernel::System::Cache',
'Kernel::System::DateTime',
'Kernel::Config',
'Kernel::System::Cache',
'Kernel::System::DB',
'Kernel::System::DateTime',
'Kernel::System::GenericInterface::Webservice',
'Kernel::System::Main',
'Kernel::System::Package',
'Kernel::System::XML',
);

Expand Down Expand Up @@ -99,7 +100,7 @@ sub Run {
my %Webservices = $Self->_GetWebserviceConfigs();
my %Result = (
Message => $Self->{LanguageObject}->Translate("Migrate web service configuration."),
);
);

WEBSERVICE:
for my $Name ( sort keys %Webservices ) {
Expand All @@ -121,7 +122,7 @@ sub Run {
my $Webservice = $WebserviceObject->WebserviceGet(
Name => 'Elasticsearch',
);

if ( IsHashRefWithData($Webservice) ) {
$Result{Comment} .= 'use existing; ';
next WEBSERVICE;
Expand All @@ -134,7 +135,7 @@ sub Run {
);

if ( !$ID ) {
$Result{Comment} .= $Self->{LanguageObject}->Translate( 'Failed - see the log!' );
$Result{Comment} .= $Self->{LanguageObject}->Translate('Failed - see the log!');
$Result{Successful} = 0;
return \%Result;
}
Expand Down Expand Up @@ -356,7 +357,7 @@ sub _GetWebserviceConfigs {
return (
Elasticsearch => {
ValidID => 2,
Config => {
Config => {
Debugger => {
DebugThreshold => 'error',
TestMode => '0',
Expand All @@ -369,13 +370,13 @@ sub _GetWebserviceConfigs {
},
RemoteSystem => '',
Requester => {
Invoker => $Invoker{Elasticsearch},
Invoker => $Invoker{Elasticsearch},
Transport => {
Config => {
DefaultCommand => 'POST',
Host => 'http://localhost:9200',
InvokerControllerMapping => $ICMapping{Elasticsearch},
Timeout => '30',
Timeout => '30',
},
Type => 'HTTP::REST',
},
Expand Down
43 changes: 23 additions & 20 deletions Kernel/System/MigrateFromOTRS/OTOBOPackageSpecifics.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ use parent qw(Kernel::System::MigrateFromOTRS::Base);
# OTOBO modules

our @ObjectDependencies = (
'Kernel::System::DB',
'Kernel::System::Cache',
'Kernel::System::DB',
'Kernel::System::DateTime',
'Kernel::System::FAQ',
'Kernel::System::Package',
);

=head1 NAME
Kernel::System::MigrateFromOTRS::OTOBOResponseTemplatesMigrate - Migrate response table to OTOBO.
Kernel::System::MigrateFromOTRS::OTOBOPackageSpecifics - Migrate response table to OTOBO.
=head1 SYNOPSIS
Expand Down Expand Up @@ -70,8 +72,8 @@ sub Run {
my ( $Self, %Param ) = @_;

# Set cache object with taskinfo and starttime to show current state in frontend
my $CacheObject = $Kernel::OM->Get('Kernel::System::Cache');
my $PackageObject = $Kernel::OM->Get('Kernel::System::Package');
my $CacheObject = $Kernel::OM->Get('Kernel::System::Cache');
my $PackageObject = $Kernel::OM->Get('Kernel::System::Package');

my @SubTasks = (
{
Expand All @@ -80,18 +82,19 @@ sub Run {
Result => 'Changed path of inline images.',
Sub => \&_FAQ_InlineImg,
},
# {
# Package => 'Name of Package required',
# Description => 'What are we doing?',
# Result => 'What was done in case of success.',
# Sub => \&Subroutine,
# },

# {
# Package => 'Name of Package required',
# Description => 'What are we doing?',
# Result => 'What was done in case of success.',
# Sub => \&Subroutine,
# },
);

my %Done;
my %Failed;
SUBTASK:
for my $SubTask ( @SubTasks ) {
for my $SubTask (@SubTasks) {

next SUBTASK if !$PackageObject->PackageIsInstalled( Name => $SubTask->{Package} );

Expand All @@ -106,7 +109,7 @@ sub Run {
},
);

if ( $SubTask->{Sub}->( $Self ) ) {
if ( $SubTask->{Sub}->($Self) ) {
push @{ $Done{ $SubTask->{Package} } }, $SubTask->{Result};
}
else {
Expand All @@ -120,26 +123,26 @@ sub Run {
Successful => 1,
);

if ( %Done ) {
if (%Done) {
$Result{Comment} = $Self->{LanguageObject}->Translate('Done -');
for my $Package ( sort keys %Done ) {
$Result{Comment} .= " $Package:";
for my $Task ( @{ $Done{ $Package } } ) {
for my $Task ( @{ $Done{$Package} } ) {
$Result{Comment} .= " $Task";
}
}
}

if ( %Failed ) {
if (%Failed) {
$Result{Comment} .= $Result{Comment} ? ' ' : '';
$Result{Comment} .= $Self->{LanguageObject}->Translate('Failed at -');
for my $Package ( sort keys %Failed ) {
$Result{Comment} .= " $Package:";
for my $Task ( @{ $Failed{ $Package } } ) {
for my $Task ( @{ $Failed{$Package} } ) {
$Result{Comment} .= " $Task";
}
}

$Result{Successful} = 0;
}

Expand All @@ -148,7 +151,7 @@ sub Run {

sub _FAQ_InlineImg {
my ( $Self, %Param ) = @_;

my %Substitutions = (
qr/src="\/otrs\/index\.pl/ => 'src="/otobo/index.pl',
);
Expand All @@ -163,7 +166,7 @@ sub _FAQ_InlineImg {
my $Success = 1;

FAQ:
for my $FAQID ( @FAQIDs ) {
for my $FAQID (@FAQIDs) {
my %FAQ = $FAQObject->FAQGet(
ItemID => $FAQID,
ItemFields => 1,
Expand All @@ -172,7 +175,7 @@ sub _FAQ_InlineImg {

my $Substituded = 0;

for my $i ( 1..6 ) {
for my $i ( 1 .. 6 ) {
for my $RegEx ( keys %Substitutions ) {
$Substituded = 1 if ( $FAQ{"Field$i"} && $FAQ{"Field$i"} =~ s/$RegEx/$Substitutions{ $RegEx }/ );
}
Expand Down

0 comments on commit 10420cd

Please sign in to comment.