Class VilleSubmission

java.lang.Object
studentrepoloader.model.villecsv.impl.VilleSubmission
All Implemented Interfaces:
Comparable<VilleSubmissionFields>, VilleSubmissionFields
Direct Known Subclasses:
GitLabSubmission

public class VilleSubmission extends Object implements VilleSubmissionFields
Default implementation of VilleSubmissionFields, based on the first five columns of a ViLLe CSV row.

This implementation assumes the input String[] contains exactly the core metadata fields in this order:

 User$First name$Last name$Time$Student number or other id code$
 

The corresponding indexes (0 to 4) must match this layout. Each method returns the raw value from that position, after basic validation and trimming. This class enforces lightweight sanitation rules:

  • getUser() must contain "@" and a dot after it (e.g., email)
  • getFirstName() and getLastName() must not contain numeric characters
  • getTime() must match the pattern yyyy-MM-dd
  • getStudentId() is not validated by default due to wide variation in formats

Extend this class and override getStudentId() if additional validation is required.

  • Field Details

    • villeCsvRow

      protected final String[] villeCsvRow
  • Method Details

    • getUser

      public String getUser()
      Returns the user identifier (typically an email address) from column 0.

      The value must contain both an @ and a . to be considered valid.

      Specified by:
      getUser in interface VilleSubmissionFields
      Returns:
      trimmed user email
      Throws:
      IllegalArgumentException - if the user string is malformed
    • getFirstName

      public String getFirstName()
      Returns the student's first name from column 1.

      Must not contain numeric characters.

      Specified by:
      getFirstName in interface VilleSubmissionFields
      Returns:
      trimmed first name
      Throws:
      IllegalArgumentException - if the name contains digits
    • getLastName

      public String getLastName()
      Returns the student's last name from column 2.

      Must not contain numeric characters.

      Specified by:
      getLastName in interface VilleSubmissionFields
      Returns:
      trimmed last name
      Throws:
      IllegalArgumentException - if the name contains digits
    • getTime

      public String getTime()
      Returns the submission timestamp from column 3.

      Must conform to the format yyyy-MM-dd, e.g., 2025-03-10.

      Specified by:
      getTime in interface VilleSubmissionFields
      Returns:
      validated timestamp string
      Throws:
      IllegalArgumentException - if the value is not a valid date
    • getStudentId

      public String getStudentId()
      Returns the student ID from column 4.

      This field is not validated by default due to wide variation in formats, including numeric IDs and Finnish-style OIDs. Implementations may override this method if stricter validation is needed.

      Specified by:
      getStudentId in interface VilleSubmissionFields
      Returns:
      trimmed student ID
    • getParentFolderName

      public String getParentFolderName()
      Returns the base folder name used to group this submission under an outer task-level directory.

      In this implementation, the parent folder name is derived from the filename of the original ViLLe CSV export this submission was parsed from. Specifically, it strips the file extension from viLLeCsvFile.getVilleCsvFile().getName() to use as a stable identifier for grouping.

      This ensures that all submissions originating from the same export file are grouped under a consistent folder name, which is ideal for constructing deterministic output structures like:

       clones/
       └── Tehtävä_1.1_05092025_08_22_PM/
           ├── antti15_Esimerkki_Antti/
           └── ...
       

      This method is called by SubmissionCloner or any other system component that requires layout information when rendering student submissions to disk.

      Specified by:
      getParentFolderName in interface VilleSubmissionFields
      Returns:
      the original CSV filename without extension, used as parent folder name
    • getViLLeCsvFile

      public ViLLeCsvFile getViLLeCsvFile()
      Returns:
      ViLLeCsvFile object associated with this submission object.
    • getVilleCsvRow

      public String[] getVilleCsvRow()
      Returns:
      The original array used to construct this object.
    • toString

      public String toString()
      Overrides:
      toString in class Object