Exemplo n.º 1
0
 def validateForPipeline(self, pipeline):
     """validateForPipeline(pipeline) -> None
     This will make sure that the parameters in the alias list are present
     in the pipeline. If they were removed, the aliases pointing to it will 
     be removed. This changes the mashup in place """
     to_remove = []
     for alias in self.alias_list:
         try:
             param = pipeline.db_get_object(alias.component.vttype,
                                            alias.component.vtid)
         except:
             to_remove.append(alias)
     for a in to_remove:
         self.alias_list.remove(a)    
     pos = 0
     mashup_aliases = []
     for a in self.alias_list:
         mashup_aliases.append(a.name)
         a.component.pos = pos
         pos+=1
         
     for a, info in pipeline.aliases.iteritems():
         if a not in mashup_aliases:
             parameter = pipeline.db_get_object(info[0],info[1])
             cid = self.id_scope.getNewId('component')
             aid = self.id_scope.getNewId('alias')
             component = Component(cid, parameter.vtType, 
                                   parameter.real_id, info[2], info[3],
                                   info[4], parameter.type, 
                                   parameter.strValue, parameter.pos, 
                                   pos, "")
             newalias = Alias(aid, a, component) 
             self.alias_list.append(newalias)
             pos +=1      
Exemplo n.º 2
0
 def fromXml(node):
     if node.tag != 'mashup':
         #print "node.tag != 'mashup'"
         return None
     #read attributes
     data = node.get('id', None)
     id = Mashup.convert_from_str(data, 'long')
     data = node.get('name', None)
     name = Mashup.convert_from_str(data, 'str')
     data = node.get('version', None)
     version = Mashup.convert_from_str(data, 'long')
     data = node.get('vtid', None)
     vtid = Mashup.convert_from_str(data, 'str')
     data = node.get('type', None)
     type = Mashup.convert_from_str(data, 'str')
     data = node.get('has_seq', None)
     seq = Component.convert_from_str(data, 'bool')
     alias_list = []
     layout = None
     geometry = None
     for child in node.getchildren():
         if child.tag == "alias":
             alias = Alias.fromXml(child)
             alias_list.append(alias)
         if child.tag == "layout":
             layout = str(child.text).strip(" \n\t")
         if child.tag == "geometry":
             geometry = str(child.text).strip(" \n\t")
     return Mashup(id=id, name=name, vtid=vtid, version=version, 
                            alias_list=alias_list, t=type, has_seq=seq,
                            layout=layout, geometry=geometry)
Exemplo n.º 3
0
 def create_mashup(self, id_scope=IdScope()):
     c1 = Component(id=id_scope.getNewId('component'),
                       vttype='parameter', param_id=15L, 
                       parent_vttype='function', parent_id=3L, mid=4L,
                       type='String', value='test', p_pos=0, pos=1, 
                       strvaluelist='test1,test2', widget="text")
     a1 = Alias(id=id_scope.getNewId('alias'), name='alias1', component=c1)
     
     m = Mashup(id=id_scope.getNewId('mashup'), name='mashup1', vtid='empty.vt', 
                version=15L, alias_list=[a1])
     return m
    def fromXml(node):
        if node.tag != "alias":
            return None

        # read attributes
        data = node.get("id", None)
        id = Alias.convert_from_str(data, "long")
        data = node.get("name", None)
        name = Alias.convert_from_str(data, "str")
        for child in node.getchildren():
            if child.tag == "component":
                component = Component.fromXml(child)
        alias = Alias(id, name, component)
        return alias
Exemplo n.º 5
0
    def fromXml(node):
        if node.tag != 'alias':
            return None

        #read attributes
        data = node.get('id', None)
        id = Alias.convert_from_str(data, 'long')
        data = node.get('name', None)
        name = Alias.convert_from_str(data, 'str')
        for child in node.getchildren():
            if child.tag == "component":
                component = Component.fromXml(child)
        alias = Alias(id, name, component)
        return alias
Exemplo n.º 6
0
 def create_alias(self, id_scope=IdScope()):
     c1 = Component(id=id_scope.getNewId('component'),
                    vttype='parameter',
                    param_id=15L,
                    parent_vttype='function',
                    parent_id=3L,
                    mid=4L,
                    type='String',
                    value='test',
                    p_pos=0,
                    pos=1,
                    strvaluelist='test1,test2',
                    widget="text")
     a1 = Alias(id=id_scope.getNewId('alias'), name='alias1', component=c1)
     return a1
Exemplo n.º 7
0
 def create_action(self, id_scope=IdScope()):
     from core.mashup.component import Component
     from core.mashup.alias import Alias
     c1 = Component(id=id_scope.getNewId('component'),
                       vttype='parameter', param_id=15L, 
                       parent_vttype='function', parent_id=3L, mid=4L,
                       type='String', value='test', p_pos=0, pos=1, 
                       strvaluelist='test1,test2', widget="text")
     a1 = Alias(id=id_scope.getNewId('alias'), name='alias1', component=c1)
     
     m = Mashup(id=id_scope.getNewId('mashup'), name='mashup1', vtid='empty.vt', 
                version=15L, alias_list=[a1])
     action = Action(id=id_scope.getNewId('action'),
                     parent_id=0L,
                     date=datetime(2007,11,18),
                     mashup=m)
     return action
