Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
zlamalp committed Nov 30, 2022
2 parents a8f7456 + 1789230 commit bc2d474
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 210 deletions.
3 changes: 1 addition & 2 deletions gen/du_info_export
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use Tie::IxHash;

our $SERVICE_NAME = "du_info_export";
our $PROTOCOL_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.2";
my $SCRIPT_VERSION = "3.0.3";

perunServicesInit::init;
my $DIRECTORY = perunServicesInit::getDirectory;
Expand Down Expand Up @@ -77,7 +77,6 @@ foreach my $resourceId ($data->getResourceIds()) {
foreach my $memberId ($data->getMemberIdsForResource(resource => $resourceId)) {
my $uuid = $data->getUserAttributeValue(attrName => $A_U_UUID, member => $memberId);
my $einfraLogin = $data->getUserAttributeValue(attrName => $A_USER_LOGIN_EINFRA, member => $memberId);
$einfraLogin = defined $einfraLogin ? $einfraLogin : "";

unless(defined $attributesByUUID{$uuid}) {

Expand Down
4 changes: 2 additions & 2 deletions gen/myq_printsvc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use perunServicesUtils;

local $::SERVICE_NAME = "myq_printsvc";
local $::PROTOCOL_VERSION = "3.1.0";
my $SCRIPT_VERSION = "3.0.0";
my $SCRIPT_VERSION = "3.0.1";

perunServicesInit::init;
my $DIRECTORY = perunServicesInit::getDirectory;
Expand Down Expand Up @@ -84,7 +84,7 @@ for my $login (@logins) {
# CODE
print FILE $login . ";";
# SCANSTORAGE
print FILE '"' . "\\\\copy.ics.muni.cz\\$login\\Scan" . '";';
print FILE '"' . "\\\\ha-bay.ics.muni.cz\\sciscan\\$login\\Scan" . '";';
# PIN
print FILE ";";
# MANAGED_GROUPS
Expand Down
27 changes: 21 additions & 6 deletions gen/o365_mu
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ sub saveUsersToFile;
sub saveGroupsToFile;

our $SERVICE_NAME = "o365_mu";
our $PROTOCOL_VERSION = "3.1.0";
my $SCRIPT_VERSION = "3.1.1";
our $PROTOCOL_VERSION = "3.2.0";
my $SCRIPT_VERSION = "3.2.0";

perunServicesInit::init;
my $DIRECTORY = perunServicesInit::getDirectory;
Expand All @@ -28,6 +28,7 @@ my $data = perunServicesInit::getHashedDataWithGroups;
#-------------------------------------------------------------------------

our $A_G_AD_NAME; *A_G_AD_NAME = \'urn:perun:group:attribute-def:def:adName:o365mu';
our $A_G_O365_MAILS; *A_G_O365_MAILS = \'urn:perun:group:attribute-def:def:o365EmailAddresses:o365mu';
our $A_F_DOMAIN_NAME; *A_F_DOMAIN_NAME = \'urn:perun:facility:attribute-def:def:o365DomainName';
our $A_MG_O365_SEND_AS; *A_MG_O365_SEND_AS = \'urn:perun:member_group:attribute-def:virt:o365SendAs';
our $A_U_O365_MAIL_ADDRS; *A_U_O365_MAIL_ADDRS = \'urn:perun:user:attribute-def:def:o365EmailAddresses:mu';
Expand All @@ -45,6 +46,8 @@ our $MAIL_FORWARD_TEXT = "mailForward";
our $ARCHIVE_TEXT = "archive";
our $STORE_AND_FORWARD_TEXT = "storeAndForward";
our $EMAIL_ADDRESSES = "emailAddresses";
our $GROUP_MAIL_TEXT = "groupMail";
our $GROUP_CONTACTS_TEXT = "groupContacts";

###------------------------------------------------------------------------------
### RESOURCE MAILBOXES CONFIGURATION
Expand Down Expand Up @@ -338,7 +341,18 @@ sub processGroup {
if($groupADName) {
#all groups for mu should have specific part of name
$groupADName = $groupADName . '_group.muni.cz';
$groups->{$groupADName} = undef;
#get group mail
my $groupMails = $data->getGroupAttributeValue( group => $groupId, attrName => $A_G_O365_MAILS );
#take the first email if there is none with right domain
my $groupMail = $groupMails->[0];
foreach my $mail(sort @$groupMails) {
if($mail =~ m/\@group[.]muni[.]cz/) {
$groupMail = $mail;
last;
}
}

$groups->{$groupADName}->{$GROUP_MAIL_TEXT} = $groupMail;

foreach my $memberId($data->getMemberIdsForResourceAndGroup( resource => $resourceId, group => $groupId )) {
processGroupMember $memberId, $groupId, $resourceId, $groupADName;
Expand All @@ -361,7 +375,7 @@ sub processGroupMember {
my $UPN = $users->{$UCO}->{$UPN_TEXT};
my $sendAsGroup = $data->getMemberGroupAttributeValue( member => $memberId, group => $groupId, attrName => $A_MG_O365_SEND_AS );

if($sendAsGroup) { $groups->{$groupADName}->{$UPN} = 1; }
if($sendAsGroup) { $groups->{$groupADName}->{$GROUP_CONTACTS_TEXT}->{$UPN} = 1; }
}

# input: file name for users data, usersData structure
Expand Down Expand Up @@ -394,9 +408,10 @@ sub saveGroupsToFile {
binmode FILE, ":utf8";

foreach my $adName (sort keys %$groupsData) {
my $contacts = join " ", sort keys %{$groupsData->{$adName}};
my $groupMail = $groupsData->{$adName}->{$GROUP_MAIL_TEXT};
my $contacts = join " ", sort keys %{$groupsData->{$adName}->{$GROUP_CONTACTS_TEXT}};
unless($contacts) { $contacts = ""; }
print FILE $adName . "\t" . $contacts . "\n";
print FILE $adName . "\t" . $contacts . "\t" . $groupMail . "\n";
}

close(FILE) or die "Cannot close $fileName: $! \n";
Expand Down
86 changes: 65 additions & 21 deletions send/VsupIfis.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package VsupIfis;
use Exporter 'import';
@ISA = ('Exporter');
@EXPORT = qw(load_kos load_vema load_dc2);
@EXPORT = qw(load_kos load_vema load_dc2 load_is);

use strict;
use warnings FATAL => 'all';
Expand Down Expand Up @@ -42,43 +42,43 @@ sub init_config($) {
}

#
# Load map of users relations from KOS
# Load map of users relations from IS
# Require params: $hostname, $port, $db_name, $db_user, $db_password
#
sub load_kos() {
sub load_is() {

my $config = init_config("kos.conf");
my $config = init_config("is.conf");

my $hostname = $config->{"hostname"};
my $port = $config->{"port"};
my $db_name = $config->{"db_name"};
my $db_user = $config->{"username"};
my $db_password = $config->{"password"};

my $dbh = DBI->connect("dbi:Oracle://$hostname:$port/$db_name", $db_user, $db_password,{ RaiseError=>1, AutoCommit=>0, LongReadLen=>65536, ora_charset => 'AL32UTF8'}) or die "Connect to database $db_name Error!\n";
$dbh->do("alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS'");
my $dbh = DBI->connect("dbi:Pg:dbname=$db_name;host=$hostname;port=$port", $db_user, $db_password,{ RaiseError=>1, AutoCommit=>0 }) or die "Connect to database $db_name Error!\n";

# Select query for input database (KOS) - all students with UCO not null and DO_ >= now or null
my $sth = $dbh->prepare(qq{select case when OSB_ID=UCO then null else UCO end as UCO, NS, 'STU' as TYP_VZTAHU, STUD_FORMA as DRUH_VZTAHU, ID_STUDIA as VZTAH_CISLO, STUD_FORMA as STU_FORMA, STUD_STAV as STUD_STAV, STUD_TYP as STU_PROGR, OD, DO_, KARTA_LIC as KARTA_IDENT from SIS2IDM_STUDIA where (case when OSB_ID=UCO then null else UCO end) is not null and (DO_ >= TRUNC(SYSDATE) OR DO_ is NULL)});
# Select query for input database (IS) - all students with UCO_PERUN not null and STUD_DO >= now or null
my $sth = $dbh->prepare(qq{select distinct ex_is2idm_studia.UCO_PERUN as UCO, NS, 'STU' as TYP_VZTAHU, STUD_FORMA as DRUH_VZTAHU, ex_is2idm_studia.ID_STUDIA as VZTAH_CISLO, STUD_FORMA as STU_FORMA, STUD_STAV as STUD_STAV, STUD_TYP as STU_PROGR, STUD_OD, STUD_DO, KARTA_LIC as KARTA_IDENT from ex_is2idm_studia left join ex_is2idm_adresy on ex_is2idm_studia.ID_STUDIA=ex_is2idm_adresy.ID_STUDIA where ex_is2idm_studia.UCO_PERUN is not null and (STUD_DO >= CURRENT_DATE OR STUD_DO is NULL)});
$sth->execute();

# Structure to store data from input database (KOS)
# Structure to store data from input database (IS)
my $inputData = {};
while(my $row = $sth->fetchrow_hashref()) {
my $key = $row->{VZTAH_CISLO};
$inputData->{$key}->{'OSB_ID'} = $row->{UCO};
$inputData->{$key}->{'TYP_VZTAHU'} = $row->{TYP_VZTAHU};
$inputData->{$key}->{'DRUH_VZTAHU'} = $row->{DRUH_VZTAHU};
$inputData->{$key}->{'STU_FORMA'} = $row->{STU_FORMA};
$inputData->{$key}->{'STUD_STAV'} = $row->{STUD_STAV};
$inputData->{$key}->{'STU_PROGR'} = $row->{STU_PROGR};
$inputData->{$key}->{'NS'} = $row->{NS};
$inputData->{$key}->{'VZTAH_OD'} = $row->{OD};
$inputData->{$key}->{'VZTAH_DO'} = $row->{DO_};
$inputData->{$key}->{'KARTA_IDENT'} = $row->{KARTA_IDENT};
# disregarding the select Postgres is using lower-cased column names.
my $key = $row->{vztah_cislo};
$inputData->{$key}->{'OSB_ID'} = $row->{uco};
$inputData->{$key}->{'TYP_VZTAHU'} = $row->{typ_vztahu};
$inputData->{$key}->{'DRUH_VZTAHU'} = $row->{druh_vztahu};
$inputData->{$key}->{'STU_FORMA'} = $row->{stu_forma};
$inputData->{$key}->{'STUD_STAV'} = $row->{stud_stav};
$inputData->{$key}->{'STU_PROGR'} = $row->{stu_progr};
$inputData->{$key}->{'NS'} = $row->{ns};
$inputData->{$key}->{'VZTAH_OD'} = $row->{stud_od};
$inputData->{$key}->{'VZTAH_DO'} = $row->{stud_do};
$inputData->{$key}->{'KARTA_IDENT'} = $row->{karta_ident};
}

# Disconnect from input database (KOS)
# Disconnect from input database (IS)
$dbh->disconnect();

return $inputData;
Expand Down Expand Up @@ -132,6 +132,50 @@ sub load_dc2() {

}

#
# Load map of users relations from KOS
# Require params: $hostname, $port, $db_name, $db_user, $db_password
#
sub load_kos() {

my $config = init_config("kos.conf");

my $hostname = $config->{"hostname"};
my $port = $config->{"port"};
my $db_name = $config->{"db_name"};
my $db_user = $config->{"username"};
my $db_password = $config->{"password"};

my $dbh = DBI->connect("dbi:Oracle://$hostname:$port/$db_name", $db_user, $db_password,{ RaiseError=>1, AutoCommit=>0, LongReadLen=>65536, ora_charset => 'AL32UTF8'}) or die "Connect to database $db_name Error!\n";
$dbh->do("alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS'");

# Select query for input database (KOS) - all students with UCO not null and DO_ >= now or null
my $sth = $dbh->prepare(qq{select case when OSB_ID=UCO then null else UCO end as UCO, NS, 'STU' as TYP_VZTAHU, STUD_FORMA as DRUH_VZTAHU, ID_STUDIA as VZTAH_CISLO, STUD_FORMA as STU_FORMA, STUD_STAV as STUD_STAV, STUD_TYP as STU_PROGR, OD, DO_, KARTA_LIC as KARTA_IDENT from SIS2IDM_STUDIA where (case when OSB_ID=UCO then null else UCO end) is not null and (DO_ >= TRUNC(SYSDATE) OR DO_ is NULL)});
$sth->execute();

# Structure to store data from input database (KOS)
my $inputData = {};
while(my $row = $sth->fetchrow_hashref()) {
my $key = $row->{VZTAH_CISLO};
$inputData->{$key}->{'OSB_ID'} = $row->{UCO};
$inputData->{$key}->{'TYP_VZTAHU'} = $row->{TYP_VZTAHU};
$inputData->{$key}->{'DRUH_VZTAHU'} = $row->{DRUH_VZTAHU};
$inputData->{$key}->{'STU_FORMA'} = $row->{STU_FORMA};
$inputData->{$key}->{'STUD_STAV'} = $row->{STUD_STAV};
$inputData->{$key}->{'STU_PROGR'} = $row->{STU_PROGR};
$inputData->{$key}->{'NS'} = $row->{NS};
$inputData->{$key}->{'VZTAH_OD'} = $row->{OD};
$inputData->{$key}->{'VZTAH_DO'} = $row->{DO_};
$inputData->{$key}->{'KARTA_IDENT'} = $row->{KARTA_IDENT};
}

# Disconnect from input database (KOS)
$dbh->disconnect();

return $inputData;

}

#
# Load map of users relations from VEMA
#
Expand Down
5 changes: 5 additions & 0 deletions send/o365_mu_process.pl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
my $PLAIN_TEXT_OBJECT_TEXT = "plainTextObject";
my $AD_GROUP_NAME_TEXT = "groupName";
my $SEND_AS_TEXT = "sendAs";
my $GROUP_MAIL_TEXT = "groupMail";
my $COMMAND_TEXT = "command";
my $PARAMETERS_TEXT = "parameters";

Expand Down Expand Up @@ -504,6 +505,8 @@ sub readDataAboutGroups {
my $groupADName = $parts[0];
my @emails = ();
if($parts[1]) { @emails = split / /, $parts[1]; }
my $groupMail = "";
if($parts[2]) { $groupMail = $parts[2]; }

#If groupADName is from any reason empty, set global return code to 1 and skip this group
unless($line) {
Expand All @@ -514,6 +517,7 @@ sub readDataAboutGroups {

$groupsStruc->{$groupADName}->{$AD_GROUP_NAME_TEXT} = $groupADName;
$groupsStruc->{$groupADName}->{$SEND_AS_TEXT} = \@emails;
$groupsStruc->{$groupADName}->{$GROUP_MAIL_TEXT} = $groupMail;
$groupsStruc->{$groupADName}->{$PLAIN_TEXT_OBJECT_TEXT} = $line;
}
close FILE or die "ERROR - Could not close file $pathToFile: $!\n";
Expand Down Expand Up @@ -596,6 +600,7 @@ sub getGroupsContent {
my $group = {};
$group->{$AD_GROUP_NAME_TEXT} = $key;
$group->{$SEND_AS_TEXT} = $groupToProcess->{$SEND_AS_TEXT};
$group->{$GROUP_MAIL_TEXT} = $groupToProcess->{$GROUP_MAIL_TEXT};
push @parameters, $group;
}

Expand Down
Loading

0 comments on commit bc2d474

Please sign in to comment.