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

    final ODatabaseRecord database = getDatabase();
    final OClass oClass = database.getMetadata().getSchema().getClass(className);
    if (oClass == null)
      return null;

    for (final OIndex<?> oIndex : oClass.getClassIndexes()) {
      database.getMetadata().getIndexManager().dropIndex(oIndex.getName());
    }

    final OClass superClass = oClass.getSuperClass();
    final int[] clustersToIndex = oClass.getPolymorphicClusterIds();

    final String[] clusterNames = new String[clustersToIndex.length];
    for (int i = 0; i < clustersToIndex.length; i++) {
      clusterNames[i] = database.getClusterNameById(clustersToIndex[i]);
    }

    final int clusterId = oClass.getDefaultClusterId();

    ((OSchemaProxy) database.getMetadata().getSchema()).dropClassInternal(className);
    ((OSchemaProxy) database.getMetadata().getSchema()).saveInternal();
    database.getMetadata().getSchema().reload();

    deleteDefaultCluster(clusterId);

    if (superClass == null)
      return true;

    for (final OIndex<?> oIndex : superClass.getIndexes()) {
      for (final String clusterName : clusterNames)
        oIndex.getInternal().removeCluster(clusterName);

      OLogManager.instance().info("Index %s is used in super class of %s and should be rebuilt.", oIndex.getName(), className);
      oIndex.rebuild();
    }

    return true;
  }
public Object execute ( final Map < Object , Object > iArgs ) { if ( className == null ) throw new OCommandExecutionException ( "Cannot execute the command because it has not been parsed yet" ) ; final ODatabaseRecord database = getDatabase ( ) ; final OClass oClass = database . getMetadata ( ) . getSchema ( ) . getClass ( className ) ; if ( oClass == null ) return null ; for ( final OIndex < ? > oIndex : oClass . getClassIndexes ( ) ) { database . getMetadata ( ) . getIndexManager ( ) . dropIndex ( oIndex . getName ( ) ) ; } final OClass superClass = oClass . getSuperClass ( ) ; final int [ ] clustersToIndex = oClass . getPolymorphicClusterIds ( ) ; final String [ ] clusterNames = new String [ clustersToIndex . length ] ; for ( int i = 0 ; i < clustersToIndex . length ; i ++ ) { clusterNames [ i ] = database . getClusterNameById ( clustersToIndex [ i ] ) ; } final int clusterId = oClass . getDefaultClusterId ( ) ; ( ( OSchemaProxy ) database . getMetadata ( ) . getSchema ( ) ) . dropClassInternal ( className ) ; ( ( OSchemaProxy ) database . getMetadata ( ) . getSchema ( ) ) . saveInternal ( ) ; database . getMetadata ( ) . getSchema ( ) . reload ( ) ; deleteDefaultCluster ( clusterId ) ; if ( superClass == null ) return true ; for ( final OIndex < ? > oIndex : superClass . getIndexes ( ) ) { for ( final String clusterName : clusterNames ) oIndex . getInternal ( ) . removeCluster ( clusterName ) ; OLogManager . instance ( ) . info ( "Index %s is used in super class of %s and should be rebuilt." , oIndex . getName ( ) , className ) ; oIndex . rebuild ( ) ; } return true ; }
Execute the DROP CLASS.