Ejemplo n.º 1
0
 def match_internal(self, model, idx, count, progress=None):
     self.traversed = True
     self._matched = False
     sz = model.getEventCount()
     maxidx = -1
     for el in self.get_children():
         if isinstance(el, fev):
             params = el.process_params()
             tidx = idx
             while tidx < count:
                 mev = model.getEventAt(tidx)
                 v = el.match_params(params, mev, tidx)
                 if v:
                     if tidx > maxidx: maxidx = tidx
                     break
                 tidx += 1
                 if progress:
                     progress.progress(tidx)
             if tidx == count:
                 raise FlowError("element " + el.str_resolved() +
                                 " not found, in flow ")
         else:
             tmpidx = el.match_internal(model,
                                        idx,
                                        count,
                                        progress=progress)
             if tmpidx > maxidx:
                 maxidx = tmpidx
         self._matched = True
     return maxidx
Ejemplo n.º 2
0
 def match_internal(self, model, idx, count, progress=None):
     self.traversed = True
     self._matched = False
     sz = model.getEventCount()
     rep = 0
     el = self.children[0]
     self.exception = None
     while True:
         if isinstance(el, fev):
             params = el.process_params()
             while idx < count:
                 mev = model.getEventAt(idx)
                 v = el.match_params(params, mev, idx)
                 idx += 1
                 if progress:
                     progress.progress(idx)
                 if v: break
             if idx == count:
                 break
         else:
             try:
                 idx = el.match_internal(model,
                                         idx,
                                         count,
                                         progress=progress)
             except FlowError, e:
                 self.exception = e
                 break
         rep += 1
         if rep == self.max:
             break
Ejemplo n.º 3
0
    def match_internal(self, model, idx, count, progress=None):
        self.traversed = True
        self._matched = False
        men = None
        mcount = 0
        for el in self.get_children():
            if isinstance(el, fev):
                params = el.process_params()
                maxEvIdx = model.getEventCount()
                #for en in model.getEntityIterator(False):
                #if params[0].match(en.getPath()) and en.getLastEventIndex() > maxEvIdx:
                #    maxEvIdx = en.getLastEventIndex()
                if maxEvIdx < 0:
                    raise FlowError("No Entity found matching " +
                                    params[0].pattern)
                while idx <= maxEvIdx:
                    mev = model.getEventAt(idx)
                    v = el.match_params(params, mev, idx)
                    idx += 1
                    if progress:
                        progress.progress(idx)

                    if v: break
                    if idx == count:
                        raise FlowError("element " + el.str_resolved() +
                                        " not found in model.")
            else:
                idx = el.match_internal(model, idx, count, progress=progress)
                mcount += 1
        self._matched = True
        return idx
Ejemplo n.º 4
0
 def match_internal(self, model, idx, count, progress=None):
     self.traversed = True
     self._matched = False
     sz = model.getEventCount()
     rep = 0
     el = self.children[0]
     self.exception = None
     while True:
         if isinstance(el, fev):         
             params = el.process_params()
             while idx < count:
                 mev = model.getEventAt(idx)
                 v = el.match_params(params, mev, idx)
                 idx += 1 
                 if progress:
                     progress.progress(idx)
                 if v: break;
             if idx == count:
                 break
         else:
             try:
                 idx = el.match_internal(model, idx, count, progress=progress)
             except FlowError, e:
                 self.exception = e;
                 break           
         rep += 1
         if rep == self.max:
             break;
Ejemplo n.º 5
0
 def match_internal(self, model, idx, count, progress=None):
     self.traversed = True
     self._matched = False
     sz = model.getEventCount()
     maxidx = -1
     for el in self.get_children():
         if isinstance(el, fev):         
             params = el.process_params()
             tidx = idx;
             while tidx < count:
                 mev = model.getEventAt(tidx)
                 v = el.match_params(params, mev, tidx) 
                 if v:               
                     if tidx>maxidx: maxidx = tidx               
                     break;
                 tidx += 1
                 if progress:
                     progress.progress(tidx)
             if tidx == count:
                 raise FlowError("element "+el.str_resolved()+" not found, in flow ")
         else:
             tmpidx = el.match_internal(model, idx, count, progress=progress)
             if tmpidx > maxidx:
                 maxidx = tmpidx
         self._matched = True 
     return maxidx
Ejemplo n.º 6
0
 def match_internal(self, model, idx, count, progress=None):
     self.traversed = True
     self._matched = False
     sz = model.getEventCount()
     exc = []
     children = self.get_children()
     for el in children:
         if isinstance(el, fev):
             params = el.process_params()
             while idx < count:
                 mev = model.getEventAt(idx)
                 v = el.match_params(params, mev, idx)
                 idx += 1
                 if progress:
                    progress.progress(idx)
                 if v:               
                     self._matched = True                        
                     return idx
         else:
             try:
                 idx1 = el.match_internal(model, idx, count, progress=progress)
                 self._matched = True
                 #clear other branches taken. We do this here
                 #because if no branch succeeds we want to keep
                 #the traversed and model info for the partial 
                 #successes.
                 for el1 in children:
                     if el1 != el:
                         el1.reset()
                 return idx1
             except FlowError, e:
                 #print "got exception ", e, "for index ", idx
                 exc.append(e)
                 continue
