diff Lib/IMPL/Web/View/Metadata/BaseMeta.pm @ 366:935629bf80df

model metadata, in progress
author cin
date Mon, 02 Dec 2013 17:44:38 +0400
parents 82b6c967bcf1
children 608e74bc309f
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/Metadata/BaseMeta.pm	Mon Dec 02 02:13:12 2013 +0400
+++ b/Lib/IMPL/Web/View/Metadata/BaseMeta.pm	Mon Dec 02 17:44:38 2013 +0400
@@ -14,6 +14,7 @@
 	props => [
 		model => PROP_RO,
 		modelType => PROP_RO,
+		holdingType => PROP_RO,
 		provider => PROP_RO,
 		name => PROP_RO,
 		label => PROP_RO,
@@ -39,40 +40,57 @@
 	
 	#mixin other args
 	if ($args) {
-		$this->$_($args->{$_}) foreach grep $args->{$_}, qw(name label container template);
+		$this->$_($args->{$_}) foreach grep $args->{$_}, qw(name label container template holdingType);
 	}
 }
 
-sub GetChild {
+sub GetProperty {
 	my ($this,$name) = @_;
 	
-	if(my $child = $this->_childMap->{$name}) {
-		return $child;
-	} else {
-		return $this->_childMap->{$name} = $this->provider->GetChild($this,$name);
-	}
+	$this->_PopulateProperties()
+		unless $this->_childNames;
+	
+	return $this->_childMap->{$name};
 }
 
-sub GetChildren {
+sub GetProperties {
 	my ($this) = @_;
 	
 	if ($this->_childNames) {
 		return [ map $this->_childMap->{$_}, @{$this->_childNames} ];
 	} else {
-		my @childNames;
-		my %childMap;
-		my @result; 
+		return $this->_PopulateProperties;
+	}	
+}
+
+sub _PopulateProperties {
+	my ($this) = @_;
 	
-		foreach my $child (@{$this->provider->PopulateChildren($this)}) {
-			$childMap{$child->name} = $child;
-			push @childNames, $child->name;
-			push @result, $child;
-		}
-		
-		$this->_childMap(\%childMap);
-		$this->_childNames(\@childNames);
-		return \@result;
-	}	
+	my @childNames;
+	my %childMap;
+	my @result; 
+
+	foreach my $child (@{$this->provider->PopulateProperties($this)}) {
+		$childMap{$child->name} = $child;
+		push @childNames, $child->name;
+		push @result, $child;
+	}
+	
+	$this->_childMap(\%childMap);
+	$this->_childNames(\@childNames);
+	return \@result;
+}
+
+sub GetItems {
+	my ($this) = @_;
+	
+	return $this->provider->GetItems($this);
+}
+
+sub GetItem {
+	my ($this,$index) = @_;
+	
+	return $this->provider->GetItem($this,$index);
 }
 
 1;