Ejemplo n.º 1
0
    def create(cls, user=None, type=None, workflow_object=None):
        """
        Create a new deposition object.

        To persist the deposition, you must call save() on the created object.
        If no type is defined, the default deposition type will be assigned.

        @param user: The owner of the deposition
        @param type: Deposition type identifier.
        """
        if user is not None:
            user = user.get_id()

        if workflow_object:
            sip = SubmissionInformationPackage(metadata=workflow_object.data)
            workflow_object.data = {
                "sips": [sip.__getstate__()],
                "files": [],
                "title": "",
                "drafts": {},
                "type": type,
            }
            workflow_object.set_data(workflow_object.data)
            workflow_object.save()

        # Note: it is correct to pass 'type' and not 't' below to constructor.
        obj = cls(workflow_object=workflow_object, type=type, user_id=user)
        return obj
Ejemplo n.º 2
0
    def create(cls, user=None, type=None, workflow_object=None):
        """Create a new payload object."""
        if user is not None:
            user = user.get_id()

        if workflow_object:
            sip = SubmissionInformationPackage(metadata=workflow_object.data)
            workflow_object.data = {
                "sips": [sip.__getstate__()],
                "files": [],
                "title": "",
                "drafts": {},
                "type": type,
            }
            workflow_object.set_data(workflow_object.data)
            if workflow_object.id is None:
                workflow_object.save()

        # Note: it is correct to pass 'type' and not 't' below to constructor.
        obj = cls(workflow_object=workflow_object, type=type, user_id=user)
        return obj