@classmethod
def from_artifact(cls, a):
    result = cls.query.get(ref_id=a.index_id())
    if (result is None):
        try:
            result = cls(ref_id=a.index_id(), project_id=a.app_config.project_id, app_config_id=a.app_config._id)
            session(result).flush(result)
        except pymongo.errors.DuplicateKeyError:
            session(result).expunge(result)
            result = cls.query.get(ref_id=a.index_id())
    result.link = a.shorthand_id()
    result.url = a.url()
    if (result.link is None):
        result.delete()
        return None
    return result
@classmethod
def from_artifact(cls, a):
    result = cls.query.get(ref_id=a.index_id())
    if (result is None):
        try:
            result = cls(ref_id=a.index_id(), project_id=a.app_config.project_id, app_config_id=a.app_config._id)
            session(result).flush(result)
        except pymongo.errors.DuplicateKeyError:
            session(result).expunge(result)
            result = cls.query.get(ref_id=a.index_id())
    result.link = a.shorthand_id()
    result.url = a.url()
    if (result.link is None):
        result.delete()
        return None
    return result