core/src/main/java/com/orientechnologies/orient/core/sql/OCommandExecutorSQLTruncateClass.java
public Object execute(final Map<Object, Object> iArgs) {
    if (schemaClass == null)
      throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");

    final long recs = schemaClass.count(deep);
    if (recs > 0 && !unsafe) {
      if (schemaClass.isSubClassOf("V")) {
        throw new OCommandExecutionException(
            "'TRUNCATE CLASS' command cannot be used on not empty vertex classes. Apply the 'UNSAFE' keyword to force it (at your own risk)");
      } else if (schemaClass.isSubClassOf("E")) {
        throw new OCommandExecutionException(
            "'TRUNCATE CLASS' command cannot be used on not empty edge classes. Apply the 'UNSAFE' keyword to force it (at your own risk)");
      }
    }

    Collection<OClass> subclasses = schemaClass.getAllSubclasses();
    if (deep && !unsafe) {// for multiple inheritance
      for (OClass subclass : subclasses) {
        long subclassRecs = schemaClass.count();
        if (subclassRecs > 0) {
          if (subclass.isSubClassOf("V")) {
            throw new OCommandExecutionException(
                "'TRUNCATE CLASS' command cannot be used on not empty vertex classes (" + subclass.getName()
                    + "). Apply the 'UNSAFE' keyword to force it (at your own risk)");
          } else if (subclass.isSubClassOf("E")) {
            throw new OCommandExecutionException(
                "'TRUNCATE CLASS' command cannot be used on not empty edge classes (" + subclass.getName()
                    + "). Apply the 'UNSAFE' keyword to force it (at your own risk)");
          }
        }
      }
    }

    try {
      schemaClass.truncate();
      invalidateCommandCache(schemaClass);
      if (deep) {
        for (OClass subclass : subclasses) {
          subclass.truncate();
          invalidateCommandCache(subclass);
        }
      }
    } catch (IOException e) {
      throw OException.wrapException(new OCommandExecutionException("Error on executing command"), e);
    }

    return recs;
  }
public Object execute(final Map<Object, Object> iArgs) {
    if (schemaClass == null)
      throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");

    final long recs = schemaClass.count(deep);
    if (recs > 0 && !unsafe) {
      if (schemaClass.isSubClassOf("V")) {
        throw new OCommandExecutionException(
            "'TRUNCATE CLASS' command cannot be used on not empty vertex classes. Apply the 'UNSAFE' keyword to force it (at your own risk)");
      } else if (schemaClass.isSubClassOf("E")) {
        throw new OCommandExecutionException(
            "'TRUNCATE CLASS' command cannot be used on not empty edge classes. Apply the 'UNSAFE' keyword to force it (at your own risk)");
      }
    }

    Collection<OClass> subclasses = schemaClass.getAllSubclasses();
    if (deep && !unsafe) {// for multiple inheritance
      for (OClass subclass : subclasses) {
        long subclassRecs = schemaClass.count();
        if (subclassRecs > 0) {
          if (subclass.isSubClassOf("V")) {
            throw new OCommandExecutionException(
                "'TRUNCATE CLASS' command cannot be used on not empty vertex classes (" + subclass.getName()
                    + "). Apply the 'UNSAFE' keyword to force it (at your own risk)");
          } else if (subclass.isSubClassOf("E")) {
            throw new OCommandExecutionException(
                "'TRUNCATE CLASS' command cannot be used on not empty edge classes (" + subclass.getName()
                    + "). Apply the 'UNSAFE' keyword to force it (at your own risk)");
          }
        }
      }
    }

    try {
      schemaClass.truncate();
      invalidateCommandCache(schemaClass);
      if (deep) {
        for (OClass subclass : subclasses) {
          subclass.truncate();
          invalidateCommandCache(subclass);
        }
      }
    } catch (IOException e) {
      throw OException.wrapException(new OCommandExecutionException("Error on executing command"), e);
    }

    return recs;
  }
public Object execute ( final Map < Object , Object > iArgs ) { if ( schemaClass == null ) throw new OCommandExecutionException ( "Cannot execute the command because it has not been parsed yet" ) ; final long recs = schemaClass . count ( deep ) ; if ( recs > 0 && ! unsafe ) { if ( schemaClass . isSubClassOf ( "V" ) ) { throw new OCommandExecutionException ( "'TRUNCATE CLASS' command cannot be used on not empty vertex classes. Apply the 'UNSAFE' keyword to force it (at your own risk)" ) ; } else if ( schemaClass . isSubClassOf ( "E" ) ) { throw new OCommandExecutionException ( "'TRUNCATE CLASS' command cannot be used on not empty edge classes. Apply the 'UNSAFE' keyword to force it (at your own risk)" ) ; } } Collection < OClass > subclasses = schemaClass . getAllSubclasses ( ) ; if ( deep && ! unsafe ) { // for multiple inheritance
 for ( OClass subclass : subclasses ) { long subclassRecs = schemaClass . count ( ) ; if ( subclassRecs > 0 ) { if ( subclass . isSubClassOf ( "V" ) ) { throw new OCommandExecutionException ( "'TRUNCATE CLASS' command cannot be used on not empty vertex classes (" + subclass . getName ( ) + "). Apply the 'UNSAFE' keyword to force it (at your own risk)" ) ; } else if ( subclass . isSubClassOf ( "E" ) ) { throw new OCommandExecutionException ( "'TRUNCATE CLASS' command cannot be used on not empty edge classes (" + subclass . getName ( ) + "). Apply the 'UNSAFE' keyword to force it (at your own risk)" ) ; } } } } try { schemaClass . truncate ( ) ; invalidateCommandCache ( schemaClass ) ; if ( deep ) { for ( OClass subclass : subclasses ) { subclass . truncate ( ) ; invalidateCommandCache ( subclass ) ; } } } catch ( IOException e ) { throw OException . wrapException ( new OCommandExecutionException ( "Error on executing command" ) , e ) ; } return recs ; }
Execute the command.
Execute the command .