Пример #1
0
  private IModelEntity getSelectedEntity() {
    logger.debug("IN");
    IModelEntity entity = null;
    try {
      IDataSource ds = getDataSource();

      // change max recursion level to data source

      Map<String, Object> properties = ds.getConfiguration().loadDataSourceProperties();
      properties.put("maxRecursionLevel", "5");
      // ds.setDataMartModelAccessModality(modelAccessModality);

      IModelStructure structure = ds.getModelStructure();
      QbeEngineInstance engineInstance = getEngineInstance();
      QbeTemplate template = engineInstance.getTemplate();
      if (template.isComposite()) { // composite Qbe is not supported
        logger.error("Template is composite. This is not supported by the Registry engine");
        throw new SpagoBIEngineServiceException(
            getActionName(), "Template is composite. This is not supported by the Registry engine");
      }
      // takes the only datamart's name configured
      String modelName = (String) template.getDatamartNames().get(0);
      RegistryConfiguration registryConfig =
          (RegistryConfiguration) template.getProperty("registryConfiguration");
      String entityName = registryConfig.getEntity();

      int index = entityName.lastIndexOf(".");
      entityName =
          entityName
              + "::"
              + entityName.substring(
                  index + 1); // entity name is something like it.eng.Store::Store
      logger.debug("Looking for entity [" + entityName + "] in model [" + modelName + "] ...");
      entity = structure.getRootEntity(modelName, entityName);
      logger.debug("Entity [" + entityName + "] was found");
      if (entity == null) {
        logger.error("Entity [" + entityName + "] not found!");
        throw new SpagoBIEngineServiceException(
            getActionName(), "Entity [" + entityName + "] not found!");
      }
    } finally {
      logger.debug("OUT");
    }
    return entity;
  }