Project

General

Profile

« Previous | Next » 

Revision 2994

Added by sgarg over 18 years ago

added function to get list of projects for NCEAS from a given project list

View differences:

src/perl/register-dataset.cgi
3953 3953
    #my $admindb = NCEAS::AdminDB->new();
3954 3954
    #$admindb->connect($nceas_db, $nceas_db_user, $nceas_db_password);
3955 3955
    #my $projects = $admindb->getProjects();
3956
    #my $projects = getTestProjectListFromTextFile();
3956 3957
    my $projects = getTestProjectList();
3957 3958
    return $projects;
3958 3959
}
......
3989 3990
    $projects[6] = \@row7;
3990 3991
    return \@projects;
3991 3992
}
3993

  
3994
################################################################################
3995
# 
3996
# get a list of projects from a text file where the NCEAS
3997
# admin db is not available.
3998
#
3999
################################################################################
4000
sub getTestProjectListFromTextFile {
4001
    my @projects;
4002
    my $listname = "projects.txt";
4003

  
4004
    my $count = 0;
4005
    open(file,$listname) || die ("Couldn't open the file");
4006
    while(<file>) {
4007
        chomp();
4008
        #print $_;
4009

  
4010
        my @row;
4011
        my ($projectid, $pilast, $pifirst, $ptitle, $stitle) = split(':', $_);
4012
        $pilast =~ s/ //g;
4013
        $pifirst =~ s/ //g;
4014
        $ptitle =~ s/((  )|(^ )|( $))//g;
4015
        $stitle =~ s/((  )|(^ )|( $))//g;
4016

  
4017
        $row[0] = $projectid;
4018
        $row[1] = $pilast;
4019
        $row[2] = $pifirst;
4020
        $row[3] = $ptitle;
4021
        $row[4] = $stitle;
4022

  
4023
        $projects[$count++] = \@row;
4024
    }
4025

  
4026
    return \@projects;
4027
}

Also available in: Unified diff