NAME

Webservice::InterMine::Path - functions for finding problems with paths

SYNOPSIS

For validation using functions/static methods:

use Webservice::InterMine::Path qw(:validate);

my @errors;
push @errors, validate_path($model, $path_string);
push @errors, end_is_class($model, $path_string);
push @errors, b_is_subclass_of_a($model, $path_stringA, $path_stringB);
confess @errors if @errors;

For queries for path based information from query services:

use Webservice::InterMine;

my $service = Webservice::InterMine->get_testmine;
my $path = $service->new_path('Department.employees.name');
my $has_guessed_correctly = 0;
for my $name ($path->get_possible_values) {
    last if $has_guessed_correctly;
    print "Is your name $name?: y|N:";
    chomp(my $resp = <STDIN>);
    $has_guessed_correctly++ if ($resp =~ /y(es)?/i);
}

METHODS

new(Str path, Service service, [HashRef subtypes])

Construct a new path object for use with path based webservice. The path is immediately validated before use, so any subclass constraints that affect this path need to be included in the subtypes hash.

This constructor is not meant to be used directly; rather, obtain Webservice::InterMine:Path objects from their respective Service objects via their new_path methods.

get_results_iterator([$format])

Return an object for iterating over rows of results. The formats that are supported by the possible values service are jsonobjects (the default), and count formats. However, for accessing counts, and even values, it is probably easier to use the convenience methods listed below.

set_subtype($key => $value)

Paths can be refined by adding subtype constraints after they have been constructed. EG:

my $path = $service->new_path("Department.employees.name")
# now the path represents that names of employees

$path->set_subtype("Department.employees" => "CEO");
# And now it represents the names of CEOs

get_possible_values()

Returns the values this path may potentially have. Be aware that in list context it returns, as expected, as list of values, whereas in scalar context it resturns an Array-Reference to that list of values. If you just want the number of items in the list, use get_possible_values_count instead, which is much more efficient.

get_possible_values_count()

Returns the number of different values this path may represent. This is the most efficient way to retrieve this information from the server.

end_is_attribute()

Return true if this object represents a path that ends in an attribute.

prefix()

Return the path before this one. eg, for "Gene.exons.name", return a path representing "Gene.exons". The resulting path with have all the same data as this one, including subclass information.

append(@parts)

Return a path representing a path made from this one with further parts added on. Eg, for a path representing "Gene.exons", a call to $path->append("name") should return a path representing "Gene.exons.name".

FUNCTIONS

validate_path

Usage   : validate_path($model, 'Department.name');
Function: Return errors for this path, nothing if the path is valid
Args    : $model - the InterMine::Model to use for validating
          $path_string - the path in string format

last_bit

Usage   : last_bit($model, 'Department.name');
Function: Returns the metaclass for the last part of the path-string
Args    : $model - the InterMine::Model to use for validating
          $path_string - the path in string format

resolve

Resolves a path to a class descriptor, or an attribute descriptor.

type_of

Usage    : type_of($model, 'Department.name');
Function : returns a string with the type that this string evaluates to
           ie: Department.name => String
               Department.employees => Employee

end_is_class

Usage   : end_is_class($model, 'Department.name');
Function: Returns an error if the last bit does not evaluate to a class (ie. is an attribute)
Args    : $model - the InterMine::Model to use for validating
          $path_string - the path in string format

a_is_subclass_of_b($model, $classA, $classB)

Returns undef if $classA represents a subclass of $classB, or if they do not represent valid paths, otherwise returns a message.

b_is_subclass_of_a($model, $classA, $classB)

Returns undef if $classA represents a subclass of $classB, or if they do not represent valid paths, otherwise returns a message.

class_of

Usage   : class_of($instance);
Function: Returns the meta-class that an object refers to.
Args    : an Webservice::InterMine::Field or ClassDescriptor instance

AUTHOR

FlyMine <support@flymine.org>

BUGS

Please report any bugs or feature requests to support@flymine.org.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Webservice::InterMine::Path

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2009,2010 FlyMine, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.