public int getElementPosition ( String element_id ) { int index = - 1 ; for ( int i = 0 ; i < entities . size ( ) ; i ++ ) { QueryControllerEntity element = entities . get ( i ) ; if ( element instanceof QueryControllerQuery ) { QueryControllerQuery query = ( QueryControllerQuery ) element ; if ( query . getID ( ) . equals ( element_id ) ) { index = i ; break ; } } if ( element instanceof QueryControllerGroup ) { QueryControllerGroup group = ( QueryControllerGroup ) element ; if ( group . getID ( ) . equals ( element_id ) ) { index = i ; break ; } else { // Searching inside the group. Vector < QueryControllerQuery > queries_ingroup = group . getQueries ( ) ; for ( QueryControllerQuery query : queries_ingroup ) { if ( query . getID ( ) . equals ( element_id ) ) { index = i ; break ; } } } } } return index ; }
Returns the index of the element in the vector . If its is a query and the query is found inside a query group . The position of the group is returned instead .