Skip to content

Commit

Permalink
fixed, removed PostConstruct, refactoring
Browse files Browse the repository at this point in the history
Issue #574
  • Loading branch information
rsoika committed Mar 8, 2024
1 parent a6b9deb commit 0b0709c
Showing 1 changed file with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.imixs.workflow.faces.data.WorkflowController;
import org.imixs.workflow.faces.data.WorkflowEvent;

import jakarta.annotation.PostConstruct;
import jakarta.ejb.EJB;
import jakarta.enterprise.context.ConversationScoped;
import jakarta.enterprise.event.Observes;
Expand All @@ -63,7 +62,7 @@
* history, versions, comments, references, documents
*
* <p>
* Each chronic entry for a workitme consists of the following data items:
* Each chronic entry for a workitem consists of the following data items:
* <ul>
*
* - type : date|history|file|version|
Expand All @@ -80,20 +79,17 @@
@ConversationScoped
public class ChronicleController implements Serializable {

/**
*
*/
private static final long serialVersionUID = 1L;
@Inject
protected WorkflowController workflowController;
private static Logger logger = Logger.getLogger(ChronicleController.class.getName());

List<ChronicleEntity> originChronicleList;
List<ChronicleEntity> filteredChronicleList;
String filter = null;

Map<Integer, Set<Integer>> yearsMonths;

@Inject
protected WorkflowController workflowController;

@Inject
protected DMSController dmsController;

Expand All @@ -108,8 +104,11 @@ public class ChronicleController implements Serializable {

private DateFormat dateFormat = null;

/**
* This helper method is called during the WorkflowEvent.WORKITEM_CHANGED to
* update the chronicle view for the current workitem.
*/
@SuppressWarnings("unchecked")
@PostConstruct
public void init() {
long l = System.currentTimeMillis();
originChronicleList = new ArrayList<ChronicleEntity>();
Expand All @@ -132,17 +131,14 @@ public void init() {
// do we have real history entries?
if (history.size() > 0 && history.get(0) instanceof List) {
for (List<Object> entries : history) {

Date date = (Date) entries.get(0);
String message = (String) entries.get(1);
String user = (String) entries.get(2);

ItemCollection entry = new ItemCollection();
entry.replaceItemValue("date", date);
entry.replaceItemValue("user", user);
entry.replaceItemValue("message", message);
entry.replaceItemValue("type", "history");

addChronicleEntry(originChronicleList, entry);
}
}
Expand Down Expand Up @@ -284,7 +280,6 @@ public void init() {
}

/*
*
* Helper Method checks if a given UniqueID is part of a list of Workitems
*
* @param list
Expand All @@ -305,22 +300,21 @@ private boolean containsUniqueID(List<ItemCollection> list, String uniqueID) {

/**
* WorkflowEvent listener
* <p>
* If a new WorkItem was created the file upload will be reset.
*
* If a new WorkItem was created or changed, the chronicle view will be
* initialized.
*
* @param workflowEvent
*/
public void onWorkflowEvent(@Observes WorkflowEvent workflowEvent) {
if (workflowEvent == null)
if (workflowEvent == null) {
return;

}
if (WorkflowEvent.WORKITEM_CREATED == workflowEvent.getEventType()
|| WorkflowEvent.WORKITEM_CHANGED == workflowEvent.getEventType()) {
// reset chronicle data...
init();
}

}

/**
Expand All @@ -334,11 +328,9 @@ public String getFilter() {

public List<Integer> getYears() {
Set<Integer> result = yearsMonths.keySet();

List<Integer> sortedList = new ArrayList<>(result);
Collections.sort(sortedList);
Collections.reverse(sortedList);

return sortedList;
}

Expand Down

0 comments on commit 0b0709c

Please sign in to comment.