isNotEmpty = 0 != quantities.get(entry.getAsset()).getQuantity().doubleValue();
if ( entry.isActive() && isin != null && ! "".equals(isin.trim()) && ! UNNECESSARY.equals(isin.trim()) && isNotEmpty)
{
try
{
SecuritiesCurrentMarketPrice currentPrice = currentPricesMap.get(entry.getIsin());
boolean upToDate = false;
if (currentPrice == null)
{
currentPrice = new SecuritiesCurrentMarketPrice();
currentPrice.setIsin(isin);
currentPrice.setAssetname(entry.getAsset());
}
else
{
if (currentPrice.getPrice() != null)
if (System.currentTimeMillis() - currentPrice.getValueDate().getTime().getTime() < DateBoostUtils.daysInMilliseconds(5))
{//5 days are up to date
upToDate = true;
}
}
SecuritiesMarketPrice price = new SecuritiesMarketPrice();
price.setIsin(isin);
if (doCancelUpdateSecuritiesInformation)
break;
boolean result = false;
int i = 0;
if (upToDate && entry.getAssetname() != null)
getLog().debug("up to date: " + entry.getAsset() + " (" + isin+ ")");
else
{
while (i < managers.length)
{
try
{
result = managers[i].updateInformation(entry, price, currentPrice, exchangeRateManager, userMessageManager);
}
catch (Exception ex)
{
ex.printStackTrace();
}
if (result)
i = managers.length;
else
i++;
}
if (result)
{
Session session = getSessionFactory().getCurrentSession();
getLog().debug("begin transaction");
session.beginTransaction();
session.saveOrUpdate(entry);
if (price.getPrice() != null)
{
getLog().debug("saving price: ", price.getId()," ", price.getIsin()," ", price.getPrice()," ", price.getCurrency()," ", price.getValueDate().getTime());
session.save(price);
getLog().debug("saved price ");
if (currentPrice.getPrice() != null)
{
getLog().debug("saving current price ", currentPrice.getId()," ", currentPrice.getIsin()," ", currentPrice.getPrice()," ", currentPrice.getCurrency()," ", currentPrice.getValueDate().getTime());
session.saveOrUpdate(currentPrice);
}
}
getLog().debug("commit transaction");