File:  [LON-CAPA] / nsdl / harvestsmete / OAIvocabulary.pm
Revision 1.1: download - view: text, annotated - select for diffs
Thu May 8 16:37:31 2003 UTC (21 years, 7 months ago) by www
Branches: MAIN
CVS tags: HEAD
SMETE side harvest code for LON-CAPA

#!/usr/local/bin/perl -w

use strict;

sub OAIv_findPlatform {
	my $platform = shift @_;
	chomp $platform;

	# Default Platform Type is 6-Other
	my $platformType = "6-Other";

	# If multiple platforms match, it's cross platform
	my $isCrossPlatform;
	$isCrossPlatform=0;

	if ( $platform =~ /^(.*)HTML Browser(.*)$/ ) {
		$platformType="5-WWW";
		$isCrossPlatform=$isCrossPlatform+1;
	}
	if ( $platform =~ /^(.*)Java Virtual Machine(.*)$/ ) {
		$platformType="8-Java";
		$isCrossPlatform=$isCrossPlatform+1;
	}
	if ( $platform =~ /^(.*)PC(.*)$/ ) {
		$platformType="3-PC";
		$isCrossPlatform=$isCrossPlatform+1;
	}
	if ( $platform =~ /^(.*)Sun Sparc(.*)$/ ) {
		$platformType="7-UNIX";
		$isCrossPlatform=$isCrossPlatform+1;
	}
	if ( $platform =~ /^(.*)SGI(.*)$/ ) {
		$platformType="7-UNIX";
		$isCrossPlatform=$isCrossPlatform+1;
	}
	if ( $platform =~ /^(.*)HP(.*)$/ ) {
		$platformType="7-UNIX";
		$isCrossPlatform=$isCrossPlatform+1;
	}

	if ( $isCrossPlatform >= 2 ) {
		$platformType="1-Cross-Platform";
	}

	return $platformType;
}

sub OAIv_findLContext () {
	my @gradelevels;
	foreach my $grade (@_) {
		if ( $grade eq "Higher Education" ) {
			push(@gradelevels,"13","14","15","16");
		} elsif ( $grade eq "Secondary Education" ) {
			push(@gradelevels,"9","10","11","12");
		} else {
		}
	}
	return join(";", @gradelevels);
}

sub OAIv_parseVcard () {
# Sample
#BEGIN:vCard
#FN:Steve Hayes           
#N:Hayes;Steve      
#EMAIL;INTERNET:shayes@vt.edu  
#ORG:Virginia Tech;Computer Science
#END:vCard
	my $firstname;
	my $lastname;
	my $email;
	my $org;
	my @pdi;

	my @vcard = split /\n/, shift(@_);
	foreach my $element (@vcard) {
		chomp $element;
		my ($property,$value) = split /:/, $element;
		next if ! defined $property;
		if ( $property eq "FN" ) {
			($firstname,$lastname) = split / /, $value;
		} elsif ( $property eq "EMAIL;INTERNET" ) {
			$email = $value;
		} elsif ( $property eq "ORG" ) {
			$org = $value;
		}
	}

	push(@pdi,$lastname, $firstname, $email, $org);
	return @pdi;
}

return 1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>