예제 #1
0
  /**
   * Gets the dimension with the specified name within this cube.
   *
   * @param dimensionName name of the dimension to find
   * @return dimension within the cube if found, otherwise <code>null</code>
   */
  public DimensionHandle getDimension(String dimensionName) {
    if (StringUtil.isBlank(dimensionName)) return null;
    if (!getElement().canDynamicExtends()) {
      Dimension dimension = module.findDimension(dimensionName);
      if (dimension == null) return null;
      if (dimension.isContentOf(getElement())) return (DimensionHandle) dimension.getHandle(module);
      else {
        // check the client to find the children of the cube
        List<BackRef> clients = dimension.getClientList();
        if (clients != null) {
          for (BackRef ref : clients) {
            DesignElement client = ref.getElement();
            if (client.isContentOf(getElement())) return (DimensionHandle) client.getHandle(module);
          }
        }
      }
    } else if (getElement().getDynamicExtendsElement(getModule()) != null) {
      Cube cube = (Cube) getElement();
      DesignElement element =
          cube.findLocalElement(
              dimensionName,
              MetaDataDictionary.getInstance().getElement(ReportDesignConstants.DIMENSION_ELEMENT));
      return (DimensionHandle) (element == null ? null : element.getHandle(module));
    }

    return null;
  }
예제 #2
0
  public void checkDimension() throws SemanticException {
    if (element instanceof TabularDimension) {
      Dimension sharedDimension =
          TabularDimensionPropSearchStrategy.getSharedDimension(module, element);
      if (sharedDimension != null) {
        String name = (String) element.getName();
        String sharedName = sharedDimension.getName();

        if (!sharedName.equals(name)) {
          NameExecutor nameExecutor = new NameExecutor(module, element);
          INameHelper nameHelper = nameExecutor.getNameHelper();
          NameSpace namespace = nameExecutor.getNameSpace();
          String namespaceId = nameExecutor.getNameSpaceId();
          DesignElement existedElement = namespace.getElement(name);
          if (existedElement == null) {
            // the name is not put in name space, then simply rename
            // it to the name of the shared element
            setName(sharedName);
          } else {
            if (existedElement == element) {
              // remove it from the name space and then rename it
              getActivityStack()
                  .execute(new NameSpaceRecord(nameHelper, namespaceId, element, false));
              setName(sharedName);
            } else {
              // do nothing and simply rename it to the name of
              // the shared element
              setName(sharedName);
            }
          }
        }
      }
    }
  }
예제 #3
0
 private void updateDimensions(ActivityStack stack) {
   Dimension dimension = (Dimension) element;
   List<BackRef> clients = dimension.getClientList();
   for (BackRef client : clients) {
     DesignElement content = client.getElement();
     String propName = client.getPropertyName();
     if (content instanceof Dimension
         && ITabularDimensionModel.INTERNAL_DIMENSION_RFF_TYPE_PROP.equals(propName)) {
       NameRecord rename = new NameRecord(content, element.getName());
       stack.execute(rename);
     }
   }
 }
예제 #4
0
  /**
   * Sets the element name.
   *
   * @param name the new name.
   * @throws NameException if the element name is not allowed to change.
   */
  public void setName(String name) throws NameException {
    name = StringUtil.trimString(name);

    // Ignore change to the current name.

    String oldName = element.getName();
    if ((name == null && oldName == null)
        || (name != null && oldName != null && name.equals(oldName))) return;

    // ignore change to the dimension that refers a shared dimension
    Dimension sharedDimension =
        TabularDimensionPropSearchStrategy.getSharedDimension(module, element);
    if (sharedDimension != null && !sharedDimension.getName().equals(name)) return;

    checkName(name);

    DesignElement tmpElement = element;
    // if a contentElement is not local, need to make a local copy before changing the name
    if (tmpElement instanceof ContentElement && !((ContentElement) tmpElement).isLocal()) {
      eventTarget = ((ContentElement) tmpElement).getValueContainer();
      tmpElement = copyTopCompositeValue();
    }

    // Record the change.

    ActivityStack stack = getActivityStack();
    NameRecord rename = new NameRecord(tmpElement, name);
    stack.startTrans(rename.getLabel());

    // Drop the old name from the name space.

    // Change the name.
    stack.execute(rename);

    // Add the new name to the name space.
    renameSymbolFrom(oldName);

    // change the name of the dimension that shares this element
    if (element instanceof Dimension) {
      updateDimensions(stack);
    }

    stack.commit();
  }