Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
Johaney-s committed Oct 11, 2022
2 parents 6e9df55 + 2c29868 commit 2b64731
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
12 changes: 10 additions & 2 deletions gen/pbs_publication_fairshare
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ our $HOW_OLD_PUBLICATIONS; *HOW_OLD_PUBLICATIONS = \3; #in yea
our $A_USER_LOGIN; *A_USER_LOGIN = \'urn:perun:user_facility:attribute-def:virt:login';
our $A_USER_ID; *A_USER_ID = \'urn:perun:user:attribute-def:core:id';
our $A_RESOURCE_FAIRSHARE_GNAME; *A_RESOURCE_FAIRSHARE_GNAME = \'urn:perun:resource:attribute-def:def:fairshareGroupName';
our $A_RESOURCE_ID; *A_RESOURCE_ID = \'urn:perun:resource:attribute-def:core:id';
our $A_MEMBER_STATUS; *A_MEMBER_STATUS = \'urn:perun:member:attribute-def:core:status';

my $nowYear = (localtime)[5] + 1900;

Expand Down Expand Up @@ -59,6 +59,10 @@ foreach my $resourceId ($data->getResourceIds()) {

foreach my $memberId ($data->getMemberIdsForResource(resource => $resourceId)) {

# process only VALID members
my $status = $data->getMemberAttributeValue(member => $memberId, attrName => $A_MEMBER_STATUS);
next unless ($status eq "VALID");

my $userId = $data->getUserIdForMember(member => $memberId);
my $userLogin = $data->getUserFacilityAttributeValue(member => $memberId, attrName => $A_USER_LOGIN);

Expand All @@ -70,7 +74,7 @@ foreach my $resourceId ($data->getResourceIds()) {
$users->{$userId}->{"weight"} = 1.0;
$users->{$userId}->{"group"} = "G:" . $fairShareGroupName;

# skip users without any publication
# skip processing publications for users without any publication
next unless defined $authorsByID->{$userId};

# gather all users publications for later processing
Expand Down Expand Up @@ -102,6 +106,10 @@ foreach my $resourceId ($data->getResourceIds()) {
my $userId = $data->getUserIdForMember(member => $memberId);
next if($users->{$userId});

# process only VALID members
my $status = $data->getMemberAttributeValue(member => $memberId, attrName => $A_MEMBER_STATUS);
next unless ($status eq "VALID");

$users->{$userId}->{"login"} = $data->getUserFacilityAttributeValue(member => $memberId, attrName => $A_USER_LOGIN);
$users->{$userId}->{"weight"} = 1.0;
$users->{$userId}->{"group"} = 'root';
Expand Down
41 changes: 39 additions & 2 deletions gen/vsup_is
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ use strict;
use warnings;
use perunServicesInit;
use perunServicesUtils;
use Time::Piece;
sub resolveExpiration;

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

perunServicesInit::init;
my $DIRECTORY = perunServicesInit::getDirectory;
Expand All @@ -31,6 +33,7 @@ our $A_BIRTH_NUMBER; *A_BIRTH_NUMBER = \'urn:perun:user:attribute-def:def:birth
our $A_GENDER; *A_GENDER = \'urn:perun:user:attribute-def:def:gender';
our $A_JOB; *A_JOB = \'urn:perun:user:attribute-def:def:job';
our $A_EXPIRATION_DC2; *A_EXPIRATION_DC2 = \'urn:perun:user:attribute-def:def:expirationDc2';
our $A_EXPIRATION_MANUAL; *A_EXPIRATION_MANUAL = \'urn:perun:user:attribute-def:def:expirationManual';

our $A_PHONE; *A_PHONE = \'urn:perun:user:attribute-def:def:phoneDc2';
our $A_EMAIL_PRIV; *A_EMAIL_PRIV = \'urn:perun:user:attribute-def:opt:privateMail';
Expand Down Expand Up @@ -73,6 +76,7 @@ foreach my $resourceId ($data->getResourceIds()) {
my $gender = $data->getUserAttributeValue(member => $memberId, attrName => $A_GENDER);
my $job = $data->getUserAttributeValue(member => $memberId, attrName => $A_JOB);
my $expirationDC2 = $data->getUserAttributeValue(member => $memberId, attrName => $A_EXPIRATION_DC2);
my $expirationManual = $data->getUserAttributeValue(member => $memberId, attrName => $A_EXPIRATION_MANUAL);
my $phone = $data->getUserAttributeValue(member => $memberId, attrName => $A_PHONE);
my $emailPriv = $data->getUserAttributeValue(member => $memberId, attrName => $A_EMAIL_PRIV);
my $emailPrivKOS = $data->getUserAttributeValue(member => $memberId, attrName => $A_EMAIL_PRIV_KOS);
Expand All @@ -94,7 +98,7 @@ foreach my $resourceId ($data->getResourceIds()) {
$users->{$key}->{$A_BIRTH_NUMBER} = $birthNumber || '';
$users->{$key}->{$A_GENDER} = $gender || '';
$users->{$key}->{$A_JOB} = $job || '';
$users->{$key}->{$A_EXPIRATION_DC2} = $expirationDC2 || '';
$users->{$key}->{$A_EXPIRATION_DC2} = resolveExpiration($expirationDC2, $expirationManual);

$users->{$key}->{$A_PHONE} = $phone || '';
$users->{$key}->{$A_EMAIL_PRIV} = $emailPriv || ($emailPrivKOS || '');
Expand Down Expand Up @@ -131,3 +135,36 @@ for my $key (@keys) {
close(FILE);

perunServicesInit::finalize;

#
# Return latest of two expiration dates (DC2 / Manual)
#
sub resolveExpiration() {

# read input
my $expirationDc2 = shift;
my $expirationMan = shift;
# parse to time or undef
my $expirationDc2Time = (defined $expirationDc2 and length($expirationDc2) > 0) ? Time::Piece->strptime($expirationDc2,"%Y-%m-%d") : undef;
my $expirationManTime = (defined $expirationMan and length($expirationMan) > 0) ? Time::Piece->strptime($expirationMan,"%Y-%m-%d") : undef;

my @expirations = ();
if (defined $expirationDc2Time) { push(@expirations, $expirationDc2Time->epoch); }
if (defined $expirationManTime) { push(@expirations, $expirationManTime->epoch); }

# sort all expirations
my @sorted_expirations = sort { $a <=> $b } @expirations;
my $latest_expiration = $sorted_expirations[$#sorted_expirations];

if (defined $latest_expiration) {
if (defined $expirationDc2Time and ($latest_expiration == $expirationDc2Time->epoch)) {
return $expirationDc2;
}
if (defined $expirationManTime and ($latest_expiration == $expirationManTime->epoch)) {
return $expirationMan;
}
}
# expiration not set
return '';

}
2 changes: 1 addition & 1 deletion send/VsupIfis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ sub load_dc2() {

# Select query for input database (DC2) - internal/external teachers with valid relation
my $sth = $dbh->prepare(qq{SELECT UCO, VZTAH_CISLO, NS, VZTAH_STATUS_NAZEV, VZTAH_STATUS_CISLO, OD, DO,
CASE WHEN (VZTAH_STATUS_CISLO in (1,2,4,5,6,7,8,9,10,16,17,21) AND VZTAH_FUNKCE_CISLO in (1,2,3,4,5,52))
CASE WHEN (VZTAH_STATUS_CISLO in (1,2,4,5,6,7,8,9,10,16,17,18,21) AND VZTAH_FUNKCE_CISLO in (1,2,3,4,5,52))
THEN 'ITIC'
ELSE null
END as KARTA_IDENT
Expand Down
2 changes: 1 addition & 1 deletion send/vsup_is
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ foreach my $key (sort keys %$dataByKeys) {

# Construct BIRTH_DATE from BIRTH_NUMBER
my $BIRTH_DATE = undef;
if (defined $BIRTH_NUMBER and length( $BIRTH_NUMBER > 0)) {
if (defined $BIRTH_NUMBER and length($BIRTH_NUMBER) > 0) {

my $YY = substr($BIRTH_NUMBER, 0, 2);
my $MM = substr($BIRTH_NUMBER, 2, 2);
Expand Down

0 comments on commit 2b64731

Please sign in to comment.