Beispiel #1
0
  /**
   * This method will create queryResultObjectDataBean for a node passed to it.
   *
   * @param node node for which QueryResultObjectDataBean is to be created.
   * @param queryDetailsObj QueryDetails object.
   * @return queryResultObjectDataBean.
   */
  public static QueryResultObjectDataBean getQueryResulObjectDataBean(
      OutputTreeDataNode node, QueryDetails queryDetailsObj) {
    QueryResultObjectDataBean queryResultObjectDataBean = new QueryResultObjectDataBean();
    if (node != null) {
      EntityInterface deEntity = node.getOutputEntity().getDynamicExtensionsEntity();
      String entityName;
      Map<String, String> tagKeyValueMap = getTaggedValueMap(deEntity);
      queryResultObjectDataBean.setPrivilegeType(
          Utility.getInstance().getPrivilegeType(tagKeyValueMap));
      queryResultObjectDataBean.setEntity(deEntity);

      List<EntityInterface> mainEntityList = getMainEntityListFromMap(queryDetailsObj, deEntity);
      if (mainEntityList == null) {
        entityName = deEntity.getName();
      } else {
        EntityInterface mainEntity = getMainEntity(mainEntityList, node);
        if (mainEntity == null) {
          mainEntity = mainEntityList.get(0);
        }
        queryResultObjectDataBean.setMainEntity(mainEntity);
        entityName = mainEntity.getName();
      }
      queryResultObjectDataBean.setCsmEntityName(entityName);
      setEntityName(queryResultObjectDataBean);
      boolean readDeniedObject = isReadDeniedObject(queryResultObjectDataBean.getCsmEntityName());
      queryResultObjectDataBean.setReadDeniedObject(readDeniedObject);
    }
    return queryResultObjectDataBean;
  }
Beispiel #2
0
 /**
  * To check whether the given Entity in OutputTreeDataNode is mainEntity or not.
  *
  * @param mainEntityList the list of main entities.
  * @param node the OutputTreeDataNode
  * @return The reference to entity in the OutputTreeDataNode, if its present in the
  *     mainEntityList.
  */
 private static EntityInterface isMainEntity(
     List<EntityInterface> mainEntityList, OutputTreeDataNode node) {
   EntityInterface dynamicExtensionsEntity = node.getOutputEntity().getDynamicExtensionsEntity();
   if (!mainEntityList.contains(dynamicExtensionsEntity)) {
     dynamicExtensionsEntity = null;
   }
   return dynamicExtensionsEntity;
 }
Beispiel #3
0
 /**
  * This method will return node corresponding to an entity from query.
  *
  * @param entity entity
  * @param queryDetailsObj queryDetailsObj
  * @return outputTreeDataNode outputTreeDataNode
  */
 private static OutputTreeDataNode getMatchingEntityNode(
     EntityInterface entity, QueryDetails queryDetailsObj) {
   OutputTreeDataNode outputTreeDataNode = null;
   Iterator<OutputTreeDataNode> iterator =
       queryDetailsObj.getUniqueIdNodesMap().values().iterator();
   while (iterator.hasNext()) {
     OutputTreeDataNode outputNode = iterator.next();
     if (outputNode.getOutputEntity().getDynamicExtensionsEntity().equals(entity)) {
       outputTreeDataNode = outputNode;
       break;
     }
   }
   return outputTreeDataNode;
 }
