mondo-project / mondo-hawk

Heterogeneous model indexing solution, based on NoSQL stores.
Eclipse Public License 2.0
17 stars 5 forks source link

select(p:Type|p) not working, isTypeOf works for some queries #56

Open agarciadom opened 6 years ago

agarciadom commented 6 years ago

This query had to be rewritten from using select(p:Type|xyz) to using select(p|p.isTypeOf(Type)):

var components = Component.all; return components.collect(c|c.countClasses()).sum() / components.size;

@cached
operation Component countClasses() {
  return self.OwnedElement.select(c|c.isTypeOf(Class)).size + 
    self.OwnedElement.select(p|p.isTypeOf(Package)).collect(p|p.countClasses()).sum() + 
    self.OwnedElement.select(subc|subc.isTypeOf(Component)).collect(subc|subc.countClasses()).sum();
}

@cached
operation Package countClasses() {
  return self.OwnedElement.select(c|c.isTypeOf(Class)).size +
    self.OwnedElement.select(p|p.isTypeOf(Package)).collect(p|p.countClasses()).sum();
}