コード例 #1
0
  /**
   * get a string status indicator for the modelName status label, given the modelName
   *
   * @param modelName the model name to test
   * @return the status of the supplied model name
   */
  private String getModelNameStatus(String sModelName) {
    // Check for null or zero-length
    if (sModelName == null || sModelName.length() == 0) {
      return MODEL_CREATE_ERROR_NO_NAME;
      // Check for valid model name
    }
    String fileNameMessage = ModelUtilities.validateModelName(sModelName, FILE_EXT);
    if (fileNameMessage != null) {
      return MODEL_CREATE_ERROR_INVALID_NAME;
    }
    // Check if already exists
    String sFileName = getFileName(sModelName);
    IPath modelFullPath = null;
    IPath modelRelativePath = null;

    if (newModelParent != null) {
      modelFullPath = newModelParent.getFullPath().append(sFileName);
      modelRelativePath = newModelParent.getProjectRelativePath().append(sFileName);
    }

    if (newModelParent != null && newModelParent.getProject().exists(modelRelativePath)) {
      return MODEL_CREATE_ERROR_ALREADY_EXISTS;
    }

    if (targetFilePath != null && targetFilePath.equals(modelFullPath)) {
      return MODEL_CREATE_ERROR_SAME_NAME_AS;
    }

    // success
    return MODEL_CREATE_ERROR_IS_VALID;
  }
コード例 #2
0
  /**
   * test whether the supplied modelName is valid
   *
   * @param modelName the model name to test
   * @return 'true' if the name is valid, 'false' if not.
   */
  private boolean isValidModelName(String sModelName) {

    // Check for null or zero-length
    if (sModelName == null || sModelName.length() == 0) {
      return false;
    }
    // Check for valid model name
    String fileNameMessage = ModelUtilities.validateModelName(sModelName, FILE_EXT);
    if (fileNameMessage != null) {
      return false;
    }

    // Check if already exists
    String sFileName = getFileName(sModelName);
    IPath modelFullPath = null;
    IPath modelRelativePath = null;
    if (newModelParent != null) {
      modelFullPath = newModelParent.getFullPath().append(sFileName);
      modelRelativePath = newModelParent.getProjectRelativePath().append(sFileName);
    }

    if (newModelParent != null && newModelParent.getProject().exists(modelRelativePath)) {
      return false;
    }

    // Check if it is the same path as the relational model being generated
    if (targetFilePath != null && targetFilePath.equals(modelFullPath)) {
      return false;
    }

    // success
    return true;
  }