Example #1
0
    def get_input_value(my, sobject, snapshot):
        ''' value of the loading checkbox''' 
        # use the naming
        naming = Project.get_naming("node")
        naming.set_sobject(sobject)
        naming.set_snapshot(snapshot)
        namespace = naming.get_value()
        instance = sobject.get_name()
        snap_node_name = snapshot.get_node_name()

        """
        # Currently, web state object is not rebuilt.
        shot_id = my.search_id
        if not shot_id:
            shot_id = WebState.get().get_state("shot_id")

        if shot_id == "":
            shot_id = WebContainer.get_web().get_form_value("shot_id")
        if shot_id == "":
            raise WidgetException("No shot found value passed in")
        """

         
        #shot = my.parent.get_shot()

        shot_code = my.parent.get_value("shot_code")

        value = "%s|%s|%s|%s|%s|%s" % (snapshot.get_code(), shot_code, \
                instance, snapshot.get_context(), namespace, snap_node_name)
        return value
Example #2
0
    def add_related_connection(my, src_sobject, dst_sobject, src_path=None):
        '''adding the related sobject code to this current sobject''' 
        my.add_related_sobject(src_sobject)
        my.add_related_sobject(dst_sobject)


        #shot_col =  dst_sobject.get_foreign_key()
        schema = my.get_schema()
        st1 = my.get_base_search_type()
        st2 =  dst_sobject.get_base_search_type()
        relationship = schema.get_relationship(st1, st2)
        attrs = schema.get_relationship_attrs(st1, st2)
        
        from_col = attrs.get("from_col")

        search = Search( my.SEARCH_TYPE )
        search.add_filter(from_col,  dst_sobject.get_code())
        search.add_filter("type", "asset")
        search.add_filter("asset_code",  src_sobject.get_code())
        search.add_order_by('name desc')
        instances = search.get_sobjects()
        """
        # if it allows order by, I can switch to this
        filters = [('asset_code', src_sobject.get_code())]
        instances = dst_sobject.get_related_sobjects(my.SEARCH_TYPE, filters=filters)
        """
        naming = Project.get_naming("node")
        instance_name = naming.get_shot_instance_name(dst_sobject, src_sobject, instances)
        my.set_value('name', instance_name)
        my.set_value('type', 'asset')
Example #3
0
    def create(cls, shot, asset, instance_name="", type="asset", unique=False):

        shot_col = shot.get_foreign_key()
        search = Search( cls.SEARCH_TYPE )
        search.add_filter(shot_col, shot.get_code())
        search.add_filter("type", type)
        #if unique:
        #    search.add_filter("name", instance_name)
        search.add_filter("asset_code", asset.get_code())
        search.add_order_by('name desc')
        sobjs = search.get_sobjects()

        # if unique and exists, then return
        if unique and sobjs:
            Environment.add_warning("Instance exists", "Shot '%s' already has an instance for asset '%s'" % (shot.get_code(), asset.get_code()) )
            return

        naming = Project.get_naming("node")
        instance_name = naming.get_shot_instance_name(shot, asset, sobjs)
        
        #instance_name = cls.get_instance_name(sobjs, instance_name) 
        
        instance = SObjectFactory.create( cls.SEARCH_TYPE )
        instance.set_value(shot_col,shot.get_code())
        instance.set_value("asset_code",asset.get_code())
        instance.set_value("name",instance_name)
        instance.set_value("type",type)

        instance.commit()
        return instance
Example #4
0
    def get_input_value(my, sobject, snapshot):
        ''' value of the loading checkbox'''
        # use the naming
        naming = Project.get_naming("node")
        naming.set_sobject(sobject)
        naming.set_snapshot(snapshot)
        namespace = naming.get_value()
        instance = sobject.get_name()
        snap_node_name = snapshot.get_node_name()
        """
        # Currently, web state object is not rebuilt.
        shot_id = my.search_id
        if not shot_id:
            shot_id = WebState.get().get_state("shot_id")

        if shot_id == "":
            shot_id = WebContainer.get_web().get_form_value("shot_id")
        if shot_id == "":
            raise WidgetException("No shot found value passed in")
        """

        #shot = my.parent.get_shot()

        shot_code = my.parent.get_value("shot_code")

        value = "%s|%s|%s|%s|%s|%s" % (snapshot.get_code(), shot_code, \
                instance, snapshot.get_context(), namespace, snap_node_name)
        return value
Example #5
0
    def add_related_connection(self, src_sobject, dst_sobject, src_path=None):
        '''adding the related sobject code to this current sobject'''
        self.add_related_sobject(src_sobject)
        self.add_related_sobject(dst_sobject)

        #shot_col =  dst_sobject.get_foreign_key()
        schema = self.get_schema()
        st1 = self.get_base_search_type()
        st2 = dst_sobject.get_base_search_type()
        relationship = schema.get_relationship(st1, st2)
        attrs = schema.get_relationship_attrs(st1, st2)

        from_col = attrs.get("from_col")

        search = Search(self.SEARCH_TYPE)
        search.add_filter(from_col, dst_sobject.get_code())
        search.add_filter("type", "asset")
        search.add_filter("asset_code", src_sobject.get_code())
        search.add_order_by('name desc')
        instances = search.get_sobjects()
        """
        # if it allows order by, I can switch to this
        filters = [('asset_code', src_sobject.get_code())]
        instances = dst_sobject.get_related_sobjects(self.SEARCH_TYPE, filters=filters)
        """
        naming = Project.get_naming("node")
        instance_name = naming.get_shot_instance_name(dst_sobject, src_sobject,
                                                      instances)
        self.set_value('name', instance_name)
        self.set_value('type', 'asset')
Example #6
0
    def create(cls, shot, asset, instance_name="", type="asset", unique=False):

        shot_col = shot.get_foreign_key()
        search = Search(cls.SEARCH_TYPE)
        search.add_filter(shot_col, shot.get_code())
        search.add_filter("type", type)
        #if unique:
        #    search.add_filter("name", instance_name)
        search.add_filter("asset_code", asset.get_code())
        search.add_order_by('name desc')
        sobjs = search.get_sobjects()

        # if unique and exists, then return
        if unique and sobjs:
            Environment.add_warning(
                "Instance exists",
                "Shot '%s' already has an instance for asset '%s'" %
                (shot.get_code(), asset.get_code()))
            return

        naming = Project.get_naming("node")
        instance_name = naming.get_shot_instance_name(shot, asset, sobjs)

        #instance_name = cls.get_instance_name(sobjs, instance_name)

        instance = SObjectFactory.create(cls.SEARCH_TYPE)
        instance.set_value(shot_col, shot.get_code())
        instance.set_value("asset_code", asset.get_code())
        instance.set_value("name", instance_name)
        instance.set_value("type", type)

        instance.commit()
        return instance
Example #7
0
    def get_namespace(my, sobject, snapshot):
        ''' this is actually the namespace in Maya and node name in Houdini'''
        if not sobject:
            return ""

        naming = Project.get_naming("node") 
        naming.set_sobject(sobject)
        naming.set_snapshot(snapshot)
        instance = naming.get_value()
        return instance   
Example #8
0
    def get_namespace(my, sobject, snapshot):
        ''' this is actually the namespace in Maya and node name in Houdini'''
        if not sobject:
            return ""

        naming = Project.get_naming("node")
        naming.set_sobject(sobject)
        naming.set_snapshot(snapshot)
        instance = naming.get_value()
        return instance