Exemplo n.º 8
0
 def loadAliasesFromPipeline(self, pipeline, id_scope):
     """loadAliasesFromPipelines(pipeline: Pipeline) -> None 
     This will replace current aliases with the ones present in Pipeline
     
     """
     
     if pipeline:
         self.alias_list = []
         if len(pipeline.aliases) > 0:
             pos = 0
             for aname,info in pipeline.aliases.iteritems():
                 parameter = pipeline.db_get_object(info[0],info[1])
                 cid = id_scope.getNewId('component')
                 aid = id_scope.getNewId('alias')
                 component = Component(cid, parameter.vtType, 
                                       parameter.real_id, info[2], info[3],
                                       info[4], parameter.type, 
                                       parameter.strValue, parameter.pos, 
                                       pos, "")
                 alias = Alias(aid, aname, component)
                 self.alias_list.append(alias)
                 pos += 1 
Exemplo n.º 9
0
    def updateAliasFromParam(self, param):
        add_alias = True
        new_aliases = []
        pos = 0
        for alias in self.currentMashup.alias_list:
            if alias.component.vtid != param.id:
                calias = copy.copy(alias)
                calias.component.pos = pos
                new_aliases.append(calias)
                pos += 1
            else:
                #print "found alias: ", alias
                add_alias = False
                if param.alias != '':
                    new_alias = copy.copy(alias)
                    new_alias.name = param.alias
                    new_aliases.append(new_alias)
                    pos += 1
        if add_alias:
            parameter = self.vtPipeline.db_get_object(param.dbtype, param.id)
            cid = self.id_scope.getNewId('component')
            aid = self.id_scope.getNewId('alias')
            component = Component(cid, parameter.vtType, parameter.real_id,
                                  param.parent_dbtype, param.parent_id,
                                  param.mId, parameter.type,
                                  parameter.strValue, parameter.pos, pos, "")
            alias = Alias(aid, param.alias, component)
            new_aliases.append(alias)
            self.vtPipeline.add_alias(param.alias, param.type, param.id,
                                      param.parent_dbtype, param.parent_id,
                                      param.mId)
        else:
            self.vtPipeline.change_alias(param.alias, param.type, param.id,
                                         param.parent_dbtype, param.parent_id,
                                         param.mId)

        return self.createMashupVersion(new_aliases, quiet=False)
Exemplo n.º 10
0
    def updateAliasesFromPipeline(self, pipeline):
        """updateAliasesFromPipeline(self, pipeline) -> long
        This will generate a new mashup by updating the aliases of the current 
        mashup according to the aliases in a pipeline. This assumes that the 
        mashup's current aliases are different from pipeline aliases by at most 
        one change (eg., an alias rename, an alias addition, an alias removal)
        
        """
        pip_aliases = pipeline.aliases.keys()
        mashup_aliases = [a.name for a in self.currentMashup.alias_list]
        new_aliases = []
        if len(pip_aliases) == len(mashup_aliases):
            #an alias probably changed its name or its value
            old_a = None
            new_a = None
            for a in self.currentMashup.alias_list:
                if a.name not in pip_aliases:
                    old_a = copy.copy(a)
                    new_aliases.append(old_a)
                else:
                    new_aliases.append(a)
            for a in pip_aliases:
                if a not in mashup_aliases:
                    new_a = (a, pipeline.aliases[a])
            if old_a is not None and new_a is not None:
                (a, info) = new_a
                parameter = pipeline.db_get_object(info[0], info[1])
                old_a.name = a
                old_a.component.vttype = parameter.vtType
                old_a.component.vtid = parameter.real_id
                old_a.component.vtparent_type = info[2]
                old_a.component.vt_parent_id = info[3]
                old_a.component.mid = info[4]
                old_a.component.type = parameter.type
                old_a.component.val = parameter.strValue
                old_a.component.vtpos = parameter.pos

        elif len(pip_aliases) < len(mashup_aliases):
            # an alias was removed
            pos = 0
            for a in self.currentMashup.alias_list:
                if a.name in pip_aliases:
                    alias = copy.copy(a)
                    alias.component.pos = pos
                    new_aliases.append(alias)
                    pos += 1
        else:
            #an alias was added
            pos = len(mashup_aliases)
            new_aliases = [a for a in self.currentMashup.alias_list]
            for a in pip_aliases:
                if a not in mashup_aliases:
                    info = pipeline.aliases[a]
                    parameter = pipeline.db_get_object(info[0], info[1])
                    cid = self.id_scope.getNewId('component')
                    aid = self.id_scope.getNewId('alias')
                    component = Component(cid, parameter.vtType,
                                          parameter.real_id, info[2], info[3],
                                          info[4], parameter.type,
                                          parameter.strValue, parameter.pos,
                                          pos, "")
                    alias = Alias(aid, a, component)
                    new_aliases.append(alias)
                    pos += 1

        return self.createMashupVersion(new_aliases, quiet=False)