Search in sources :

Example 6 with CaseRoleInstance

use of org.jbpm.casemgmt.api.model.instance.CaseRoleInstance in project jbpm by kiegroup.

the class CaseFileInstanceImpl method assign.

@Override
public void assign(String roleName, OrganizationalEntity entity) {
    if (AuthorizationManager.OWNER_ROLE.equals(roleName) && entity instanceof User) {
        assignOwner((User) entity);
        return;
    }
    CaseRoleInstance caseRoleInstance = this.roles.get(roleName);
    if (caseRoleInstance == null) {
        throw new IllegalArgumentException("No role with name " + roleName + " was found");
    }
    ((CaseRoleInstanceImpl) caseRoleInstance).addRoleAssignment(entity);
}
Also used : User(org.kie.api.task.model.User) CaseRoleInstance(org.jbpm.casemgmt.api.model.instance.CaseRoleInstance)

Example 7 with CaseRoleInstance

use of org.jbpm.casemgmt.api.model.instance.CaseRoleInstance in project jbpm by kiegroup.

the class CaseFileInstanceMarshallingStrategy method unmarshal.

@SuppressWarnings("unchecked")
@Override
public Object unmarshal(Context context, ObjectInputStream is, byte[] object, ClassLoader classloader) throws IOException, ClassNotFoundException {
    logger.debug("About to read {} bytes to unmarshal CaseFileInstance", (object == null ? 0 : object.length));
    Map<String, Object> caseFileContent = (Map<String, Object>) caseFileMarshaller.unmarshal(context, is, object, classloader);
    CaseFileInstanceImpl caseFileInstance = new CaseFileInstanceImpl();
    caseFileInstance.setCaseId((String) caseFileContent.get(CASE_ID_KEY));
    caseFileInstance.setDefinitionId((String) caseFileContent.get(CASE_DEF_ID_KEY));
    caseFileInstance.setCaseStartDate((Date) caseFileContent.get(CASE_START_KEY));
    caseFileInstance.setCaseEndDate((Date) caseFileContent.get(CASE_END_KEY));
    caseFileInstance.setCaseReopenDate((Date) caseFileContent.get(CASE_REOPEN_KEY));
    caseFileInstance.setRolesAssignments((Map<String, CaseRoleInstance>) caseFileContent.get(CASE_ROLE_ASSIGNMENTS_KEY));
    caseFileInstance.setComments((List<CommentInstance>) caseFileContent.get(CASE_COMMENTS_KEY));
    logger.debug("CaseFileInstance meta data unmarshalled properly into {}", caseFileInstance);
    List<SerializedContent> caseDataContent = (List<SerializedContent>) caseFileContent.get(CASE_DATA_KEY);
    logger.debug("About to read serialized content {}", caseDataContent);
    for (SerializedContent serializedContent : caseDataContent) {
        ObjectMarshallingStrategy marshaller = marshallersByName.get(serializedContent.getMarshaller());
        logger.debug("Marshaller for {} is of type {}", serializedContent, marshaller);
        Object value = marshaller.unmarshal(context, is, serializedContent.getContent(), classloader);
        caseFileInstance.add(serializedContent.getName(), value);
        logger.debug("Data unmarshalled into {} and put into case file under '{}' name", value, serializedContent.getName());
    }
    caseFileInstance.setAccessRestrictions((Map<String, List<String>>) caseFileContent.get(CASE_DATA_RESTRICTIONS_KEY));
    caseFileInstance.setParentInstanceId((Long) caseFileContent.get(CASE_PARENT_INSTANCE_ID_KEY));
    caseFileInstance.setParentWorkItemId((Long) caseFileContent.get(CASE_PARENT_WORK_ITEM_ID_KEY));
    logger.debug("Unmarshal of CaseFileInstance completed - result {}", caseFileInstance);
    return caseFileInstance;
}
Also used : CommentInstance(org.jbpm.casemgmt.api.model.instance.CommentInstance) ObjectMarshallingStrategy(org.kie.api.marshalling.ObjectMarshallingStrategy) CaseFileInstanceImpl(org.jbpm.casemgmt.impl.model.instance.CaseFileInstanceImpl) ArrayList(java.util.ArrayList) List(java.util.List) CaseRoleInstance(org.jbpm.casemgmt.api.model.instance.CaseRoleInstance) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

CaseRoleInstance (org.jbpm.casemgmt.api.model.instance.CaseRoleInstance)7 ArrayList (java.util.ArrayList)4 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)2 CaseFileInstanceImpl (org.jbpm.casemgmt.impl.model.instance.CaseFileInstanceImpl)2 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 CaseMilestoneInstance (org.jbpm.casemgmt.api.model.instance.CaseMilestoneInstance)1 CaseStageInstance (org.jbpm.casemgmt.api.model.instance.CaseStageInstance)1 CommentInstance (org.jbpm.casemgmt.api.model.instance.CommentInstance)1 CaseInstanceImpl (org.jbpm.casemgmt.impl.model.instance.CaseInstanceImpl)1 PersistObjectCommand (org.jbpm.shared.services.impl.commands.PersistObjectCommand)1 ObjectMarshallingStrategy (org.kie.api.marshalling.ObjectMarshallingStrategy)1 User (org.kie.api.task.model.User)1