Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part1 of the class diagram written in python.
Part1 comprises the classes: - Project - Markup - Header - BimSnippet - DocumentReference - Topic - TopicConstraint with its subclasses - Topicstatus - TopicPriority - TopicType - TopicLabel - TopicStage - Modification - Comment - ViewpointReference - Uri
- Loading branch information
1 parent
1c34ad9
commit 31ef931
Showing
6 changed files
with
334 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
from uuid import UUID | ||
from datetime import datetime, date | ||
from uri import Uri | ||
from typing import List # used for custom type annotations | ||
from modification import Modification | ||
from topic import Topic, TopicConstraint | ||
|
||
class Header: | ||
def __init__(self, | ||
ifcProjectId: UUID = None, | ||
ifcSpacialStructureElement: UUID = None, | ||
external: bool = True, | ||
filename: str = "", | ||
time: datetime = None, | ||
reference: Uri = None): | ||
|
||
""" Initialization function for Header """ | ||
|
||
self.ifcProjectId = ifcProjectId | ||
self.ifcSpacialStructureElement = ifcSpacialStructureElement | ||
self.external = external | ||
self.filename = filename | ||
self.time = time | ||
self.reference = reference | ||
|
||
class DocumentReference: | ||
def __init__(self, | ||
id: UUID = None, | ||
external: bool = False, | ||
reference: Uri = None, | ||
description: str = ""): | ||
|
||
""" Initialization function for DocumentReference """ | ||
|
||
self.id = id | ||
self.external = external | ||
self.reference = reference | ||
self.description = description | ||
|
||
|
||
class SnippetType(TopicConstraint): | ||
|
||
""" | ||
This is not in the semantical sense a subclass of TopicConstraint, it | ||
rather uses the facilities it offers. I should then rename | ||
TopicConstraint in the future to not confuse the readers at this point | ||
""" | ||
|
||
def __init__(self): | ||
|
||
values = TopicConstraint.parseConstraints("SnippetType") | ||
super(TopicStatus, self).__init__(values[0], values) | ||
|
||
|
||
class BimSnippet: | ||
def __init__(self, | ||
type: SnippetType = None, | ||
external: bool = True, | ||
reference: Uri = None, | ||
schema: Uri = None): | ||
|
||
""" Initialization function for BimSnippet """ | ||
|
||
self.type = type | ||
self.external = external | ||
self.reference = reference | ||
self.schema = schema | ||
|
||
|
||
class ViewpointReference: | ||
|
||
""" Base class for Viewpoint. """ | ||
|
||
def __init__(self, | ||
file: Uri = None, | ||
snapshot: Uri = None, | ||
index: int = 0): | ||
|
||
""" Initialisation function of ViewpointReference """ | ||
|
||
self.file = file | ||
self.snapshot = snapshot | ||
self.index = index | ||
|
||
class Comment: | ||
|
||
""" Class holding all data about a comment """ | ||
|
||
def __init__(self, | ||
creation: Modification, | ||
comment: str, | ||
viewpoint: ViewpointReference = None, | ||
lastModification: Modification = None): | ||
|
||
""" Initialisation function of Comment """ | ||
|
||
self.creation = creation | ||
self.comment = comment | ||
self.viewpoint = viewpoint | ||
self.lastModification = lastModification | ||
|
||
|
||
class Markup: | ||
|
||
""" Every topic folder has exactly one markup.bcf file. This forms the | ||
starting point for the ui to get the data """ | ||
|
||
def __init__(self, | ||
header: Header = None, | ||
topic: List[Topic] = list(), | ||
bimSnippet: BimSnippet = None, | ||
docRefs: List[DocumentReference] = list(), | ||
relatedTopic: UUID = None, | ||
comments: List[Comment] = list(), | ||
viewpoints: List[ViewpointReference] = list(), | ||
snapshots: List[Uri] = list()): | ||
|
||
""" Initialization function for Markup """ | ||
|
||
self.header = header | ||
self.topic = topic | ||
self.bimSnippet = bimSnippet | ||
self.docRefs = docRefs | ||
self.relatedTopic = relatedTopic | ||
self.comments = comments | ||
self.viewpoints = viewpoints | ||
self.snapshots = snapshots | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from datetime import datetime | ||
|
||
class Modification: | ||
|
||
""" | ||
This class is used by Topic and Comment to for one denote the author | ||
and date of the last change and the creator and the creation date of an | ||
object of one of the respective classes | ||
""" | ||
|
||
def __init__(self, | ||
author: str, | ||
date: datetime): | ||
|
||
""" Initialisation function for Modification """ | ||
|
||
self.author = author | ||
self.date = date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from uri import Uri | ||
from uuid import UUID | ||
from markup import Markup | ||
|
||
class Project: | ||
def __init__(self, | ||
uuid: UUID = None, | ||
name: str = "", | ||
extSchemaSrc: Uri = None): | ||
self.id = uuid | ||
self.name = name | ||
self.extSchemaSrc = extSchemaSrc | ||
self.topicList = list() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
from typing import List | ||
from enum import Enum | ||
from uuid import UUID | ||
from modification import Modification | ||
from uri import Uri | ||
from datetime import date | ||
|
||
class TopicConstraint: | ||
|
||
""" | ||
Base class for | ||
- TopicStatus | ||
- TopicPriority | ||
- TopicType | ||
- TopicStage | ||
- TopicLabel | ||
This class is not supposed to be instantiated directly. The __init__ | ||
function of every subclass is supposed to parse the contents of the XML | ||
Schema Definition (XSD) file | ||
[extension.xsd](https://github.com/buildingSMART/BCF-XML/blob/master/Extension | ||
Schemas/extension.xsd) and instantiate this base class with a list of valid | ||
values. Every time the value is to be updated it is checked against the | ||
list of valid values, which shall not be writable to the outside, and set | ||
if the new value is in. | ||
""" | ||
|
||
def __init__(self, | ||
initialValue: str, | ||
validValues: str): | ||
self.validValues = validValues | ||
if initialValue in validValues: | ||
self.value = initialValue | ||
|
||
@property | ||
def validValues(self): | ||
return self.validValues | ||
|
||
@validValues.setter | ||
def validValues(self, values: List[str]): | ||
pass # validValues shall not be writable to the outside | ||
|
||
@property | ||
def value(self): | ||
return self.value | ||
|
||
@value.setter | ||
def value(self, newValue: str): | ||
|
||
""" Only sets if newValue is valid """ | ||
|
||
if newValue in self.__validValues: | ||
self.value = newValue | ||
|
||
@staticmethod | ||
def parseConstraints(self, elementName): | ||
|
||
""" Returns a list of the values specified in extensions.xsd for the | ||
element with the name `elementName`""" | ||
|
||
#TODO: write that function | ||
|
||
return [None] | ||
|
||
|
||
class TopicStatus(TopicConstraint): | ||
|
||
def __init__(self): | ||
|
||
""" | ||
First gets the valid values from extensions.xsd by calling the | ||
static method parseConstraints and then initializing the base class | ||
""" | ||
|
||
values = TopicConstraint.parseConstraints("TopicStatus") | ||
super(TopicStatus, self).__init__(values[0], values) | ||
|
||
|
||
class TopicType(TopicConstraint): | ||
|
||
def __init__(self): | ||
|
||
""" | ||
First gets the valid values from extensions.xsd by calling the | ||
static method parseConstraints and then initializing the base class | ||
""" | ||
|
||
values = TopicConstraint.parseConstraints("TopicType") | ||
super(TopicStatus, self).__init__(values[0], values) | ||
|
||
|
||
class TopicLabel(TopicConstraint): | ||
|
||
def __init__(self): | ||
|
||
""" | ||
First gets the valid values from extensions.xsd by calling the | ||
static method parseConstraints and then initializing the base class | ||
""" | ||
|
||
values = TopicConstraint.parseConstraints("TopicLabel") | ||
super(TopicStatus, self).__init__(values[0], values) | ||
|
||
|
||
class TopicStage(TopicConstraint): | ||
|
||
def __init__(self): | ||
|
||
""" | ||
First gets the valid values from extensions.xsd by calling the | ||
static method parseConstraints and then initializing the base class | ||
""" | ||
|
||
values = TopicConstraint.parseConstraints("Stage") | ||
super(TopicStatus, self).__init__(values[0], values) | ||
|
||
|
||
class TopicPriority(TopicConstraint): | ||
|
||
def __init__(self): | ||
|
||
""" | ||
First gets the valid values from extensions.xsd by calling the | ||
static method parseConstraints and then initializing the base class | ||
""" | ||
|
||
values = TopicConstraint.parseConstraints("Priority") | ||
super(TopicStatus, self).__init__(values[0], values) | ||
|
||
|
||
|
||
class Topic: | ||
|
||
""" Topic contains all metadata about one ... topic """ | ||
|
||
def __init__(self, | ||
id: UUID, | ||
title: str, | ||
creation: Modification, | ||
type: TopicType = None, | ||
status: TopicStatus = None, | ||
refs: List[Uri] = list(), | ||
priority: TopicPriority = None, | ||
index: int = 0, | ||
labels: List[str] = list(), | ||
lastModification: Modification = None, | ||
dueDate: date = None, | ||
assignee: str = "", | ||
description: str = "", | ||
stage: TopicStage = None): | ||
|
||
""" Initialisation function of Topic """ | ||
|
||
self.id = id | ||
self.title = title | ||
self.creation = creation | ||
self.type = type | ||
self.status = status | ||
self.refs = refs | ||
self.priority = priority | ||
self.index = index | ||
self.labels = labels | ||
self.lastModification = lastModification | ||
self.dueDate = dueDate | ||
self.assignee = assignee | ||
self.description = description | ||
self.stage = stage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
""" | ||
Wrapper class for a URI, maybe will get replaced by the uri module in the | ||
future | ||
""" | ||
class Uri: | ||
def __init__(self, uri: str): | ||
self.uri = uri |
Empty file.