def componentImport(obj,
                    protocol,
                    user=None,
                    refreshCache=False,
                    modelType=['activity', 'item']):
    """
    :param modelType: model or models to search
    :type modelType: str or iterable
    :returns: protocol (updated)
    """
    import itertools
    from girderformindlogger.models import pluralize, smartImport
    from girderformindlogger.utility import firstLower

    updatedProtocol = deepcopy(protocol)
    obj2 = {k: v for k, v in expand(deepcopy(obj)).items() if v is not None}
    try:
        for order in obj2.get("reprolib:terms/order", {}):
            for activity in order.get("@list", []):
                IRI = activity.get('url', activity.get('@id'))
                if reprolibPrefix(IRI) not in list(
                        itertools.chain.from_iterable([
                            protocol.get(mt, {}).keys()
                            for mt in ["activities", "items"]
                        ])):
                    activityComponent, activityContent, canonicalIRI =         \
                        smartImport(
                            IRI,
                            user=user,
                            refreshCache=refreshCache
                        ) if (IRI is not None and not IRI.startswith(
                            "Document not found"
                        )) else (None, None, None)
                    activity["url"] = activity[
                        "schema:url"] = canonicalIRI if (canonicalIRI
                                                         is not None) else IRI
                    activityComponent = pluralize(
                        firstLower(
                            activityContent.get(
                                '@type', [''])[0].split('/')[-1].split(':')[-1]
                        )) if (activityComponent is None and isinstance(
                            activityContent, dict)) else activityComponent
                    if activityComponent is not None:
                        activityComponents = (pluralize(activityComponent)
                                              if activityComponent != 'screen'
                                              else 'items')
                        updatedProtocol[activityComponents][
                            canonicalIRI] = deepcopy(
                                formatLdObject(activityContent,
                                               activityComponent,
                                               user,
                                               refreshCache=refreshCache))
        return (updatedProtocol.get('meta', updatedProtocol).get(
            modelType if isinstance(modelType, str) else modelType[0],
            updatedProtocol))
    except:
        import sys, traceback
        print("error!")
        print(sys.exc_info())
        print(traceback.print_tb(sys.exc_info()[2]))
def getModelCollection(modelType):
    """
    Returns the Collection named for the given modelType, creating if not
    already extant.

    :param modelType: 'activity', 'screen', etc.
    :type modelType: str
    :returns: dict
    """
    from girderformindlogger.models import pluralize
    name = pluralize(modelType).title()
    collection = CollectionModel().findOne({'name': name})
    if not collection:
        collection = CollectionModel().createCollection(name=name,
                                                        public=True,
                                                        reuseExisting=True)
    return (collection)