Beispiel #4
0
  /**
   * To add the Id columns of MainEntities in the SQL if its not present. It will also populate
   * entityIdIndexMap passes it.
   *
   * @param columnIndex columnIndex
   * @param selectSql selectSql
   * @param entityIdIndexMap entityIdIndexMap
   * @param selectSqlColumnList selectSqlColumnList
   * @param outputTreeDataNode outputTreeDataNode
   * @return The modified SQL string.
   */
  private static Map putIdColumnsInSql(
      int colIndex,
      String selectSql,
      Map<EntityInterface, Integer> entityIdIndexMap,
      List<String> selectSqlColumnList,
      OutputTreeDataNode outputTreeDataNode,
      Map<String, String> specimenMap,
      Map<String, String> columnNameVsAliasMap) {
    int columnIndex = colIndex;
    StringBuffer sql = new StringBuffer(selectSql);
    Map sqlIndexMap = new HashMap();
    if (outputTreeDataNode != null) {
      List<QueryOutputTreeAttributeMetadata> attributes = outputTreeDataNode.getAttributes();
      for (QueryOutputTreeAttributeMetadata attributeMetaData : attributes) {
        AttributeInterface attribute = attributeMetaData.getAttribute();
        String sqlColumnName = attributeMetaData.getColumnName().trim();
        if (attribute.getName().equals(AQConstants.IDENTIFIER)) {
          int index =
              selectSqlColumnList.indexOf(
                  columnNameVsAliasMap.get(sqlColumnName) + " " + sqlColumnName);

          if (index >= 0) {
            entityIdIndexMap.put(attribute.getEntity(), index);
            break;
          } else {
            // appendColNameToSql(selectSql, sql, sqlColumnName);
            entityIdIndexMap.put(attribute.getEntity(), null);
            columnIndex++;
            if (outputTreeDataNode
                .getOutputEntity()
                .getDynamicExtensionsEntity()
                .getName()
                .equals("edu.wustl.catissuecore.domain.Specimen")) {
              if (specimenMap == null) {
                specimenMap = new HashMap<String, String>();
              }
              specimenMap.put("specimenKey", "edu.wustl.catissuecore.domain.Specimen");
              specimenMap.put("columnIndex", String.valueOf(columnIndex - 1));
            }
            break;
          }
        }
      }
    }
    sqlIndexMap.put(AQConstants.SQL, sql.toString());
    sqlIndexMap.put(AQConstants.ID_COLUMN_ID, columnIndex);
    return sqlIndexMap;
  }
Beispiel #5
0
 /**
  * This method will return map of a entity as value and list of all the main entities of this
  * particular entity as value.
  *
  * @param queryDetailsObj QueryDetails object
  * @return mainEntityMap Map of all main entities present in query.
  */
 public static Map<EntityInterface, List<EntityInterface>> getMainEntitiesForAllQueryNodes(
     QueryDetails queryDetailsObj) {
   Map<EntityInterface, List<EntityInterface>> mainEntityMap =
       new HashMap<EntityInterface, List<EntityInterface>>();
   for (OutputTreeDataNode queryNode : queryDetailsObj.getUniqueIdNodesMap().values()) {
     List<EntityInterface> mainEntityList = new ArrayList<EntityInterface>();
     EntityInterface deEntity = queryNode.getOutputEntity().getDynamicExtensionsEntity();
     mainEntityList = getAllMainEntities(deEntity, mainEntityList);
     populateMainEntitiesForANode(mainEntityList, deEntity);
     if (mainEntityList.size() != 1) {
       mainEntityList = populateMainEntityList(mainEntityList, deEntity);
     }
     populateMap(mainEntityMap, mainEntityList, deEntity);
   }
   return mainEntityMap;
 }
Beispiel #6
0
 /**
  * This method will prepare the query clone and return it.
  *
  * @param queryDetailsObj contains group of fields in this Object
  * @param session HttpSession object
  * @return query clone.
  */
 private static IQuery getQueryClone(QueryDetails queryDetailsObj, HttpSession session) {
   IQuery queryClone = null;
   try {
     boolean isMainObjAdded = false;
     IPathFinder pathFinder = new CommonPathFinder();
     DAGPanel dagPanel = new DAGPanel(pathFinder);
     // iterate through the uniqueIdNodesMap and check if main entities of all the nodes are
     // present
     for (Object element : queryDetailsObj.getUniqueIdNodesMap().entrySet()) {
       Map.Entry<String, OutputTreeDataNode> idmapValue =
           (Map.Entry<String, OutputTreeDataNode>) element;
       OutputTreeDataNode node = idmapValue.getValue(); // get the node
       // get the entity
       EntityInterface mapEntity = node.getOutputEntity().getDynamicExtensionsEntity();
       // get the main entities list for the entity
       List<EntityInterface> finalMnEntityLst = queryDetailsObj.getMainEntityMap().get(mapEntity);
       List<EntityInterface> mainEntityList = new ArrayList<EntityInterface>();
       FlexInterface flexInterface = new FlexInterface();
       flexInterface.initFlexInterface();
       mainEntityList = setMainEntityList(finalMnEntityLst, mainEntityList);
       if (mainEntityList == null) // mainEntityList is null if the entity itself is main entity;
       {
         if (!isMainObjAdded) {
           isMainObjAdded = true;
         }
       } else {
         queryClone =
             addMainEntityToQuery(queryDetailsObj, dagPanel, node, mainEntityList, session);
       }
     }
     queryClone = modifyQuery(queryDetailsObj, queryClone, isMainObjAdded, dagPanel);
   } catch (MultipleRootsException e) {
     logger.error(e.getMessage(), e);
   }
   return queryClone;
 }