Update StockData for Moose.
This commit is contained in:
parent
d41affa4cc
commit
6e4e666a0d
1 changed files with 49 additions and 48 deletions
|
|
@ -16,7 +16,48 @@ use WebGUI::Utility;
|
||||||
use WebGUI::Asset::Wobject;
|
use WebGUI::Asset::Wobject;
|
||||||
use Finance::Quote;
|
use Finance::Quote;
|
||||||
|
|
||||||
our @ISA = qw(WebGUI::Asset::Wobject);
|
use WebGUI::Definition::Asset;
|
||||||
|
extends 'WebGUI::Asset::Wobject';
|
||||||
|
aspect tableName => 'StockData';
|
||||||
|
aspect icon => 'stockData.gif';
|
||||||
|
aspect assetName => ["assetName", 'Asset_StockData'];
|
||||||
|
property templateId => (
|
||||||
|
fieldType => "template",
|
||||||
|
default => 'StockDataTMPL000000001',
|
||||||
|
tab => 'display',
|
||||||
|
namespace => 'StockData',
|
||||||
|
label => ["template_label", 'Asset_StockData'],
|
||||||
|
hoverHelp => ["template_label_description", 'Asset_StockData'],
|
||||||
|
);
|
||||||
|
property displayTemplateId => (
|
||||||
|
fieldType => "template",
|
||||||
|
default => 'StockDataTMPL000000002',
|
||||||
|
tab => 'display',
|
||||||
|
namespace => "StockData/Display",
|
||||||
|
label => ["display_template_label", 'Asset_StockData'],
|
||||||
|
hoverHelp => ["display_template_label_description", 'Asset_StockData'],
|
||||||
|
);
|
||||||
|
property defaultStocks => (
|
||||||
|
fieldType => "textarea",
|
||||||
|
default => "DELL\nMSFT\nORCL\nSUNW\nYHOO",
|
||||||
|
tab => 'properties',
|
||||||
|
label => ["default_stock_label", 'Asset_StockData'],
|
||||||
|
hoverHelp => ["default_stock_label_description", 'Asset_StockData'],
|
||||||
|
);
|
||||||
|
property source => (
|
||||||
|
fieldType => "selectList",
|
||||||
|
default => "usa",
|
||||||
|
tab => 'properties',
|
||||||
|
options => &_getStockSources,
|
||||||
|
label => ["stock_source", 'Asset_StockData'],
|
||||||
|
hoverHelp => ["stock_source_description", 'Asset_StockData'],
|
||||||
|
);
|
||||||
|
property failover => (
|
||||||
|
fieldType => "yesNo",
|
||||||
|
default => undef,
|
||||||
|
label => ["failover_label", 'Asset_StockData'],
|
||||||
|
hoverHelp => ["failover_description", 'Asset_StockData'],
|
||||||
|
);
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -189,7 +230,7 @@ sub _getStocks {
|
||||||
# Create a new Finance::Quote object
|
# Create a new Finance::Quote object
|
||||||
my $q = Finance::Quote->new;
|
my $q = Finance::Quote->new;
|
||||||
# Disable failover if specified
|
# Disable failover if specified
|
||||||
unless ($self->getValue("failover")) {
|
unless ($self->failover) {
|
||||||
$q->failover(0);
|
$q->failover(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,7 +238,7 @@ sub _getStocks {
|
||||||
$q->timeout(15);
|
$q->timeout(15);
|
||||||
|
|
||||||
# Fetch the stock information and return the results
|
# Fetch the stock information and return the results
|
||||||
return $q->fetch($self->getValue("source"),@{$stocks});
|
return $q->fetch($self->source,@{$stocks});
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -261,50 +302,10 @@ sub definition {
|
||||||
my %properties;
|
my %properties;
|
||||||
tie %properties, 'Tie::IxHash';
|
tie %properties, 'Tie::IxHash';
|
||||||
%properties = (
|
%properties = (
|
||||||
templateId =>{
|
|
||||||
fieldType=>"template",
|
|
||||||
defaultValue=>'StockDataTMPL000000001',
|
|
||||||
tab=>'display',
|
|
||||||
namespace=>'StockData',
|
|
||||||
label=>$i18n->get("template_label"),
|
|
||||||
hoverHelp=>$i18n->get("template_label_description"),
|
|
||||||
},
|
|
||||||
displayTemplateId=>{
|
|
||||||
fieldType=>"template",
|
|
||||||
defaultValue=>'StockDataTMPL000000002',
|
|
||||||
tab=>'display',
|
|
||||||
namespace=>"StockData/Display",
|
|
||||||
label=>$i18n->get("display_template_label"),
|
|
||||||
hoverHelp=>$i18n->get("display_template_label_description"),
|
|
||||||
},
|
|
||||||
defaultStocks=>{
|
|
||||||
fieldType=>"textarea",
|
|
||||||
defaultValue=>"DELL\nMSFT\nORCL\nSUNW\nYHOO",
|
|
||||||
tab=>'properties',
|
|
||||||
label=> $i18n->get("default_stock_label"),
|
|
||||||
hoverHelp=> $i18n->get("default_stock_label_description"),
|
|
||||||
},
|
|
||||||
source=>{
|
|
||||||
fieldType=>"selectList",
|
|
||||||
defaultValue=>"usa",
|
|
||||||
tab=>'properties',
|
|
||||||
label=> $i18n->get("stock_source"),
|
|
||||||
options=>$class->_getStockSources(),
|
|
||||||
hoverHelp=>$i18n->get("stock_source_description"),
|
|
||||||
},
|
|
||||||
failover=>{
|
|
||||||
fieldType=>"yesNo",
|
|
||||||
defaultValue=>undef,
|
|
||||||
label=> $i18n->get("failover_label"),
|
|
||||||
hoverHelp=> $i18n->get("failover_description")
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
push(@{$definition}, {
|
push(@{$definition}, {
|
||||||
tableName=>'StockData',
|
|
||||||
className=>'WebGUI::Asset::Wobject::StockData',
|
|
||||||
icon=>'stockData.gif',
|
|
||||||
assetName=>$i18n->get("assetName"),
|
|
||||||
autoGenerateForms=>1,
|
autoGenerateForms=>1,
|
||||||
properties=>\%properties
|
properties=>\%properties
|
||||||
});
|
});
|
||||||
|
|
@ -323,11 +324,11 @@ See WebGUI::Asset::prepareView() for details.
|
||||||
sub prepareView {
|
sub prepareView {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->SUPER::prepareView();
|
$self->SUPER::prepareView();
|
||||||
my $template = WebGUI::Asset::Template->new($self->session, $self->get("templateId"));
|
my $template = WebGUI::Asset::Template->new($self->session, $self->templateId);
|
||||||
if (!$template) {
|
if (!$template) {
|
||||||
WebGUI::Error::ObjectNotFound::Template->throw(
|
WebGUI::Error::ObjectNotFound::Template->throw(
|
||||||
error => qq{Template not found},
|
error => qq{Template not found},
|
||||||
templateId => $self->get("templateId"),
|
templateId => $self->templateId,
|
||||||
assetId => $self->getId,
|
assetId => $self->getId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -369,7 +370,7 @@ sub view {
|
||||||
$var->{'stock.display.url'} = $self->getUrl("func=displayStock;symbol=");
|
$var->{'stock.display.url'} = $self->getUrl("func=displayStock;symbol=");
|
||||||
|
|
||||||
#Build list of stocks as an array
|
#Build list of stocks as an array
|
||||||
my $defaults = $self->getValue("defaultStocks");
|
my $defaults = $self->defaultStocks;
|
||||||
#replace any windows newlines
|
#replace any windows newlines
|
||||||
$defaults =~ s/\r//;
|
$defaults =~ s/\r//;
|
||||||
my @array = split("\n",$defaults);
|
my @array = split("\n",$defaults);
|
||||||
|
|
@ -436,7 +437,7 @@ sub www_displayStock {
|
||||||
('(not available)') x 2;
|
('(not available)') x 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self->processTemplate($var, $self->get("displayTemplateId"));
|
return $self->processTemplate($var, $self->displayTemplateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue