Class: InterMine::PathQuery::LoopConstraint

Inherits:
Object
  • Object
show all
Includes:
Coded, PathFeature
Defined in:
lib/intermine/query.rb

Direct Known Subclasses

TemplateLoopConstraint

Instance Attribute Summary collapse

Attributes included from Coded

#code, #op

Attributes included from PathFeature

#path

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loopPathObject

Returns the value of attribute loopPath.



1249
1250
1251
# File 'lib/intermine/query.rb', line 1249

def loopPath
  @loopPath
end

Class Method Details

.valid_opsObject



1251
1252
1253
# File 'lib/intermine/query.rb', line 1251

def self.valid_ops
    return ["IS", "IS NOT"]
end

.xml_opsObject



1255
1256
1257
# File 'lib/intermine/query.rb', line 1255

def self.xml_ops
    return { "IS" => "=", "IS NOT" => "!=" }
end

Instance Method Details

#to_elemObject



1259
1260
1261
1262
1263
1264
# File 'lib/intermine/query.rb', line 1259

def to_elem
    elem = super
    elem.add_attribute("op", LoopConstraint.xml_ops[@op])
    elem.add_attribute("loopPath", @loopPath)
    return elem
end

#validateObject



1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
# File 'lib/intermine/query.rb', line 1266

def validate
    if @path.elements.last.is_a?(InterMine::Metadata::AttributeDescriptor)
        raise ArgumentError, "#{self.class.name}s must be on objects or references to objects"
    end
    if @loopPath.elements.last.is_a?(InterMine::Metadata::AttributeDescriptor)
        raise ArgumentError, "loopPaths on #{self.class.name}s must be on objects or references to objects"
    end
    model = @path.model
    cdA = model.get_cd(@path.end_type)
    cdB = model.get_cd(@loopPath.end_type)
    if !(cdA == cdB) && !cdA.subclass_of?(cdB) && !cdB.subclass_of?(cdA)
        raise ArgumentError, "Incompatible types in #{self.class.name}: #{@path} -> #{cdA} and #{@loopPath} -> #{cdB}"
    end
end