private static String getParameterValue(
     TargetParameter parameter, WhatIfEngineInstance ei, SpagoBICellWrapper cell) {
   if (parameter.isAbsolute()) {
     return parameter.getValue();
   }
   String value = null;
   String dimensionName = parameter.getDimension();
   String hierarchyName = parameter.getHierarchy();
   String levelName = parameter.getLevel();
   String propertyName = parameter.getProperty();
   logger.debug(
       "Looking for dimension "
           + dimensionName
           + ", hierarchy "
           + hierarchyName
           + ", level "
           + levelName
           + ", property "
           + propertyName
           + " ...");
   Hierarchy hierarchy =
       getHierarchy(ei.getSpagoBIPivotModel().getCube(), ei.getModelConfig(), dimensionName);
   Member member = cell.getContextMember(hierarchy);
   logger.debug("Considering context member " + member.getUniqueName());
   logger.debug("Member hierarchy is " + hierarchy.getUniqueName());
   if (hierarchy.getUniqueName().equals(hierarchyName)) {
     if (propertyName == null || propertyName.trim().equals("")) {
       value = getLevelValue(member, levelName);
     } else {
       value = getMemberPropertyValue(member, propertyName);
     }
   }
   return value;
 }
示例#2
0
  public void testWithQuery() throws Exception {
    WhatIfEngineInstance ei = getWhatifengineiEngineInstance(getCatalogue());
    SpagoBIPivotModel pivotModel = (SpagoBIPivotModel) ei.getPivotModel();

    SpagoBICellSetWrapper cellSetWrapper = (SpagoBICellSetWrapper) pivotModel.getCellSet();
    SpagoBICellWrapper cellWrapper = (SpagoBICellWrapper) cellSetWrapper.getCell(0);

    cellWrapper.getMembers()[1].setProperty(WhatIfConstants.MEMBER_PROPERTY_LEAF, null);

    EqualPartitioningOnLeafsAllocationAlgorithm ae =
        new EqualPartitioningOnLeafsAllocationAlgorithm(ei);

    Long leafs = ae.getDataManager().getLeafs(cellWrapper.getMembers());

    System.out.println(leafs);
  }
  public static String buildCrossNavigationUrl(
      int targetIndex, SpagoBICellWrapper cellWrapper, WhatIfEngineInstance ei) throws Exception {
    logger.debug("IN");
    SpagoBIPivotModel modelWrapper = ei.getSpagoBIPivotModel();
    Target target = modelWrapper.getCrossNavigation().getTargets().get(targetIndex);
    List<TargetParameter> parameters = target.getParameters();
    StringBuffer buffer =
        new StringBuffer(
            "parent.execCrossNavigation(window.name, '"
                + StringEscapeUtils.escapeJavaScript(target.documentLabel)
                + "', '");
    if (!parameters.isEmpty()) {
      for (int i = 0; i < parameters.size(); i++) {
        TargetParameter aParameter = parameters.get(i);
        String parameterName = aParameter.name;
        String parameterValue = getParameterValue(aParameter, ei, cellWrapper);
        if (parameterValue != null) {
          buffer.append(
              StringEscapeUtils.escapeJavaScript(parameterName + "=" + parameterValue + "&"));
        }
      }
    }

    if (buffer.charAt(buffer.length() - 1) == '&') {
      buffer.deleteCharAt(buffer.length() - 1);
    }
    if (target.customizedView != null) {
      buffer.append("', '" + StringEscapeUtils.escapeJavaScript(target.customizedView) + "'");
    } else {
      buffer.append("', ''");
    }

    if (target.titleCross != null
        && target.targetCross != null
        && target.targetCross.equalsIgnoreCase("tab")) {
      buffer.append(",'" + target.titleCross + "','tab'");
    } else if (target.titleCross != null) {
      buffer.append(",'" + target.titleCross + "'");
    }

    buffer.append(");");
    String toReturn = buffer.toString();
    logger.debug("OUT: returning [" + toReturn + "]");
    return toReturn;
  }