Example #1
0
 def create_specifier(
         self,
         item: Persistence.PersistentObject,
         *,
         allow_partial: bool = True
 ) -> Persistence.PersistentObjectSpecifier:
     if item.project == self and allow_partial:
         return Persistence.PersistentObjectSpecifier(item=item)
     else:
         return Persistence.PersistentObjectSpecifier(item=item,
                                                      context=item.project)
Example #2
0
def get_object_specifier(
    object: typing.Optional[Persistence.PersistentObject],
    object_type: typing.Optional[str] = None,
    project: typing.Optional[Project.Project] = None
) -> typing.Optional[Persistence.PersistentDictType]:
    # project is passed for testing only
    if isinstance(object, DataItem.DataItem):
        specifier = Persistence.PersistentObjectSpecifier(object.uuid)
        specifier_uuid = specifier.item_uuid if specifier else object.uuid
        d = {
            "version": 1,
            "type": object_type or "data_item",
            "uuid": str(specifier_uuid)
        }
        return d
    if object and object_type in ("xdata", "display_xdata", "cropped_xdata",
                                  "cropped_display_xdata", "filter_xdata",
                                  "filtered_xdata"):
        assert isinstance(object, DisplayItem.DisplayDataChannel)
        specifier = Persistence.PersistentObjectSpecifier(object.uuid)
        specifier_uuid = specifier.item_uuid if specifier else object.uuid
        d = {"version": 1, "type": object_type, "uuid": str(specifier_uuid)}
        return d
    if isinstance(object, DisplayItem.DisplayDataChannel):
        # should be "data_source" but requires file format change
        specifier = Persistence.PersistentObjectSpecifier(object.uuid)
        specifier_uuid = specifier.item_uuid if specifier else object.uuid
        d = {"version": 1, "type": "data_source", "uuid": str(specifier_uuid)}
        return d
    elif isinstance(object, Graphics.Graphic):
        specifier = Persistence.PersistentObjectSpecifier(object.uuid)
        specifier_uuid = specifier.item_uuid if specifier else object.uuid
        d = {"version": 1, "type": "graphic", "uuid": str(specifier_uuid)}
        return d
    elif isinstance(object, DataStructure):
        specifier = Persistence.PersistentObjectSpecifier(object.uuid)
        specifier_uuid = specifier.item_uuid if specifier else object.uuid
        d = {"version": 1, "type": "structure", "uuid": str(specifier_uuid)}
        return d
    elif isinstance(object, DisplayItem.DisplayItem):
        specifier = Persistence.PersistentObjectSpecifier(object.uuid)
        specifier_uuid = specifier.item_uuid if specifier else object.uuid
        d = {"version": 1, "type": "display_item", "uuid": str(specifier_uuid)}
        return d
    return None
Example #3
0
 def create_specifier(
     self, item: Persistence.PersistentObject
 ) -> Persistence.PersistentObjectSpecifier:
     return Persistence.PersistentObjectSpecifier(item=item)
Example #4
0
 def item_specifier(self) -> Persistence.PersistentObjectSpecifier:
     return Persistence.PersistentObjectSpecifier(item_uuid=self.uuid)
Example #5
0
 def item_specifier(self) -> Persistence.PersistentObjectSpecifier:
     return Persistence.PersistentObjectSpecifier(
         item_uuid=self.uuid, context_uuid=self.profile.uuid)