Project

General

Profile

« Previous | Next » 

Revision 3598

Added by walbridge about 17 years ago

Updated the ResponsibleParty object creation to be more robust. Now handles N MetadataProvider elements as expected.

View differences:

src/perl/register-dataset.cgi
1212 1212
    # putting everything else under project
1213 1213
    $doc .= "<project>";
1214 1214
    $doc .= titleElement();
1215
    my %originators = personnelCreate();
1216
    $doc .= personnelList(\%originators, 'personnel');
1215
    my %originators = personnelCreate('personnel');
1216
    $doc .= personnelList(\%originators);
1217 1217
    $doc .= abstractElement();
1218 1218
    $doc .= "<studyAreaDescription>\n";
1219 1219
    $doc .= coverageElement();
......
1231 1231
    $doc .= titleElement();
1232 1232
    $doc .= creatorElement();
1233 1233
    $doc .= contactElement('creator');
1234
    my %originators = personnelCreate();
1235
    $doc .= personnelList(\%originators, 'associatedParty');
1234
    my %originators = personnelCreate('associatedParty');
1235
    $doc .= personnelList(\%originators);
1236 1236

  
1237 1237
    $doc .= pubElement();
1238 1238
    $doc .= abstractElement();
......
1253 1253
# EML document creation functions
1254 1254

  
1255 1255
sub personnelCreate {
1256
    # TODO: improve flow for personnel, associatedParty
1256
    # passed parameter defines default role for individuals
1257
    my $defaultRole = shift;
1257 1258
    # element name => objects of that type
1258 1259
    my %orig = (
1259
                'personnel'          => [],
1260
                'creator'          => [],
1261
                'metadataProvider' => [],
1262
                'publisher'        => [],
1263
                $defaultRole       => [],
1260 1264
            );
1265
    # form name => EML element name
1266
    my %roles = (
1267
                 'Originator'        => 'creator',
1268
                 'Metadata Provider' => 'metadataProvider',
1269
                 'Publisher'         => 'publisher',
1270
              );
1261 1271

  
1262
    push (@{$orig{personnel}}, [$FORM::providerGivenName, $FORM::providerSurName, 'Metadata Provider']);
1272
    push (@{$orig{'metadataProvider'}}, [$FORM::providerGivenName, $FORM::providerSurName]);
1263 1273

  
1264 1274
    # Additional originators
1265 1275
    foreach my $origName (param()) {
......
1271 1281
                my $first = normalize(param("origNamefirst" . $origNum));
1272 1282
                my $last  = normalize(param("origNamelast" . $origNum));
1273 1283
                my $origRole = param("origRole" . $origNum);
1284
                my $roleName = $roles{$origRole};
1285
                if (!hasContent($roleName)) {
1286
                  $roleName = $defaultRole;
1287
                }
1274 1288

  
1275
                push (@{$orig{personnel}}, [$first, $last, $origRole]);
1289
                #debug("XXXXX role name: " . $roleName);
1290
                push (@{$orig{$roleName}}, [$first, $last, $origRole]);
1276 1291
            }
1277 1292
        }
1278 1293
    }
1279
    return %orig
1294
    return %orig;
1280 1295
}
1281 1296

  
1282 1297
sub personnelList {
1283 1298
    my ($orig, $type) = @_;
1284 1299
    my %orig = %$orig;
1285

  
1300
    
1286 1301
    my $elemList = "";
1287
    
1288
    foreach my $v (@{$orig->{'personnel'}}) {
1289
        my ($first, $last, $role) = @$v;
1290
        my $elemRole = $type;
1291
        my $elem = "<individualName>\n";
1292
        $elem .= "<givenName>".normalize($first)."</givenName>\n";
1293
        $elem .= "<surName>".normalize($last)."</surName>\n";
1294
        $elem .= "</individualName>\n";
1302
    foreach my $role (keys %orig) {
1303
        foreach my $v (@{$orig->{$role}}) {
1304
            my ($first, $last, $origRole) = @$v;
1305
            my $elem = "<individualName>\n";
1306
            $elem .= "<givenName>".normalize($first)."</givenName>\n";
1307
            $elem .= "<surName>".normalize($last)."</surName>\n";
1308
            $elem .= "</individualName>\n";
1295 1309

  
1296
        if ($role eq "Originator") {
1297
            $elemRole = 'creator';
1298
        }
1299
        elsif ($role eq "Metadata Provider") {
1300
            $elemRole = 'metadataProvider';
1301
        }
1302
        elsif ($role eq "Publisher") {
1303
            $elemRole = 'publisher';
1304
        }
1305
        else {
1306
            $elemRole = $type;
1307
        }
1310
            if (($role eq 'personnel') && ($FORM::origNameOrgContact)) {
1311
                $elem .= "<organizationName>$FORM::origNameOrgContact</organizationName>\n";
1312
            }
1308 1313

  
1309
        if (($elemRole eq 'personnel') && ($FORM::origNameOrgContact) ) {
1310
            $elem .= "<organizationName>$FORM::origNameOrgContact</organizationName>\n";
1314
            if (($role eq 'personnel') || ($role eq 'associatedParty')) {
1315
                my $roleElem = $role;
1316
                if (hasContent($origRole)) {
1317
                    $roleElem = $origRole;
1318
                }
1319
                $elem .= "<role>".normalize($roleElem)."</role>\n";
1320
            }
1321
            $elemList .= "<$role>$elem</$role>\n";
1311 1322
        }
1312

  
1313
        if (($elemRole eq 'personnel') || ($elemRole eq 'associatedParty') ) {
1314
            $elem .= "<role>".normalize($role)."</role>\n";
1315
        }
1316

  
1317
        $elemList .= "<$elemRole>\n$elem</$elemRole>\n";
1318 1323
    }
1319 1324
    return $elemList;
1320 1325
}
......
1362 1367
    while ( my ($docid, $data) = each(%entityObjects) ) {
1363 1368
        my $accessStub = qq|<additionalMetadata>
1364 1369
            <describes>$data->{'distribid'}</describes>
1365
                <access authSystem="knb" order="allowFirst">
1370
                <access authSystem="knb" order="denyFirst">
1366 1371
                    $skinAccess
1367 1372
                    $userAccess 
1368 1373
                    <deny>

Also available in: Unified diff