File:  [LON-CAPA] / nsdl / harvestsmete / OAIvocabulary_v2.pm
Revision 1.1: download - view: text, annotated - select for diffs
Thu May 8 16:37:31 2003 UTC (21 years, 6 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 0 (Unknown)
	my $platformType = "0";

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

	if ( $platform =~ /^(.*)HTML Browser(.*)$/ ) {
		$platformType="5";
		$isCrossPlatform=$isCrossPlatform+1;
	}
	if ( $platform =~ /^(.*)Java Virtual Machine(.*)$/ ) {
		$platformType="64";
		$isCrossPlatform=$isCrossPlatform+1;
	}
	if ( $platform =~ /^(.*)PC(.*)$/ ) {
		$platformType="3";
		$isCrossPlatform=$isCrossPlatform+1;
	}
	if ( $platform =~ /^(.*)Sun Sparc(.*)$/ ) {
		$platformType="36";
		$isCrossPlatform=$isCrossPlatform+1;
	}
	if ( $platform =~ /^(.*)SGI(.*)$/ ) {
		$platformType="81";
		$isCrossPlatform=$isCrossPlatform+1;
	}
	if ( $platform =~ /^(.*)HP(.*)$/ ) {
		$platformType="82";
		$isCrossPlatform=$isCrossPlatform+1;
	}

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

	return $platformType;
}

sub OAIv_findLContext () {
	my @gradelevels;
	foreach my $grade (@_) {
		if ( $grade eq "Primary elementary" ) {
			push(@gradelevels,"1","2","3");
		} elsif ( $grade eq "Intermediate elementary" ) {
			push(@gradelevels,"4","5","6");
		} elsif ( $grade eq "Primary Education" ) {
			push(@gradelevels,"1","2","3","4","5","6");
		} elsif ($grade eq "Middle school" ){
			push(@gradelevels,"7","8");
		} elsif ( ($grade eq "Secondary Education") or ($grade eq "High school") ) {
			push(@gradelevels,"9","10","11","12");
		} elsif ($grade eq "Undergraduate lower division")  {
			push(@gradelevels,"13","14");
		} elsif ($grade eq "Undergraduate upper division") {
			push(@gradelevels,"15","16");
		} elsif ( $grade eq "Higher Education" ) {
			push(@gradelevels,"13","14","15","16");
		} elsif ( $grade eq "Graduate or professional" ) {
			push(@gradelevels,"17");
		} else {
		}
	}
	if (@gradelevels) {
		return join(";", @gradelevels);
	} else {
		return();
	}
}

sub OAIv_parseVcard_matti () {
# Sample begin:vcard FN: Richard N: Wellman ADR: ;Salt Lake City, UT 84124;;;;;USA ORG: Westminster College EMAIL; INTERNET: rwellman@westminstercollege.edu end:vcard
	my $firstname;
	my $lastname;
	my $email;
	my $org;
	my @pdi;

	($firstname, $lastname, $org, $email) = (shift(@_) =~ /^begin:vcard\sFN:\s(.*)\sN:\s(.*)\sADR:.*ORG:\s(.*)\sEMAIL;\sINTERNET:\s(.*)\send:vcard$/);

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

}

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>