コード例 #1
0
ファイル: classificationadmin.py プロジェクト: fferen/CATMAID
    def done(self, form_list, **kwargs):
        """ Will add all missing links, stored in the tag groups field.
        """
        tag_groups = self.get_selected_tag_groups()
        unified_tag_groups = {}
        num_added_links = 0
        failed_links = {}
        for eg, group in tag_groups.items():
            for p, pdata in group['project_cgroots'].items():
                # Iterate missing links
                for ml in pdata['missing']:
                    try:
                        # Add missing link
                        wid = pdata['workspace']
                        oroot = ClassInstance.objects.get(pk=ml)
                        link_existing_classification(wid, self.request.user, p,
                                                     oroot)
                        unified_tag_groups[eg] = group
                        num_added_links = num_added_links + 1
                    except Exception as e:
                        failed_links[ml] = e
        # Delete tag groups stored in session
        self.clear_cache()

        # Show final page
        return render_to_response(
            'catmaid/classification/admin_done.html', {
                'tag_groups': unified_tag_groups,
                'num_added_links': num_added_links,
                'failed_links': failed_links,
            })
コード例 #2
0
ファイル: classificationadmin.py プロジェクト: catsop/CATMAID
    def done(self, form_list, **kwargs):
        """ Will add all missing links, stored in the tag groups field.
        """
        tag_groups = self.get_selected_tag_groups()
        unified_tag_groups = {}
        num_added_links = 0
        failed_links = {}
        for eg, group in tag_groups.items():
            for pid, pdata in group['project_cgroots'].items():
                # Iterate missing links
                for ml in pdata['missing']:
                    try:
                        # Add missing link
                        wid = pdata['workspace']
                        oroot = ClassInstance.objects.get(pk=ml)
                        p = Project.objects.get(pk=pid)
                        link_existing_classification(wid, self.request.user, p, oroot)
                        unified_tag_groups[eg] = group
                        num_added_links = num_added_links + 1
                    except Exception as e:
                        failed_links[ml] = e

        # Show final page
        return render_to_response('catmaid/classification/admin_done.html', {
            'tag_groups': unified_tag_groups,
            'num_added_links': num_added_links,
            'failed_links': failed_links,
        })
コード例 #3
0
def import_projects(user, pre_projects, make_public, tags, permissions,
                    tile_width, tile_height, tile_source_type,
                    cls_graph_ids_to_link):
    """ Creates real CATMAID projects out of the PreProject objects
    and imports them into CATMAID.
    """
    imported = []
    not_imported = []
    for pp in pre_projects:
        try:
            # Create stacks and add them to project
            stacks = []
            for s in pp.stacks:
                stack = Stack.objects.create(title=s.name,
                                             dimension=s.dimension,
                                             resolution=s.resolution,
                                             image_base=s.image_base,
                                             num_zoom_levels=s.num_zoom_levels,
                                             file_extension=s.file_extension,
                                             tile_width=tile_width,
                                             tile_height=tile_height,
                                             tile_source_type=tile_source_type,
                                             metadata=s.metadata)
                stacks.append(stack)
                # Add overlays of this stack
                for o in s.overlays:
                    Overlay.objects.create(title=o.name,
                                           stack=stack,
                                           image_base=o.image_base,
                                           default_opacity=o.default_opacity,
                                           file_extension=o.file_extension,
                                           tile_width=tile_width,
                                           tile_height=tile_height,
                                           tile_source_type=tile_source_type)
            # Create new project
            p = Project.objects.create(title=pp.name, public=make_public)
            # Assign permissions to project
            assigned_permissions = []
            for user_or_group, perm in permissions:
                assigned_perm = assign(perm.codename, user_or_group, p)
                assigned_permissions.append(assigned_perm)
            # Tag the project
            p.tags.add(*tags)
            # Add stacks to project
            for s in stacks:
                trln = Double3D()
                ps = ProjectStack.objects.create(project=p,
                                                 stack=s,
                                                 translation=trln)
            # Make project persistent
            p.save()
            # Link classification graphs
            for cg in cls_graph_ids_to_link:
                workspace = settings.ONTOLOGY_DUMMY_PROJECT_ID
                cgroot = ClassInstance.objects.get(pk=cg)
                link_existing_classification(workspace, user, p, cgroot)
            # Remember created project
            imported.append(pp)
        except Exception as e:
            not_imported.append((pp, e))

    return (imported, not_imported)
コード例 #4
0
ファイル: importer.py プロジェクト: aschampion/CATMAID
def import_projects( user, pre_projects, tags, permissions,
    tile_width, tile_height, tile_source_type, cls_graph_ids_to_link ):
    """ Creates real CATMAID projects out of the PreProject objects
    and imports them into CATMAID.
    """
    imported = []
    not_imported = []
    for pp in pre_projects:
        try:
            # Create stacks and add them to project
            stacks = []
            for s in pp.stacks:
                stack = Stack.objects.create(
                    title=s.name,
                    dimension=s.dimension,
                    resolution=s.resolution,
                    image_base=s.image_base,
                    num_zoom_levels=s.num_zoom_levels,
                    file_extension=s.file_extension,
                    tile_width=tile_width,
                    tile_height=tile_height,
                    tile_source_type=tile_source_type,
                    metadata=s.metadata)
                stacks.append( stack )
                # Add overlays of this stack
                for o in s.overlays:
                    Overlay.objects.create(
                        title=o.name,
                        stack=stack,
                        image_base=o.image_base,
                        default_opacity=o.default_opacity,
                        file_extension=o.file_extension,
                        tile_width=tile_width,
                        tile_height=tile_height,
                        tile_source_type=tile_source_type)
            # Create new project
            p = Project.objects.create(
                title=pp.name)
            # Assign permissions to project
            assigned_permissions = []
            for user_or_group, perm in permissions:
                assigned_perm = assign( perm.codename, user_or_group, p )
                assigned_permissions.append( assigned_perm )
            # Tag the project
            p.tags.add( *tags )
            # Add stacks to project
            for s in stacks:
                trln = Double3D()
                ps = ProjectStack.objects.create(
                    project=p, stack=s, translation=trln)
            # Make project persistent
            p.save()
            # Link classification graphs
            for cg in cls_graph_ids_to_link:
                workspace = settings.ONTOLOGY_DUMMY_PROJECT_ID
                cgroot = ClassInstance.objects.get(pk=cg)
                link_existing_classification(workspace, user, p, cgroot)
            # Remember created project
            imported.append( pp )
        except Exception as e:
            not_imported.append( (pp, e) )

    return (imported, not_imported)