Ejemplo n.º 1
0
    def create(cls, data, session):
        new_data = cls()

        new_data.annotation = Annotation.create(data)
        new_data.disambiguation = Disambiguation.create(data)
        new_data.identifiers = create_identifiers(data)
        new_data.aliases, default_alias = create_aliases(data)

        if default_alias is not None:
            new_data.default_alias = default_alias

        return new_data
Ejemplo n.º 2
0
    def update(self, data, session):
        # Create a new EntityData, copying the current data.
        new_data = self.copy()

        if self.annotation is not None:
            new_data.annotation = self.annotation.update(data)
        else:
            new_data.annotation = Annotation.create(data)

        if self.disambiguation is not None:
            new_data.disambiguation = self.disambiguation.update(data)
        else:
            new_data.disambiguation = Disambiguation.create(data)

        new_data.identifiers =\
            update_identifiers(self.identifiers, data)

        new_data.aliases, default_alias =\
            update_aliases(self.aliases, self.default_alias_id, data)

        if default_alias is not None:
            new_data.default_alias = default_alias

        return new_data