/**
   * @see
   *     org.teiid.designer.core.validation.ObjectValidationRule#validate(org.eclipse.emf.ecore.EObject,
   *     org.teiid.designer.core.validation.ValidationContext)
   * @since 4.2
   */
  @Override
  public void validate(final EObject eObject, final ValidationContext context) {
    CoreArgCheck.isNotNull(context);
    CoreArgCheck.isNotNull(eObject);

    // get uniqueness preference status
    final int status =
        context.getPreferenceStatus(ValidationPreferences.EOBJECT_UUID_UNIQUENESS, IStatus.ERROR);
    if (status == IStatus.OK) {
      return;
    }

    // if the eObject is a model annotation then
    // is already being validation by ModelAnnoattionUuidRule
    if (eObject instanceof ModelAnnotation) {
      return;
    }

    final ModelEditor editor = ModelerCore.getModelEditor();
    final String uuidString = ModelerCore.getObjectIdString(eObject);
    if (uuidString == null) {
      final String pathInModel = editor.getModelRelativePathIncludingModel(eObject).toString();
      final ValidationResult result = new ValidationResultImpl(eObject);
      // create validation problem and add it to the result
      final ValidationProblem problem =
          new ValidationProblemImpl(
              0,
              IStatus.ERROR,
              ModelerCore.Util.getString("EObjectUuidRule.0", pathInModel)); // $NON-NLS-1$
      problem.setHasPreference(context.hasPreferences());
      result.addProblem(problem);
      context.addResult(result);
    } else {
      boolean isDuplicate = context.containsUuid(uuidString);
      if (isDuplicate) {
        final String pathInModel = editor.getModelRelativePathIncludingModel(eObject).toString();
        final ValidationResult result = new ValidationResultImpl(eObject);
        String modelName = editor.getModelName(eObject);
        // create validation problem and addit to the result
        final ValidationProblem problem =
            new ValidationProblemImpl(
                0,
                status,
                ModelerCore.Util.getString(
                    "EObjectUuidRule.1", pathInModel, uuidString, modelName)); // $NON-NLS-1$
        problem.setHasPreference(context.hasPreferences());
        result.addProblem(problem);
        context.addResult(result);
      } else {
        context.addUuidToContext(uuidString);
      }
    }
  }
  /**
   * @see
   *     org.teiid.designer.core.validation.ObjectValidationRule#validate(org.eclipse.emf.ecore.EObject,
   *     org.teiid.designer.core.validation.ValidationContext)
   * @since 4.2
   */
  @Override
  public void validate(final EObject eObject, final ValidationContext context) {
    CoreArgCheck.isNotNull(context);
    CoreArgCheck.isInstanceOf(ModelAnnotation.class, eObject);

    final ModelEditor editor = ModelerCore.getModelEditor();
    String uuidString = ModelerCore.getObjectIdString(eObject);
    if (uuidString == null) {
      final String pathInModel = editor.getModelRelativePathIncludingModel(eObject).toString();
      final ValidationResult result = new ValidationResultImpl(eObject);
      // create validation problem and add it to the result
      final ValidationProblem problem =
          new ValidationProblemImpl(
              0,
              IStatus.ERROR,
              ModelerCore.Util.getString("ModelAnnotationUuidRule.0", pathInModel)); // $NON-NLS-1$
      result.addProblem(problem);
      context.addResult(result);
    } else {
      boolean isDuplicate = context.containsUuid(uuidString);
      if (isDuplicate) {
        final String pathInModel = editor.getModelRelativePathIncludingModel(eObject).toString();
        final ValidationResult result = new ValidationResultImpl(eObject);
        String modelName = editor.getModelName(eObject);
        // create validation problem and addit to the result
        final ValidationProblem problem =
            new ValidationProblemImpl(
                0,
                IStatus.ERROR,
                ModelerCore.Util.getString(
                    "ModelAnnotationUuidRule.1",
                    pathInModel,
                    uuidString,
                    modelName)); //$NON-NLS-1$
        result.addProblem(problem);
        context.addResult(result);
      } else {
        context.addUuidToContext(uuidString);
      }
    }
  }