diff --git a/gen/pbs_publication_fairshare b/gen/pbs_publication_fairshare index 373c5f26..1035e49b 100755 --- a/gen/pbs_publication_fairshare +++ b/gen/pbs_publication_fairshare @@ -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; @@ -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); @@ -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 @@ -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'; diff --git a/gen/vsup_is b/gen/vsup_is index 8a42a29c..a96c84ca 100755 --- a/gen/vsup_is +++ b/gen/vsup_is @@ -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; @@ -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'; @@ -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); @@ -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 || ''); @@ -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 ''; + +} diff --git a/send/VsupIfis.pm b/send/VsupIfis.pm index 00c1a45a..45af03f7 100755 --- a/send/VsupIfis.pm +++ b/send/VsupIfis.pm @@ -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 diff --git a/send/vsup_is b/send/vsup_is index 2c74399c..5316c86d 100755 --- a/send/vsup_is +++ b/send/vsup_is @@ -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);