Ejemplo n.º 7
0
    def match_internal(self, model, idx, count, progress=None):
        self.traversed = True
        self._matched = False
        men = None
        mcount = 0
        for el in self.get_children():
            if isinstance(el, fev):
                params = el.process_params()
                maxEvIdx = model.getEventCount()
                #for en in model.getEntityIterator(False):
                    #if params[0].match(en.getPath()) and en.getLastEventIndex() > maxEvIdx:
                    #    maxEvIdx = en.getLastEventIndex()
                if maxEvIdx < 0:
                    raise FlowError("No Entity found matching "+params[0].pattern)
                while idx <= maxEvIdx:
                    mev = model.getEventAt(idx)
                    v = el.match_params(params, mev, idx)
                    idx += 1 
                    if progress:
                        progress.progress(idx)

                    if v: break
                    if idx == count:
                        raise FlowError("element "+el.str_resolved()+" not found in model.")
            else:
                idx = el.match_internal(model, idx, count, progress=progress)
                mcount += 1
        self._matched = True;
        return idx
Ejemplo n.º 8
0
def msc_flow_print():
    if model == None or model.getEventCount() == 0:
        raise Error("Invalid model")

    print "(",
    en = None
    first = True
    prt = ""
    for i in range(0, model.getEventCount()):
        ev = model.getEventAt(i)
        m = ev.getMarker()
        if m != None:
            if first:
                first = False
            else:
                prt += ","
            en1 = ev.getEntity()
            if en1 != en:
                en = en1
                prt += "\n(\"" + en.getPath() + "\",\"" + ev.getLabel() + "\")"
            else:
                prt += "\"" + ev.getLabel() + "\""
    print prt + ")"
Ejemplo n.º 9
0
def msc_flow_print():
    if model == None or model.getEventCount() == 0:
        raise Error("Invalid model")
    
    print "(",
    en = None
    first = True
    prt = ""
    for i in range(0, model.getEventCount()):
        ev = model.getEventAt(i)
        m = ev.getMarker()
        if m != None:
            if first:
                first = False
            else:
                prt += ","
            en1 = ev.getEntity()
            if en1 != en:
                en = en1
                prt += "\n(\"" + en.getPath() + "\",\""+ev.getLabel()+"\")"
            else:
                prt += "\"" + ev.getLabel() + "\""
    print prt + ")"
Ejemplo n.º 10
0
 def match(self, start_event_idx=0, model=None, progress=None):
     if model == None:
         model = MSCDataModel.getInstance()
     if model == None:
         raise Error("Null model")        
     ev_count = model.getEventCount()
     if ev_count == 0:
         raise Error("Empty model")        
     if ev_count<=start_event_idx:
         return -1
     self.reset()
     try:
         res = self.match_internal(model, start_event_idx, ev_count, progress=progress);
     except AbortSearchException:
         raise FlowError("Search aborted")
     return res
Ejemplo n.º 11
0
 def match(self, start_event_idx=0, model=None, progress=None):
     if model == None:
         model = MSCDataModel.getInstance()
     if model == None:
         raise Error("Null model")
     ev_count = model.getEventCount()
     if ev_count == 0:
         raise Error("Empty model")
     if ev_count <= start_event_idx:
         return -1
     self.reset()
     try:
         res = self.match_internal(model,
                                   start_event_idx,
                                   ev_count,
                                   progress=progress)
     except AbortSearchException:
         raise FlowError("Search aborted")
     return res
Ejemplo n.º 12
0
 def match_internal(self, model, idx, count, progress=None):
     self.traversed = True
     self._matched = False
     sz = model.getEventCount()
     exc = []
     children = self.get_children()
     for el in children:
         if isinstance(el, fev):
             params = el.process_params()
             while idx < count:
                 mev = model.getEventAt(idx)
                 v = el.match_params(params, mev, idx)
                 idx += 1
                 if progress:
                     progress.progress(idx)
                 if v:
                     self._matched = True
                     return idx
         else:
             try:
                 idx1 = el.match_internal(model,
                                          idx,
                                          count,
                                          progress=progress)
                 self._matched = True
                 #clear other branches taken. We do this here
                 #because if no branch succeeds we want to keep
                 #the traversed and model info for the partial
                 #successes.
                 for el1 in children:
                     if el1 != el:
                         el1.reset()
                 return idx1
             except FlowError, e:
                 #print "got exception ", e, "for index ", idx
                 exc.append(e)
                 continue