Exemple #1
0
    def derive_prototype(instance):
        """Derives a prototype for the given attribute. This prototype attribute
        will be equal in all respects, expect for the value of the attribute.
        This value will be set to a default value, depending on the specific
        type of the given attribute.

        :param instance: Attribute to derive prototype from.
        :type instance: `XAttribute`
        :return: The derived prototype attribute.
        :rtype: `XAttribute`
        """
        prototype = instance.clone()

        if not isinstance(prototype, XAttributeList) and not isinstance(prototype, XAttributeContainer):
            if isinstance(prototype, XAttributeLiteral):
                prototype.set_value("UNKNOWN")
            elif isinstance(prototype, XAttributeBoolean):
                prototype.set_value(True)
            elif isinstance(prototype, XAttributeContinuous):
                prototype.set_value(0.0)
            elif isinstance(prototype, XAttributeDiscrete):
                prototype.set_value(0)
            elif isinstance(prototype, XAttributeTimestamp):
                prototype.set_value_millies(0)
            elif isinstance(prototype, XAttributeID):
                prototype.set_value(XIDFactory().create_id())
            else:
                raise TypeError("Unexpected attribute type!")

        return prototype
Exemple #2
0
 def __init__(self, attributes=None, identity=None):
     if not attributes:
         attributes = XAttributeMap()
     if identity:
         self.__id = identity
     else:
         self.__id = XIDFactory.create_id()
     super().__init__(attributes)
Exemple #3
0
    def clone(self):
        """Clones this event, i.e. creates a deep copy, but with a new ID, so
        equals does not hold between this and the clone

        :return: An identical clone.
        :rtype: `XExtendedEvent`
        """
        aux = XExtendedEvent(self.__original.clone())
        aux._XExtendedEvent__id = XIDFactory.create_id()
        return aux
Exemple #4
0
    def clone(self):
        """Creates and returns a copy of this object.

        :return: A clone of this instance.
        :rtype: XEvent
        """
        clone = XEvent()
        clone.set_attributes(self.get_attributes().clone())
        clone.set_id(XIDFactory.create_id())
        return clone
Exemple #5
0
 def __init__(self):
     super().__init__("Identity", "identity", urlparse("http://www.xes-standard.org/identity.xesext"))
     factory = XFactoryRegistry().current_default()
     self.ATTR_ID = factory.create_attribute_id("identity:id", XIDFactory.create_id(), self)
     self.get_log_attributes().add(self.ATTR_ID.clone())
     self.get_trace_attributes().add(self.ATTR_ID.clone())
     self.get_event_attributes().add(self.ATTR_ID.clone())
     self.get_meta_attributes().add(self.ATTR_ID.clone())
     XGlobalAttributeNameMap().register_mapping("EN", "identity:id", "Identity")
     XGlobalAttributeNameMap().register_mapping("DE", "identity:id", "Identität")
     XGlobalAttributeNameMap().register_mapping("FR", "identity:id", "Identité")
     XGlobalAttributeNameMap().register_mapping("ES", "identity:id", "Identidad")
     XGlobalAttributeNameMap().register_mapping("PT", "identity:id", "Identidade")
    def __init__(self):
        super().__init__("Micro", "micro",
                         urlparse("http://www.xes-standard.org/micro.xesext"))
        factory = XFactoryRegistry().current_default()

        self.ATTR_LEVEL = factory.create_attribute_discrete(
            "micro:level", -1, self)
        self.ATTR_PID = factory.create_attribute_id("micro:parentId",
                                                    XIDFactory.create_id(),
                                                    self)
        self.ATTR_LENGTH = factory.create_attribute_discrete(
            "micro:length", -1, self)

        self.get_event_attributes().add(self.ATTR_LEVEL.clone())
        self.get_event_attributes().add(self.ATTR_PID.clone())
        self.get_event_attributes().add(self.ATTR_LENGTH.clone())

        XGlobalAttributeNameMap().register_mapping(
            "EN", "micro:level", "Micro level of this event")
        XGlobalAttributeNameMap().register_mapping(
            "EN", "micro:parentId", "Id of parent event of this event")
        XGlobalAttributeNameMap().register_mapping(
            "EN", "micro:length", "Number of child events for this event")
