Package com.simplicite.util
Class Timesheet
- java.lang.Object
-
- com.simplicite.util.Timesheet
-
- All Implemented Interfaces:
java.io.Serializable
public class Timesheet extends java.lang.Object implements java.io.Serializable
Timesheet definition and instance- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Timesheet.GanttBlock
Assignment element as a floating blockclass
Timesheet.GanttNode
Node of resource with blocksclass
Timesheet.TimesheetLine
Timesheet line between 2 resources
-
Field Summary
Fields Modifier and Type Field Description static int
GANTT_FORWARD
Add a link to Gantt view in the timesheet viewstatic int
GANTT_HIDDEN
Hide Gantt access in the timesheet viewstatic int
GANTT_INLINED
Inline Gantt display in the timesheet viewint
m_showGanttInTimesheet
static int
PERIOD_DAY_SIZE
Minimum size of period in daysstatic int
PERIOD_MONTH_SIZE
Minimum size of period in monthsstatic int
PERIOD_WEEK_SIZE
Minimum size of period in weeksstatic char
TYPE_DAY
Manage inputs by daysstatic char
TYPE_MONTH
Manage inputs by monthsstatic char
TYPE_WEEK
Manage inputs by weeks
-
Constructor Summary
Constructors Constructor Description Timesheet(ObjectDB assign, java.lang.String id, java.lang.String name, char type, boolean flying, boolean backward, java.lang.String ref1, java.lang.String ref2, java.lang.String workloadField, java.lang.String beginDateField, java.lang.String endDateField, java.lang.String statusField, boolean chartRes, boolean chartGantt, int showGantt, boolean dragX, boolean dragY, boolean resizable)
Timesheet definition
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInputField(java.lang.String name, Grant g)
Add an input field in the timesheet.void
buildCurrentPeriod(java.lang.String begin, java.lang.String end)
Build the current period to displayTimesheet.GanttNode
buildGanttData(Parameters params)
java.util.List<java.lang.String[]>
buildPeriod(java.lang.String begin, java.lang.String end)
Return a period between 2 datesboolean
canShiftField(int fieldIndex)
Shift the field charges when its GanttBlock moves (from copiable property of field) ?java.lang.String
convertDateToKey(java.lang.String date)
Convert a date to its keydouble[]
convertInputToMonthCharges(java.lang.String encodedInput)
Convert the encoded input into 12 months of charges (TYPE_DAYS and TYPE_WEEK only)java.lang.String
convertKeyToDate(java.lang.String key)
Convert a key to its datevoid
enableGanttDragX(boolean b)
void
enableGanttDragY(boolean b)
void
enableGanttResizable(boolean b)
void
filterParams(ObjectDB assign, Parameters params)
void
fitPeriodToAssignments(Parameters params)
Period including all assignments periodsvoid
fitPeriodToInputs()
Change the current period to include all timesheet inputs for the current resourcesjava.lang.String
ganttDataToJson(Parameters params)
Serialize to JSON the GANTTjava.lang.String
getCurrentColor(java.lang.String label)
Get the color of a resourceObjectField
getCurrentEndDate()
Current end date to displayjava.util.List<Timesheet.TimesheetLine>
getCurrentLines()
Current timesheet linesjava.util.List<java.lang.String[]>
getCurrentPeriod()
Current period to displayjava.lang.String
getCurrentResource1()
Current parent resource 1 (null when 2 is set)java.lang.String
getCurrentResource2()
Current parent resource 2 (null when 1 is set)ObjectField
getCurrentStartDate()
Current first date to displayObjectField
getFieldBeginDate()
Get the begin date fieldObjectField
getFieldEndDate()
Get the end date fieldObjectField
getFieldResource1()
Get the resource1 fieldObjectField
getFieldResource2()
Get the resource2 fieldObjectField
getFieldStatus()
Get the timesheet status fieldObjectField
getFieldWorkload()
Get the workload fieldTimesheet.GanttNode
getGanttData()
GANTT treejava.util.Map<ObjectDB,java.util.LinkedHashMap<java.lang.String,java.util.HashMap<java.lang.String,Timesheet.GanttNode>>>
getGanttFilters()
GANTT filters: Object in hierarchy => list of UK Label => list of id => Nodejava.lang.String
getId()
Timesheet idObjectField
getInputField(java.lang.String name)
Input field by namejava.util.List<ObjectField>
getInputFields()
Input fields for each linejava.lang.String[]
getInputMinMaxDates()
Get the period including all timesheet inputs for the current resourcesjava.lang.String
getName()
Timesheet nameObjectDB
getObjectAssign()
Get the assignment objectObjectDB
getObjectResource1(Grant g)
ObjectDB
getObjectResource2(Grant g)
ObjectDB
getObjectTimesheet()
Get the timesheet object to store inputsjava.util.List<java.lang.String[]>
getResources(boolean resetFilter, java.lang.String resourceId1, java.lang.String resourceId2, java.lang.String beginDate, java.lang.String endDate)
Retrieve resources from the otherdouble
getResourceWorkloadFactor(java.lang.String name)
java.util.Map<java.lang.String,Timesheet.TimesheetLine>
getTimesheet(boolean resetFilter, boolean inPeriod)
Load timesheet from DBjava.util.Map<java.lang.String,Timesheet.TimesheetLine>
getTimesheet(ObjectDB assign, ObjectField r1, ObjectField r2, java.lang.String resId1, java.lang.String resId2, ObjectField d1, ObjectField d2, boolean resetFilter, boolean loadLabel, boolean inPeriod, java.lang.String fromKey, java.lang.String toKey)
char
getType()
get the timesheet type : TYPE_DAY, TYPE_WEEK or TYPE_MONTHboolean
isBackwardInputAllowed()
Allows change for old inputs ?boolean
isChartEnabled()
Use resource chart ?boolean
isChartVisible()
Is resource chart visible ?boolean
isFlying()
Floating timesheet = starts period on any dayboolean
isGanttDragXEnabled()
Is the horizontal drag allowed ?boolean
isGanttDragYEnabled()
Is the vertical drag allowed ?boolean
isGanttEnabled()
Is the GANTT chart enabled ?boolean
isGanttResizable()
Is the block resizing allowed ?boolean
isGanttVisible()
Is the GANTT chart visible ?boolean
isInputAllowed(java.lang.String key, java.lang.String assignId, java.lang.String resId1, java.lang.String resId2)
Allows change for a period key ? Default is based on the backward inputboolean
isResourceAndInputSwapped()
boolean
isTimesheetEnabled()
Use timesheet input form ?java.util.List<java.lang.String>
merge(ObjectDB assign, java.lang.String assignId, java.lang.String resId1, java.lang.String resId2)
Merge assignments and related timesheetsjava.util.List<java.lang.String>
reassign(ObjectDB assign, java.lang.String assignIdFrom, java.lang.String assignIdTo, java.lang.String resIdTo, java.lang.String resId1, java.lang.String resId2, double factor, java.lang.String begin, java.lang.String end)
Transfers assignment charge between 2 resourcesjava.util.List<java.lang.String>
save()
Save the current timesheetjava.util.List<java.lang.String>
save(java.util.List<Timesheet.TimesheetLine> lines, java.util.List<java.lang.String[]> period)
Save a timesheet.void
setBackward(boolean b)
void
setChartEnabled(boolean b)
void
setChartVisible(boolean b)
void
setCurrentColor(java.lang.String label, java.lang.String color)
Assign a color to a resourcevoid
setCurrentLines(java.util.List<Timesheet.TimesheetLine> lines)
void
setCurrentPeriod(java.util.List<java.lang.String[]> p)
void
setCurrentResource1(java.lang.String id)
void
setCurrentResource2(java.lang.String id)
void
setFlying(boolean f)
void
setGanttEnabled(boolean b)
void
setGanttInTimesheet(int option)
void
setGanttVisible(boolean b)
void
setResourceWorkloadFactor(java.lang.String name, double factor)
Factor to get charge in days of input value on the resource/gantt chart.void
setShiftable(int fieldIndex, boolean shift)
void
setTimesheetEnabled(boolean b)
void
setType(char type)
java.util.List<java.lang.String>
shiftTimesheet(ObjectDB assign, java.lang.String assignId, java.lang.String resId1, java.lang.String resId2, java.lang.String oldBeginDate, java.lang.String newBeginDate, java.lang.String oldEndDate, java.lang.String newEndDate)
Shifts the timesheet charges of one assignmentint
showGanttInTimesheet()
Is GANTT accessible in the timesheet view ? GANTT_HIDDEN, GANTT_INLINED or GANTT_FORWARDvoid
swapResourceAndInput()
Swap display of resource and input fieldsstatic java.util.List<Timesheet.TimesheetLine>
toList(java.util.Map<java.lang.String,Timesheet.TimesheetLine> lines, boolean sort)
Sort lines by resource labelsjava.lang.String
toString()
-
-
-
Field Detail
-
TYPE_DAY
public static final char TYPE_DAY
Manage inputs by days- See Also:
- Constant Field Values
-
TYPE_WEEK
public static final char TYPE_WEEK
Manage inputs by weeks- See Also:
- Constant Field Values
-
TYPE_MONTH
public static final char TYPE_MONTH
Manage inputs by months- See Also:
- Constant Field Values
-
GANTT_HIDDEN
public static final int GANTT_HIDDEN
Hide Gantt access in the timesheet view- See Also:
- Constant Field Values
-
GANTT_INLINED
public static final int GANTT_INLINED
Inline Gantt display in the timesheet view- See Also:
- Constant Field Values
-
GANTT_FORWARD
public static final int GANTT_FORWARD
Add a link to Gantt view in the timesheet view- See Also:
- Constant Field Values
-
m_showGanttInTimesheet
public int m_showGanttInTimesheet
-
PERIOD_DAY_SIZE
public static final int PERIOD_DAY_SIZE
Minimum size of period in days- See Also:
- Constant Field Values
-
PERIOD_WEEK_SIZE
public static final int PERIOD_WEEK_SIZE
Minimum size of period in weeks- See Also:
- Constant Field Values
-
PERIOD_MONTH_SIZE
public static final int PERIOD_MONTH_SIZE
Minimum size of period in months- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Timesheet
public Timesheet(ObjectDB assign, java.lang.String id, java.lang.String name, char type, boolean flying, boolean backward, java.lang.String ref1, java.lang.String ref2, java.lang.String workloadField, java.lang.String beginDateField, java.lang.String endDateField, java.lang.String statusField, boolean chartRes, boolean chartGantt, int showGantt, boolean dragX, boolean dragY, boolean resizable)
Timesheet definition- Parameters:
assign
- Assignment object between 2 resourcesid
- Timesheet idname
- Timesheet nametype
- TYPE_DAY, TYPE_WEEK or TYPE_MONTHflying
- Floating period to the current datebackward
- Allow backward inputsref1
- Foreign id of resource 1 in assignmentref2
- Foreign id of resource 2 in assignmentworkloadField
- Optional workload field of assignmentbeginDateField
- Optional begin field of assignmentendDateField
- Optional end field of assignmentstatusField
- Optional status field for each timesheetchartRes
- Enable resource chartchartGantt
- Enable GANTT chartshowGantt
- GANTT option GANTT_*dragX
- Enable GANTT X drag/drop = shift in timedragY
- Enable GANTT Y drag/drop = reassignmentresizable
- Enable GANTT resizing
-
-
Method Detail
-
getId
public java.lang.String getId()
Timesheet id
-
getName
public java.lang.String getName()
Timesheet name
-
getObjectAssign
public ObjectDB getObjectAssign()
Get the assignment object
-
getObjectTimesheet
public ObjectDB getObjectTimesheet()
Get the timesheet object to store inputs
-
getFieldStatus
public ObjectField getFieldStatus()
Get the timesheet status field
-
getFieldResource1
public ObjectField getFieldResource1()
Get the resource1 field
-
getFieldResource2
public ObjectField getFieldResource2()
Get the resource2 field
-
getFieldWorkload
public ObjectField getFieldWorkload()
Get the workload field
-
getFieldBeginDate
public ObjectField getFieldBeginDate()
Get the begin date field
-
getFieldEndDate
public ObjectField getFieldEndDate()
Get the end date field
-
getType
public char getType()
get the timesheet type : TYPE_DAY, TYPE_WEEK or TYPE_MONTH
-
setType
public void setType(char type)
-
isFlying
public boolean isFlying()
Floating timesheet = starts period on any day
-
setFlying
public void setFlying(boolean f)
-
isBackwardInputAllowed
public boolean isBackwardInputAllowed()
Allows change for old inputs ?
-
setBackward
public void setBackward(boolean b)
-
isInputAllowed
public boolean isInputAllowed(java.lang.String key, java.lang.String assignId, java.lang.String resId1, java.lang.String resId2)
Allows change for a period key ? Default is based on the backward input- Parameters:
key
- Period keyresId1
- Resource 1 idresId2
- Resource 2 id- Returns:
- true if cell is editable
-
swapResourceAndInput
public void swapResourceAndInput()
Swap display of resource and input fields
-
isResourceAndInputSwapped
public boolean isResourceAndInputSwapped()
-
isTimesheetEnabled
public boolean isTimesheetEnabled()
Use timesheet input form ?
-
setTimesheetEnabled
public void setTimesheetEnabled(boolean b)
-
isChartEnabled
public boolean isChartEnabled()
Use resource chart ?
-
setChartEnabled
public void setChartEnabled(boolean b)
-
isChartVisible
public boolean isChartVisible()
Is resource chart visible ?
-
setChartVisible
public void setChartVisible(boolean b)
-
showGanttInTimesheet
public int showGanttInTimesheet()
Is GANTT accessible in the timesheet view ? GANTT_HIDDEN, GANTT_INLINED or GANTT_FORWARD
-
setGanttInTimesheet
public void setGanttInTimesheet(int option)
-
getInputFields
public java.util.List<ObjectField> getInputFields()
Input fields for each line
-
getInputField
public ObjectField getInputField(java.lang.String name)
Input field by name
-
addInputField
public void addInputField(java.lang.String name, Grant g)
Add an input field in the timesheet. Default value is used as a input limit. Calculated expression is used as a charge in day factor. Copiable property is used as shiftable in GANTT view.- Parameters:
name
- Field nameg
- User rights
-
canShiftField
public boolean canShiftField(int fieldIndex)
Shift the field charges when its GanttBlock moves (from copiable property of field) ?
-
setShiftable
public void setShiftable(int fieldIndex, boolean shift)
-
setResourceWorkloadFactor
public void setResourceWorkloadFactor(java.lang.String name, double factor)
Factor to get charge in days of input value on the resource/gantt chart. Default value is 1 when no calculated expression is set.- Parameters:
name
- The name of the input fieldfactor
- Factor value to convert the input charge in days
-
getResourceWorkloadFactor
public double getResourceWorkloadFactor(java.lang.String name)
-
getCurrentResource1
public java.lang.String getCurrentResource1()
Current parent resource 1 (null when 2 is set)
-
setCurrentResource1
public void setCurrentResource1(java.lang.String id)
-
getCurrentResource2
public java.lang.String getCurrentResource2()
Current parent resource 2 (null when 1 is set)
-
setCurrentResource2
public void setCurrentResource2(java.lang.String id)
-
getCurrentLines
public java.util.List<Timesheet.TimesheetLine> getCurrentLines()
Current timesheet lines
-
setCurrentLines
public void setCurrentLines(java.util.List<Timesheet.TimesheetLine> lines)
-
getCurrentPeriod
public java.util.List<java.lang.String[]> getCurrentPeriod()
Current period to display
-
setCurrentPeriod
public void setCurrentPeriod(java.util.List<java.lang.String[]> p)
-
getCurrentStartDate
public ObjectField getCurrentStartDate()
Current first date to display
-
getCurrentEndDate
public ObjectField getCurrentEndDate()
Current end date to display
-
buildCurrentPeriod
public void buildCurrentPeriod(java.lang.String begin, java.lang.String end)
Build the current period to display- Parameters:
begin
- Optional start date yyyy-MM-dd (default is today)end
- Optional end date yyyy-MM-dd
-
buildPeriod
public java.util.List<java.lang.String[]> buildPeriod(java.lang.String begin, java.lang.String end)
Return a period between 2 dates- Parameters:
begin
- Begin dateend
- End date- Returns:
- List of Date+Key
-
getCurrentColor
public java.lang.String getCurrentColor(java.lang.String label)
Get the color of a resource- Parameters:
label
- Any resource label- Returns:
- color #RRGGBB
-
setCurrentColor
public void setCurrentColor(java.lang.String label, java.lang.String color)
Assign a color to a resource- Parameters:
label
- Any resource labelcolor
- #RRGGBB
-
fitPeriodToAssignments
public void fitPeriodToAssignments(Parameters params)
Period including all assignments periods
-
getInputMinMaxDates
public java.lang.String[] getInputMinMaxDates()
Get the period including all timesheet inputs for the current resources- Returns:
- 2 dates
-
fitPeriodToInputs
public void fitPeriodToInputs()
Change the current period to include all timesheet inputs for the current resources
-
getResources
public java.util.List<java.lang.String[]> getResources(boolean resetFilter, java.lang.String resourceId1, java.lang.String resourceId2, java.lang.String beginDate, java.lang.String endDate)
Retrieve resources from the other- Parameters:
resourceId1
- optional resource idresourceId2
- optional resource idbeginDate
- start dateendDate
- end date- Returns:
- List of resource1 records if resource2 is set, and vice versa
-
getTimesheet
public java.util.Map<java.lang.String,Timesheet.TimesheetLine> getTimesheet(boolean resetFilter, boolean inPeriod)
Load timesheet from DB- Parameters:
resetFilter
- true to ignore UI filtersinPeriod
- true to watch timesheets in current period- Returns:
- timesheet lines
-
getTimesheet
public java.util.Map<java.lang.String,Timesheet.TimesheetLine> getTimesheet(ObjectDB assign, ObjectField r1, ObjectField r2, java.lang.String resId1, java.lang.String resId2, ObjectField d1, ObjectField d2, boolean resetFilter, boolean loadLabel, boolean inPeriod, java.lang.String fromKey, java.lang.String toKey)
-
save
public java.util.List<java.lang.String> save(java.util.List<Timesheet.TimesheetLine> lines, java.util.List<java.lang.String[]> period)
Save a timesheet. Calls first the preSaveTimesheet hook of the timesheet object. if succesful, save all timesheet lines, and finally calls the postSaveTimesheet hook.- Parameters:
lines
- Input linesperiod
- Perod to save- Returns:
- messages User messages
-
save
public java.util.List<java.lang.String> save()
Save the current timesheet- Returns:
- messages
-
shiftTimesheet
public java.util.List<java.lang.String> shiftTimesheet(ObjectDB assign, java.lang.String assignId, java.lang.String resId1, java.lang.String resId2, java.lang.String oldBeginDate, java.lang.String newBeginDate, java.lang.String oldEndDate, java.lang.String newEndDate)
Shifts the timesheet charges of one assignment- Parameters:
assignId
- Assignment idoldBeginDate
- Original begin datenewBeginDate
- Destination begin dateoldEndDate
- Original end datenewEndDate
- Destination end date- Returns:
- Messages or null
-
merge
public java.util.List<java.lang.String> merge(ObjectDB assign, java.lang.String assignId, java.lang.String resId1, java.lang.String resId2)
Merge assignments and related timesheets- Parameters:
assign
- Assign objectassignId
- Master assignment to keepresId1
- Resource 1resId2
- Resource 2- Returns:
- Messages or null
-
reassign
public java.util.List<java.lang.String> reassign(ObjectDB assign, java.lang.String assignIdFrom, java.lang.String assignIdTo, java.lang.String resIdTo, java.lang.String resId1, java.lang.String resId2, double factor, java.lang.String begin, java.lang.String end)
Transfers assignment charge between 2 resources- Parameters:
assign
- Assign objectassignIdFrom
- Source assign id to transferassignIdTo
- Target assign id (create a new one if null)resIdTo
- New resource id (in case of creation)resId1
- Id to get timesheets from resource 1resId2
- or Id to get timesheets from resource 2factor
- Percentage of charge to reassign (0=nothing .. 1=100%)begin
- Optional start dateend
- Optional end date- Returns:
- Messages or null
-
toList
public static java.util.List<Timesheet.TimesheetLine> toList(java.util.Map<java.lang.String,Timesheet.TimesheetLine> lines, boolean sort)
Sort lines by resource labels
-
convertDateToKey
public java.lang.String convertDateToKey(java.lang.String date)
Convert a date to its key- Parameters:
date
- yyyy-MM-dd- Returns:
- yyyy-MM-dd (day), yyyy-WW (week), yyyy-MM (month)
-
convertKeyToDate
public java.lang.String convertKeyToDate(java.lang.String key)
Convert a key to its date- Parameters:
key
- yyyy-MM-dd (day), yyyy-WW (week), yyyy-MM (month)- Returns:
- date yyyy-MM-dd
-
convertInputToMonthCharges
public double[] convertInputToMonthCharges(java.lang.String encodedInput)
Convert the encoded input into 12 months of charges (TYPE_DAYS and TYPE_WEEK only)
-
filterParams
public void filterParams(ObjectDB assign, Parameters params)
-
getGanttData
public Timesheet.GanttNode getGanttData()
GANTT tree
-
getGanttFilters
public java.util.Map<ObjectDB,java.util.LinkedHashMap<java.lang.String,java.util.HashMap<java.lang.String,Timesheet.GanttNode>>> getGanttFilters()
GANTT filters: Object in hierarchy => list of UK Label => list of id => Node
-
isGanttEnabled
public boolean isGanttEnabled()
Is the GANTT chart enabled ?
-
setGanttEnabled
public void setGanttEnabled(boolean b)
-
isGanttVisible
public boolean isGanttVisible()
Is the GANTT chart visible ?
-
setGanttVisible
public void setGanttVisible(boolean b)
-
isGanttDragXEnabled
public boolean isGanttDragXEnabled()
Is the horizontal drag allowed ?
-
enableGanttDragX
public void enableGanttDragX(boolean b)
-
isGanttDragYEnabled
public boolean isGanttDragYEnabled()
Is the vertical drag allowed ?
-
enableGanttDragY
public void enableGanttDragY(boolean b)
-
isGanttResizable
public boolean isGanttResizable()
Is the block resizing allowed ?
-
enableGanttResizable
public void enableGanttResizable(boolean b)
-
buildGanttData
public Timesheet.GanttNode buildGanttData(Parameters params)
- Returns:
- a tree of resources 0=hierarchy/1=resource1/2=resource2 and blocks=assignments
-
ganttDataToJson
public java.lang.String ganttDataToJson(Parameters params)
Serialize to JSON the GANTT- Returns:
- JSON flow
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-