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 ( ) ; if ( database . getMetadata ( ) . getSchema ( ) . existsClass ( className ) ) throw new OCommandExecutionException ( "Class " + className + " already exists" ) ; final OClassImpl sourceClass = ( OClassImpl ) ( ( OSchemaProxy ) database . getMetadata ( ) . getSchema ( ) ) . createClassInternal ( className , superClass , clusterIds ) ; sourceClass . saveInternal ( ) ; if ( superClass != null ) { int [ ] clustersToIndex = superClass . getPolymorphicClusterIds ( ) ; String [ ] clusterNames = new String [ clustersToIndex . length ] ; for ( int i = 0 ; i < clustersToIndex . length ; i ++ ) { clusterNames [ i ] = database . getClusterNameById ( clustersToIndex [ i ] ) ; } for ( OIndex < ? > index : superClass . getIndexes ( ) ) for ( String clusterName : clusterNames ) index . getInternal ( ) . addCluster ( clusterName ) ; } return database . getMetadata ( ) . getSchema ( ) . getClasses ( ) . size ( ) ; }
Execute the CREATE CLASS .