-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[26516] add reminder build to initialize default fields
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
bundles/ch.elexis.core/src/ch/elexis/core/model/builder/IReminderBuilder.java
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,53 @@ | ||
package ch.elexis.core.model.builder; | ||
|
||
import java.time.LocalDate; | ||
|
||
import ch.elexis.core.model.IContact; | ||
import ch.elexis.core.model.IReminder; | ||
import ch.elexis.core.model.issue.ProcessStatus; | ||
import ch.elexis.core.model.issue.Visibility; | ||
import ch.elexis.core.services.IContextService; | ||
import ch.elexis.core.services.IModelService; | ||
|
||
public class IReminderBuilder extends AbstractBuilder<IReminder> { | ||
|
||
public IReminderBuilder(IModelService modelService, IContextService context, Visibility visibility, | ||
ProcessStatus status, String message) { | ||
super(modelService); | ||
|
||
object = modelService.create(IReminder.class); | ||
object.setStatus(status); | ||
object.setDue(LocalDate.now()); | ||
object.setVisibility(visibility); | ||
object.setMessage(message); | ||
if (context != null) { | ||
object.setCreator(context.getActiveUserContact().orElse(null)); | ||
object.setContact(context.getActiveUserContact().orElse(null)); | ||
} | ||
} | ||
|
||
public IReminderBuilder addResponsible(IContact responsible) { | ||
object.addResponsible(responsible); | ||
return this; | ||
} | ||
|
||
public IReminderBuilder contact(IContact contact) { | ||
object.setContact(contact); | ||
return this; | ||
} | ||
|
||
public IReminderBuilder subject(String subject) { | ||
object.setSubject(subject); | ||
return this; | ||
} | ||
|
||
public IReminderBuilder visibility(Visibility visibility) { | ||
object.setVisibility(visibility); | ||
return this; | ||
} | ||
|
||
public IReminderBuilder status(ProcessStatus status) { | ||
object.setStatus(status); | ||
return this; | ||
} | ||
} |