Skip to content

Commit

Permalink
Merge pull request #690 from zlamalp/arcgis
Browse files Browse the repository at this point in the history
feat(arcgis_licenses_mu): sort json output to be comparable
  • Loading branch information
zlamalp authored May 25, 2022
2 parents 0c3132f + f432b63 commit 5518477
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions gen/arcgis_licenses_mu
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ our $A_RESOURCE_ARCGIS_AFFILIATION; *A_RESOURCE_ARCGIS_AFFILIATION = \'urn:perun

#Headers
my $firstNameHeader = "firstName";
my $lastNameHeader = "lastName";
my $lastNameHeader = "lastName";
my $loginHeader = "UCO";
my $rolesHeader = "roles";
my $affiliationHeader = "isActive";
Expand All @@ -37,16 +37,16 @@ my $usersWithRoles = {};
my $facilityId = $data->getFacilityId;

foreach my $resourceId ( $data->getResourceIds() ) {

my $roleOnResource = $data->getResourceAttributeValue( attrName => $A_RESOURCE_ARCGIS_ROLE, resource => $resourceId );
my $isResourceActiveForAffiliation = $data->getResourceAttributeValue( attrName => $A_RESOURCE_ARCGIS_AFFILIATION, resource => $resourceId );

#process all members on resource
#process all members on resource
foreach my $memberId ($data->getMemberIdsForResource( resource => $resourceId )) {
#skip not VALID members in VO
my $statusInVo = $data->getMemberAttributeValue( attrName => $A_MEMBER_STATUS, member => $memberId );
if( $statusInVo ne $statusValid ) { next; }

my $UCO = $data->getUserFacilityAttributeValue( attrName => $A_USER_LOGIN, member => $memberId, facility => $facilityId );

#if user not exists, create record for him first
Expand Down Expand Up @@ -87,11 +87,14 @@ for my $key (keys %{$usersWithRoles}) {
push @data, $userRecord;
}

# order all entries by UCO
@data = sort { $a->{$loginHeader} <=> $b->{$loginHeader} } @data;

#print json to the file
my $file = "$DIRECTORY/$::SERVICE_NAME.json";
open FILE,">$file" or die "Cannot open $file: $! \n";
binmode(FILE);
print FILE JSON::XS->new->utf8->pretty->encode(\@data);
print FILE JSON::XS->new->utf8->pretty->canonical->encode(\@data);
close (FILE) or die "Cannot close $file: $! \n";

perunServicesInit::finalize;

0 comments on commit 5518477

Please sign in to comment.