private void addThinDomainModels( final String domain, final Element modelsNode, final Element root) { IMetadataDomainRepository repo = getMetadataRepository(); Domain domainObject = repo.getDomain(domain); String locale = LocaleHelper.getClosestLocale( LocaleHelper.getLocale().toString(), domainObject.getLocaleCodes()); Element modelNode; for (LogicalModel model : domainObject.getLogicalModels()) { String vis = (String) model.getProperty("visible"); if (vis != null) { String[] visibleContexts = vis.split(","); boolean visibleToContext = false; for (String context : visibleContexts) { if ("adhoc".equals(context.trim())) { visibleToContext = true; break; } } if (!visibleToContext) { continue; } } modelNode = modelsNode.addElement("model"); // $NON-NLS-1$ modelNode.addElement("domain_id").setText(domain); // $NON-NLS-1$ if (model.getId() != null) { modelNode.addElement("model_id").setText(model.getId()); // $NON-NLS-1$ } String modelName = model.getName(locale); if (modelName != null) { modelNode.addElement("model_name").setText(modelName); // $NON-NLS-1$ } if (model.getDescription() != null) { String modelDescription = model.getDescription(locale); if (modelDescription != null) { modelNode.addElement("model_description").setText(modelDescription); // $NON-NLS-1$ } } } return; }
@Override public Domain getDomain(final String id) { final IPentahoSession session = PentahoSessionHolder.getSession(); final CacheKey key = new CacheKey(session.getId(), id); Domain domain = (Domain) cacheManager.getFromRegionCache(CACHE_REGION, key); if (domain != null) { if (logger.isDebugEnabled()) { logger.debug("Found domain in cache: " + key); // $NON-NLS-1$ } return domain; } domain = delegate.getDomain(id); if (domain != null) { SecurityHelper helper = new SecurityHelper(); domain = helper.createSecureDomain(this, domain); // cache domain with the key we used to look it up, not whatever new id it might have now if (logger.isDebugEnabled()) { logger.debug("Caching domain by session: " + key); // $NON-NLS-1$ } cacheManager.putInRegionCache(CACHE_REGION, key, domain); } return domain; }