Skip to content

Commit

Permalink
impl
Browse files Browse the repository at this point in the history
Issue #391
  • Loading branch information
rsoika committed Jun 5, 2024
1 parent 0cb2944 commit 89ad91a
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 8 deletions.
82 changes: 74 additions & 8 deletions src/main/java/org/imixs/marty/team/TeamController.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@
import java.util.List;
import java.util.logging.Logger;

import jakarta.annotation.PostConstruct;
import jakarta.ejb.EJB;
import jakarta.enterprise.context.SessionScoped;
import jakarta.enterprise.event.Observes;
import jakarta.inject.Inject;
import jakarta.inject.Named;

import org.imixs.marty.profile.ProfileService;
import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.ItemCollectionComparator;
Expand All @@ -50,6 +43,13 @@
import org.imixs.workflow.faces.util.LoginController;
import org.imixs.workflow.faces.util.ResourceBundleHandler;

import jakarta.annotation.PostConstruct;
import jakarta.ejb.EJB;
import jakarta.enterprise.context.SessionScoped;
import jakarta.enterprise.event.Observes;
import jakarta.inject.Inject;
import jakarta.inject.Named;

/**
* The ProcessController provides informations about the process and space
* entities. A Workitem can be assigned to a process and one or more spaces. The
Expand Down Expand Up @@ -531,7 +531,7 @@ public boolean isMemberOf(String aUniqueID) {
* @param workflowEvent
*/
public void onWorkflowEvent(@Observes WorkflowEvent workflowEvent) {
if (workflowEvent == null || workflowEvent.getWorkitem()==null) {
if (workflowEvent == null || workflowEvent.getWorkitem() == null) {
return;
}

Expand Down Expand Up @@ -638,4 +638,70 @@ private List<ItemCollection> getMemberListByRole(String aUniqueID, String role)
return resultList;
}

/**
* This method updates the space.ref item with the first space ID the current
* user is member of.
* The method can be used as a default selector as in the Imixs-Office-Workflwo
* form part 'spaceref.xhtml'
*
* The method updates the items space.ref and space.name and returns the
* space.ref
*/
public String setDefaultSpace(ItemCollection workitem) {
// If the current workitem is assigned to a process then first resolve all
// spaces assigned to this process...
ItemCollection defaultSpace = null;
List<ItemCollection> _spaceList = getSpacesByProcessId(workitem.getItemValueString("process.Ref"));
if (_spaceList != null) {
for (ItemCollection space : _spaceList) {
if (space.getItemValueBoolean("isMember")) {
defaultSpace = space;
break;
}
}
}
// we did not yet find a matching space in the process list.
// so we iterate over all spaces
if (defaultSpace == null) {
_spaceList = getSpaces();
if (_spaceList != null) {
for (ItemCollection space : _spaceList) {
if (space.getItemValueBoolean("isMember")) {
defaultSpace = space;
break;
}
}
}
}
// do we have a match?
if (defaultSpace != null) {
workitem.setItemValue("space.ref", defaultSpace.getUniqueID());
workitem.setItemValue("space.name", defaultSpace.getItemValueString("name"));
return defaultSpace.getUniqueID();
}

// no match !
return "";

}

/**
* This method resolves the field 'process.default.ref'.
* This fields holds the first space ID the current user is member of.
*
*/
public String resolveDefaultProcessRef(ItemCollection workitem) {
// iterate over all processes
List<ItemCollection> _processList = getProcessList();
if (_processList != null) {
for (ItemCollection _process : _processList) {
if (_process.getItemValueBoolean("isMember")) {
return _process.getUniqueID();
}
}
}
// no match !
return null;

}
}
2 changes: 2 additions & 0 deletions src/main/java/org/imixs/marty/team/TeamPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
* <li>txtSpaceName
* <li>txtProcessName
* </ul>
*
* @author rsoika
* @version 2.0
*/
Expand Down Expand Up @@ -365,6 +366,7 @@ public ItemCollection run(ItemCollection workItem, ItemCollection documentActivi
workItem.appendItemValueUnique("space.manager.label", entity.getItemValue("space.manager.label"));

workItem.appendItemValueUnique("space.name", entity.getItemValue("space.name"));
workItem.appendItemValueUnique("space.parent.name", entity.getItemValue("space.parent.name"));

}

Expand Down

0 comments on commit 89ad91a

Please sign in to comment.