Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HARMONY-experimental-branch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robin Korfmann
HARMONY-experimental-branch
Commits
742718fc
Commit
742718fc
authored
1 month ago
by
Cecile Ntsama
Browse files
Options
Downloads
Patches
Plain Diff
enhance Project model and validation
parent
c3e4dadb
No related branches found
No related tags found
1 merge request
!4
merge dev to main
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Project/model.go
+168
-0
168 additions, 0 deletions
src/Project/model.go
with
168 additions
and
0 deletions
src/Project/model.go
0 → 100644
+
168
−
0
View file @
742718fc
package
project
import
(
"time"
"github.com/google/uuid"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// Project represents the main project entity stored in MongoDB
// This struct defines the complete data structure for a project including
// metadata fields for tracking creation and modification times
type
Project
struct
{
// ID is the unique MongoDB ObjectID that serves as the primary key
// The omitempty tag excludes this field if it's empty during insertion
ID
primitive
.
ObjectID
bson
:
"_id,omitempty"
json
:
"id"
// ProjectID is a human-readable unique identifier (e.g., "PRJ-2025-001")
// This allows users to reference projects with meaningful IDs
ProjectID
string
bson
:
"project_id"
json
:
"projectId"
// Name is the display name of the project (e.g., "HARMONY Mobile")
// This is what users see in the interface as the project title
Name
string
bson
:
"name"
json
:
"name"
// Description provides detailed information about the project's purpose
// This field is optional and can be empty for simple projects
Description
string
bson
:
"description"
json
:
"description"
// StartDate defines when the project begins
// Used for project timeline calculations and reporting
StartDate
time
.
Time
bson
:
"start_date"
json
:
"startDate"
// EndDate defines when the project is scheduled to complete
// Must be after StartDate as enforced by business logic
EndDate
time
.
Time
bson
:
"end_date"
json
:
"endDate"
// CreatedBy stores the UUID of the user who created this project
// This establishes ownership and is used for access control
CreatedBy
uuid
.
UUID
bson
:
"created_by"
json
:
"createdBy"
// CreatedAt records when this project was first created
// Automatically set during project creation for audit trails
CreatedAt
time
.
Time
bson
:
"created_at"
json
:
"createdAt"
// UpdatedAt tracks the last modification time
// Uses pointer to allow nil values when no updates have occurred
// The omitempty tag excludes this field if it's nil
UpdatedAt
*
time
.
Time
bson
:
"updated_at,omitempty"
json
:
"updatedAt,omitempty"
}
// ProjectToCreate represents the data structure used when creating new projects
// This struct contains only the fields that users can specify during creation
// System-generated fields like ID and timestamps are handled separately
type
ProjectToCreate
struct
{
// ProjectID must be provided by the user and must be unique
// Validation ensures this field is not empty
ProjectID
string
json
:
"projectId"
hvalidate
:
"required"
// Name is required and serves as the display title
// Validation ensures this field is not empty
Name
string
json
:
"name"
hvalidate
:
"required"
// Description is optional and can be left empty
// No validation constraints are applied to this field
Description
string
json
:
"description"
// StartDate is required and must be a valid date
// Validation ensures this field is provided
StartDate
time
.
Time
json
:
"startDate"
hvalidate
:
"required"
// EndDate is required and must be after StartDate
// Basic validation ensures this field is provided
// Business logic validation ensures it's after StartDate
EndDate
time
.
Time
json
:
"endDate"
hvalidate
:
"required"
// CreatedBy is set by the system based on the current user
// The - tag excludes this from JSON serialization as it's not user input
CreatedBy
uuid
.
UUID
json
:
"-"
}
// ProjectToUpdate represents the data structure used when updating existing projects
// This struct includes the project ID to identify which project to update
// Note: ProjectID is not included as it cannot be changed after creation
type
ProjectToUpdate
struct
{
// ID identifies which project to update using the MongoDB ObjectID
// This field is populated from the URL parameter
ID
primitive
.
ObjectID
bson
:
"_id"
json
:
"id"
// Name can be updated and is required to be non-empty
// Users can change the display name of their projects
Name
string
json
:
"name"
hvalidate
:
"required"
// Description can be updated and can be empty
// Users can modify or clear the project description
Description
string
json
:
"description"
// StartDate can be updated but must remain valid
// Users can adjust project timelines as needed
StartDate
time
.
Time
json
:
"startDate"
hvalidate
:
"required"
// EndDate can be updated but must remain after StartDate
// Business logic validation ensures timeline consistency
EndDate
time
.
Time
json
:
"endDate"
hvalidate
:
"required"
}
// ToUpdate converts a Project instance to a ProjectToUpdate structure
// This method is useful when pre-filling edit forms with existing project data
// It extracts only the fields that can be modified during updates
func
(
p
*
Project
)
ToUpdate
()
*
ProjectToUpdate
{
return
&
ProjectToUpdate
{
ID
:
p
.
ID
,
// Preserve the project identifier
Name
:
p
.
Name
,
// Current name as default
Description
:
p
.
Description
,
// Current description as default
StartDate
:
p
.
StartDate
,
// Current start date as default
EndDate
:
p
.
EndDate
,
// Current end date as default
}
}
// ProjectWithRequirements represents a project along with its associated requirements
// This structure is used for project detail views where both project information
// and requirement summaries need to be displayed together
type
ProjectWithRequirements
struct
{
// Embed the base Project struct to inherit all project fields
// This allows access to all project properties directly
*
Project
// Requirements contains summary information for all requirements in this project
// This is optimized for display purposes rather than full requirement details
Requirements
[]
*
RequirementSummary
json
:
"requirements"
// RequirementCount provides a quick count of total requirements
// This avoids the need to calculate len(Requirements) in templates
RequirementCount
int
json
:
"requirementCount"
}
// RequirementSummary provides essential requirement information for project views
// This structure contains only the fields needed for requirement lists and summaries
// Full requirement details would be loaded separately when viewing individual requirements
type
RequirementSummary
struct
{
// ID is the unique MongoDB ObjectID for this requirement
// Used for linking to detailed requirement views
ID
primitive
.
ObjectID
bson
:
"_id"
json
:
"id"
// RequirementID is a human-readable identifier for this requirement
// Generated automatically if not provided (e.g., "REQ-abc123")
RequirementID
string
bson
:
"requirement_id"
json
:
"requirementId"
// Condition describes the circumstances under which this requirement applies
// This field comes from the requirement parsing and validation process
Condition
string
bson
:
"condition"
json
:
"condition"
// System identifies which system or component this requirement affects
// This helps organize requirements by their target systems
System
string
bson
:
"system"
json
:
"system"
// Requirement contains the actual requirement text
// This is the main content that describes what must be implemented
Requirement
string
bson
:
"requirement"
json
:
"requirement"
// Status tracks the current state of this requirement
// Possible values include "Entwurf", "In Prüfung", "Genehmigt", "Abgelehnt"
Status
string
bson
:
"status"
json
:
"status"
// CreatedAt records when this requirement was first created
// Used for sorting and audit purposes
CreatedAt
time
.
Time
bson
:
"created_at"
json
:
"createdAt"
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment