Documentation ¶
Index ¶
- Variables
- func AreSequential(a, b Revision) (minor, major bool)
- func HeaderCodesEqual(a, b Header) bool
- func HeadersEqual(a, b Header) bool
- func ParseDocumentCodes(documentName string) (project, equipment, docType string)
- func ParseDocumentName(docName string) (Header, Revision, error)
- type DocInfo
- type Family
- type Header
- type HeaderFilter
- type Model
- type Project
- func (p *Project) AddEquipmentCode(code, name, description string) error
- func (p *Project) AddFamily(sys byte, family Family) error
- func (p *Project) AddSystem(sys System) error
- func (p *Project) AddType(sys, family byte, tp Type) error
- func (p Project) ContainsCode(hd Header) bool
- func (p Project) Project() string
- func (p Project) String() string
- type Revision
- type System
- type Type
- type Variant
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidNumber = fmt.Errorf("QAP number out of range 0..%d", maxDocumentNumber) ErrEmptyProjectCode = errors.New("zero length project code") ErrEmptyEquipmentCode = errors.New("zero length equipment code") ErrEmptyDocumentTypeCode = errors.New("zero length document type code") ErrEmptyAttachmentNumber = errors.New("zero length attachment number") ErrBadProjectCode = fmt.Errorf("project code must be %d upper case characters", lenP) ErrBadEquipmentCode = fmt.Errorf("equipment code must be 1..%d digits or/and upper case characters", lenE) ErrBadDocumentTypeCode = fmt.Errorf("document type code must be 1..%d upper case characters", lenDT) ErrBadAttachmentNumber = fmt.Errorf("attachment number must be 2 digits in range 0..%d", maxAttachmentNumber) ErrZeroTime = errors.New("creation/revision time is zero") ErrBadRevisionIndex = errors.New("revision index must be two digits or an upper case character followed by a digit") )
Functions ¶
func AreSequential ¶
AreSequential tests whether b follows a as a revision, indicating whether the increment between the two revisions is
- A minor revision, which can be either
- A draft to release increment (i.e. A.1-draft -> A.1)
- A minor index increment (i.e. C.2 -> C.3 or C.2 -> C.3-draft)
- A major revision (i.e. A.3 -> B.1 or A.3 -> B.1-draft)
It returns false for both minor and major if revisions are not in ascending order, they are not a single increment apart or if they are invalid revisions.
func HeaderCodesEqual ¶
HeaderCodesEqual tests project, equipment and document type codes of a and b are the same. If either a or b are invalid then HeaderCodesEqual returns false.
func HeadersEqual ¶
HeadersEqual tests headers for complete equality. If either a or b are invalid then HeadersEqual returns false.
func ParseDocumentCodes ¶
ParseDocumentCodes is a helper function to extract document codes from human input.
func ParseDocumentName ¶
ParseDocumentName parses a full document name of the style "LHC-PM-QA-202.00 rev B.2" and returns the corresponding header.
If there is no " rev " text in the string the header is parsed and a new A.1 revision is returned.
Types ¶
type DocInfo ¶
type DocInfo struct { Header Revision Revision // Time document was created. Creation time.Time // Time revision index was last incremented. RevisionTime time.Time }
DocInfo defines a document's type, naming and revision as specified by CERN's Quality Assurance Plan along with some helper data relating to time.
type Family ¶
Family represents the second letter of the equipment code. It defines the family of the equipment within a given system.
type Header ¶
type Header struct { // A user or system controlled number or a combination thereof. // Is 3 to 6 digits long. Referred to as EDMS number in QAP202. Number int32 // Composed of 3 upper case characters ProjectCode [3]byte // Composed of 1 to 5 alphanumeric characters. EquipmentCode [5]byte // DocumentTypeCode identifies the purpose of the document. // Composed of 2 upper case characters. DocumentTypeCode [2]byte // For material attached to main document. The main document's attachment // number is 0. AttachmentNumber uint8 }
Header represents a unique document name according to LHC's Quality Assurance Plan (QAP). The API is designed so that the Header is immutable through method calls, thus only direct access by the user to its fields should mutate the underlying data.
func ParseHeader ¶
ParseHeader parses a complete unversioned QAP document string of the style "SPS-PEC-HP-0023.01". The attachment number parsing may be omitted by setting ignoreAttachment to true setting attachment result to 0.
This function is very careful of the input and will more readily return an error before forming a valid Header from ambiguous or unexpected input.
func (Header) DocumentType ¶
DocumentType returns a valid QAP document type code string or an empty string.
type HeaderFilter ¶
type HeaderFilter struct {
// contains filtered or unexported fields
}
HeaderFilter is an in-memory header filtering structure optimized for common search patterns.
func NewHeaderFilter ¶
func NewHeaderFilter(headers []Header) HeaderFilter
NewHeaderFilter initializes a HeaderFilter with headers data.
func (*HeaderFilter) AddHeader ¶
func (hf *HeaderFilter) AddHeader(h Header) error
AddHeader adds a header to the filter.
func (*HeaderFilter) Has ¶
func (hf *HeaderFilter) Has(h Header) bool
func (*HeaderFilter) HumanQuery ¶
func (hf *HeaderFilter) HumanQuery(dst []Header, query string, page int) (n, totalFound int)
HumanQuery queries filter for n matches which are stored in dst. The total amount of matches found is totalFound.
func (*HeaderFilter) Len ¶
func (hf *HeaderFilter) Len() int
Len returns the amount of headers contained in filter.
type Project ¶
type Project struct { Code [3]byte // Project name (3 letters) Systems []System Name string Description string }
Project represents the overlying project structure as outlined by LHC-PM-QA-202 and LHC-PM-QA-204.
func (*Project) AddEquipmentCode ¶
func (Project) ContainsCode ¶
ContainsCode returns true if header equipment code and project code exist inside the project structure. Does not check for validity of entire Header.
type Revision ¶
type Revision struct { // Index is the document revision index and is // composed by two digits separated by a dot (or alphanumeric characters). Index [2]byte IsRelease bool }
Revision holds version code information of a document.
When registered new documents should be given revision index A.1 and a non released status.
Prior to release, new revisions of draft documents are given the revision index A.1, A.2, A.3 and so on.
In the case of a minor change only the second digit/character of the revision index is incremented, for example from C.0 to C.1 or B.3 to B.4.
In the case of a major change the first digit of the revision index is incremented while the second is set to 0. (or A if using alphanumeric revision index) Example:
A.4 -> B.0
func NewRevision ¶
func NewRevision() Revision
NewRevision returns the first version draft revision "A.1-draft".
func ParseRevision ¶
ParseRevision creates a Revision from a formatted string i.e. "B.3-draft", "A.1"
func (Revision) IncrementMajor ¶
IncrementMajor returns the DocInfo with it's major version incremented by one and IsReleased field set to isRelease argument.
func (Revision) IncrementMinor ¶
IncrementMinor returns the DocInfo with it's minor version incremented by one and IsReleased field set to isRelease argument.
type System ¶
System represents the first letter of the equipment code, which indicates the system to which the equipment belongs.