Exemple #7
0
 def __init__(self, event):
     self.__original = event
     self.__id = XIDFactory.create_id()
            # Generate random attribute
            option = random.choice([
                "string", "date", "int", "float", "boolean", "id", "list",
                "container"
            ])
            if option == "string":
                attribute = XFactory.create_attribute_literal(
                    option, "UNKNOWN")
            elif option == "date":
                attribute = XFactory.create_attribute_timestamp(option, 0)
            elif option == "int":
                attribute = XFactory.create_attribute_discrete(option, 0)
            elif option == "float":
                attribute = XFactory.create_attribute_continuous(option, 0.0)
            elif option == "boolean":
                attribute = XFactory.create_attribute_boolean(option, True)
            elif option == "id":
                attribute = XFactory.create_attribute_id(
                    option, XIDFactory.create_id())
            elif option == "list":
                attribute = XFactory.create_attribute_list(option)
            else:
                attribute = XFactory.create_attribute_container(option)
            event.get_attributes()[option] = attribute
        trace.append(event)
    log.append(trace)

# Save the random log in .xes format
with open("xes_file/random_log.xes", "w") as file:
    XesXmlSerializer().serialize(log, file)
        def startElement(self, name, attributes):
            """ Overrides startElement in class ContentHandler

            :param name:  Contains the raw XML 1.0 name of the element type
            :type name: str
            :param attributes: An instance of the Attributes class containing
             the attributes of the element
            :type attributes: xml.sax.xmlreader.AttributesImpl
            """
            tag_name = name

            if tag_name.lower() == "xesextension":
                mapping = attributes.getValue("name")
                name = attributes.getValue("prefix")
                x_uri = parse.urlparse(attributes.getValue("uri"))
                try:
                    request.urlopen(attributes.getValue("uri"))
                except error.URLError:
                    return

                self.__extension = XExtension(mapping, name, x_uri)

            elif tag_name.lower() == "log":
                self.__xAttributes = self.__extension.get_log_attributes()
            elif tag_name.lower() == "trace":
                self.__xAttributes = self.__extension.get_trace_attributes()
            elif tag_name.lower() == "event":
                self.__xAttributes = self.__extension.get_event_attributes()
            elif tag_name.lower() == "meta":
                self.__xAttributes = self.__extension.get_meta_attributes()

            elif tag_name.lower() == "string":
                self.__xAttributes = self.__extension.get_log_attributes()
                mapping = self.__extension.get_prefix(
                ) + ':' + attributes.getValue("key")
                self.__currentAttribute = self.__factory.create_attribute_literal(
                    mapping, "DEFAULT", self.__extension)
                self.__xAttributes.add(self.__currentAttribute)

            elif tag_name.lower() == "date":
                self.__xAttributes = self.__extension.get_log_attributes()
                mapping = self.__extension.get_prefix(
                ) + ':' + attributes.getValue("key")
                self.__currentAttribute = self.__factory.create_attribute_timestamp(
                    mapping, 0, self.__extension)
                self.__xAttributes.add(self.__currentAttribute)

            elif tag_name.lower() == "int":
                self.__xAttributes = self.__extension.get_log_attributes()
                mapping = self.__extension.get_prefix(
                ) + ':' + attributes.getValue("key")
                self.__currentAttribute = self.__factory.create_attribute_discrete(
                    mapping, 0, self.__extension)
                self.__xAttributes.add(self.__currentAttribute)

            elif tag_name.lower() == "float":
                self.__xAttributes = self.__extension.get_log_attributes()
                mapping = self.__extension.get_prefix(
                ) + ':' + attributes.getValue("key")
                self.__currentAttribute = self.__factory.create_attribute_continuous(
                    mapping, 0.0, self.__extension)
                self.__xAttributes.add(self.__currentAttribute)

            elif tag_name.lower() == "boolean":
                self.__xAttributes = self.__extension.get_log_attributes()
                mapping = self.__extension.get_prefix(
                ) + ':' + attributes.getValue("key")
                self.__currentAttribute = self.__factory.create_attribute_boolean(
                    mapping, False, self.__extension)
                self.__xAttributes.add(self.__currentAttribute)

            elif tag_name.lower() == "id":
                self.__xAttributes = self.__extension.get_log_attributes()
                mapping = self.__extension.get_prefix(
                ) + ':' + attributes.getValue("key")
                self.__currentAttribute = self.__factory.create_attribute_id(
                    mapping, XIDFactory.create_id(), self.__extension)
                self.__xAttributes.add(self.__currentAttribute)

            elif self.__currentAttribute is not None and tag_name.lower(
            ) == "alias":
                mapping = attributes.getValue("mapping")
                name = attributes.getValue("name")
                XGlobalAttributeNameMap().register_mapping(
                    mapping, self.__currentAttribute.get_key(), name)