/** Initializes Query name from string. */
  void setQueryName(String newName) {
    if (newName != null && newName.trim().length() == 0) {
      newName = null;
    }

    AbstractQuery query = getQuery();

    if (query == null) {
      return;
    }

    if (Util.nullSafeEquals(newName, query.getName())) {
      return;
    }

    if (newName == null) {
      throw new ValidationException("SelectQuery name is required.");
    }

    DataMap map = mediator.getCurrentDataMap();
    Query matchingQuery = map.getQuery(newName);

    if (matchingQuery == null) {
      // completely new name, set new name for entity
      QueryEvent e = new QueryEvent(this, query, query.getName());
      ProjectUtil.setQueryName(map, query, newName);
      mediator.fireQueryEvent(e);
    } else if (matchingQuery != query) {
      // there is a query with the same name
      throw new ValidationException(
          "There is another query named '" + newName + "'. Use a different name.");
    }
  }
 private void applyChanges() {
   for (DuplicatedAttributeInfo attributeInfo : duplicatedAttributes) {
     if (attributeInfo.getAction().equals(DELETE_ACTION)) {
       entity.removeAttribute(attributeInfo.getName());
     }
     if (attributeInfo.getAction().equals(RENAME_ACTION)) {
       ProjectUtil.setAttributeName(
           entity.getAttribute(attributeInfo.getName()), attributeInfo.getNewName());
     }
   }
 }
  public void setNodeName(String newName) {
    if (node == null) {
      return;
    }

    // validate...
    if (newName == null) {
      throw new ValidationException("Empty DataNode Name");
    }

    ProjectController parent = (ProjectController) getParent();
    DataNodeDefaults oldPref = parent.getDataNodePreferences();
    DataChannelDescriptor dataChannelDescriptor =
        (DataChannelDescriptor) getApplication().getProject().getRootNode();

    Collection<DataNodeDescriptor> matchingNode = dataChannelDescriptor.getNodeDescriptors();

    Iterator<DataNodeDescriptor> it = matchingNode.iterator();
    while (it.hasNext()) {
      DataNodeDescriptor node = it.next();
      if (node.getName().equals(newName)) {
        // there is an entity with the same name
        throw new ValidationException(
            "There is another DataNode named '" + newName + "'. Use a different name.");
      }
    }

    // passed validation, set value...

    // TODO: fixme....there is a slight chance that domain is different than the one
    // cached node belongs to
    ProjectUtil.setDataNodeName(
        (DataChannelDescriptor) parent.getProject().getRootNode(), node, newName);

    oldPref.copyPreferences(newName);
  }