public void initializePanel(ActivityInstance ai, Map inData) { FacesContext facesContext = FacesContext.getCurrentInstance(); InteractionRegistry registry = (InteractionRegistry) ManagedBeanUtils.getManagedBean(facesContext, InteractionRegistry.BEAN_ID); if (null != registry) { // start new interaction ModelCache modelCache = ModelCache.findModelCache(); SessionContext ippSessionContext = SessionContext.findSessionContext(); Interaction interaction = registry.getInteraction(Interaction.getInteractionId(ai)); if (null == interaction) { interaction = new Interaction(ippSessionContext.getUser(), ai, getContextId(ai), modelCache); interaction.setInDataValues(inData); registry.registerInteraction(interaction); } Map<String, Object> sessionMap = facesContext.getExternalContext().getSessionMap(); sessionMap.put( IframePanelConstants.KEY_COMMAND, IframePanelConstants.CMD_IFRAME_PANEL_INITIALIZE); sessionMap.put(IframePanelConstants.KEY_INTERACTION_ID, interaction.getId()); if (!isIceFacesPanel(ai)) { sessionMap.put(IframePanelConstants.KEY_VIEW_ID, VIEW_ID_NON_IFACE_FACELET_CONTAINER); } } // TODO emit java script to load page into panel? }
/** * @param modelCache * @param ai * @return */ private static Map<String, DescriptorDTO> getProcessDescriptors( ModelCache modelCache, ActivityInstance ai) { List<ProcessDescriptor> processDescriptorsList = CollectionUtils.newList(); Model model = modelCache.getModel(ai.getModelOID()); ProcessDefinition processDefinition = (model != null) ? model.getProcessDefinition(ai.getProcessDefinitionId()) : null; if (processDefinition != null) { ProcessInstanceDetails processInstanceDetails = (ProcessInstanceDetails) ai.getProcessInstance(); Map<String, Object> descriptorValues = processInstanceDetails.getDescriptors(); CommonDescriptorUtils.updateProcessDocumentDescriptors( descriptorValues, ai.getProcessInstance(), processDefinition); if (processInstanceDetails.isCaseProcessInstance()) { processDescriptorsList = CommonDescriptorUtils.createCaseDescriptors( processInstanceDetails.getDescriptorDefinitions(), descriptorValues, processDefinition, true); } else { processDescriptorsList = CommonDescriptorUtils.createProcessDescriptors( descriptorValues, processDefinition, true, true); } Map<String, DescriptorDTO> descriptors = new LinkedHashMap<String, DescriptorDTO>(); for (Object descriptor : processDescriptorsList) { if (descriptor instanceof ProcessDocumentDescriptor) { ProcessDocumentDescriptor desc = (ProcessDocumentDescriptor) descriptor; List<DocumentDTO> documents = new ArrayList<DocumentDTO>(); for (DocumentInfo documentInfo : desc.getDocuments()) { DocumentDTO documentDTO = new DocumentDTO(); documentDTO.name = documentInfo.getName(); documentDTO.uuid = documentInfo.getId(); documentDTO.contentType = (MimeTypesHelper.detectMimeType(documentInfo.getName(), null).getType()); documents.add(documentDTO); } DescriptorDTO descriptorDto = new DescriptorDTO(desc.getKey(), desc.getValue(), true, documents); descriptors.put(desc.getId(), descriptorDto); } else { ProcessDescriptor desc = (ProcessDescriptor) descriptor; DescriptorDTO descriptorDto = new DescriptorDTO(desc.getKey(), desc.getValue(), false, null); descriptors.put(desc.getId(), descriptorDto); } } return descriptors; } return null; }
/** * return just model and its participants * * @return * @throws Exception */ public List<ModelDTO> getModelParticipants() { List<ModelDTO> modelList = CollectionUtils.newArrayList(); Collection<DeployedModel> models = CollectionUtils.newArrayList(); models = ModelCache.findModelCache().getActiveModels(); for (DeployedModel model : models) { ModelDTO modelDTO = DTOBuilder.build(model, ModelDTO.class); modelList.add(modelDTO); // Add all top-level Organizations modelDTO.children = updateTopLevelOrganizations(model); // Add all top-level Roles modelDTO.children.addAll(updateTopLevelRoles(model)); } return modelList; }
/** * @param queryResult * @return */ public static QueryResultDTO buildTableResult( QueryResult<?> queryResult, MODE mode, Map<String, TrivialManualActivityDTO> trivialManualActivityDetails, List<String> extraColumns) { List<ActivityInstanceDTO> list = new ArrayList<ActivityInstanceDTO>(); List<CriticalityCategory> criticalityConfigurations = CriticalityUtils.getCriticalityConfiguration(); ModelCache modelCache = ModelCache.findModelCache(); QueryResultDTO resultDTO = new QueryResultDTO(); if (null != queryResult) { for (Object object : queryResult) { if (object instanceof ActivityInstance) { ActivityInstance ai = (ActivityInstance) object; ActivityInstanceDTO dto; if (ActivityInstanceUtils.isTrivialManualActivity(ai)) { TrivialActivityInstanceDTO trivialDto = DTOBuilder.build(ai, TrivialActivityInstanceDTO.class); trivialDto.trivial = true; if (null != trivialManualActivityDetails && trivialManualActivityDetails.keySet().contains(String.valueOf(ai.getOID()))) { TrivialManualActivityDTO tivialManualActivity = trivialManualActivityDetails.get(String.valueOf(ai.getOID())); trivialDto.dataMappings = tivialManualActivity.dataMappings; trivialDto.inOutData = tivialManualActivity.inOutData; } dto = trivialDto; } else { dto = DTOBuilder.build(ai, ActivityInstanceDTO.class); } dto.auxillary = isAuxiliaryActivity(ai.getActivity()); dto.duration = ActivityInstanceUtils.getDuration(ai); dto.assignedTo = getAssignedToLabel(ai); dto.criticality = populateCriticalityDTO(criticalityConfigurations, ai); dto.priority = DTOBuilder.build(ai, PriorityDTO.class); dto.status = DTOBuilder.build(ai, StatusDTO.class); dto.status.label = ActivityInstanceUtils.getActivityStateLabel(ai); dto.descriptorValues = getProcessDescriptors(modelCache, ai); dto.activatable = findIfActivatable(ai); dto.relocationEligible = org.eclipse.stardust.ui.web.viewscommon.utils.ActivityInstanceUtils .isRelocationEligible(ai); dto.benchmark = getBenchmarkForActivity(ai); List<Note> notes = org.eclipse.stardust.ui.web.viewscommon.utils.ProcessInstanceUtils.getNotes( ai.getProcessInstance()); if (null != notes) { dto.notesCount = notes.size(); } if (CollectionUtils.isNotEmpty(extraColumns) && extraColumns.contains(Constants.RESUBMISSION_TIME)) { Date resubmissionDate = org.eclipse.stardust.ui.web.viewscommon.utils.ActivityInstanceUtils .getResubmissionDate(ai); if (null != resubmissionDate) { dto.resubmissionTime = resubmissionDate.getTime(); } } ProcessDefinition processDefinition = ProcessDefinitionUtils.getProcessDefinition( ai.getModelOID(), ai.getProcessDefinitionId()); dto.processInstance.supportsProcessAttachments = ProcessDefinitionUtils.supportsProcessAttachments(processDefinition); if (mode.equals(MODE.ACTIVITY_TABLE)) { dto.completedBy = ActivityInstanceUtils.getPerformedByName(ai); dto.participantPerformer = getParticipantPerformer(ai); dto.abortActivity = !dto.isCaseInstance && isAbortable(ai); dto.delegable = isDelegable(ai); dto.abortProcess = ProcessInstanceUtils.isAbortable(ai.getProcessInstance()); } else { dto.lastPerformer = getLastPerformer(ai, UserUtils.getDefaultUserNameDisplayFormat()); if (!dto.defaultCaseActivity) { dto.abortActivity = isAbortable(ai); dto.delegable = isDelegable(ai); } } dto.defaultCaseActivity = ActivityInstanceUtils.isDefaultCaseActivity(ai); dto.isCaseInstance = ai.getProcessInstance().isCaseProcessInstance(); if (dto.defaultCaseActivity) { dto.activity.name = getCaseName(ai); } list.add(dto); } } resultDTO.totalCount = queryResult.getTotalCount(); } resultDTO.list = list; return resultDTO; }
/** @return */ public List<ModelDTO> getModels(Boolean allActive, boolean includePredefinedModel) throws Exception { List<ModelDTO> modelList = CollectionUtils.newArrayList(); try { Collection<DeployedModel> models = CollectionUtils.newArrayList(); if (allActive.equals(true)) { models = ModelCache.findModelCache().getActiveModels(); } else { models = ModelCache.findModelCache().getAllModels(); } for (DeployedModel model : models) { if (includePredefinedModel || !(PredefinedConstants.PREDEFINED_MODEL_ID.equals(model.getId()))) { ModelDTO modelDTO = DTOBuilder.build(model, ModelDTO.class); String modelName = I18nUtils.getModelName(model); List<ProcessDefinitionDTO> processDefitionDTOList = CollectionUtils.newArrayList(); List<Data> modelData = model.getAllData(); List<ProcessDefinition> processDefinitions = model.getAllProcessDefinitions(); List<ActivityDTO> activityDTOList = CollectionUtils.newArrayList(); List<DataDTO> dataDTOList = CollectionUtils.newArrayList(); // Create DataDTO list for (Data data : modelData) { DataDTO dataDTO = DTOBuilder.build(data, DataDTO.class); dataDTOList.add(dataDTO); } // Create ProcessDefinitionDTO list for (ProcessDefinition processDefinition : processDefinitions) { ProcessDefinitionDTO processDefinitionDTO = DTOBuilder.build(processDefinition, ProcessDefinitionDTO.class); processDefinitionDTO.modelName = modelName; processDefinitionDTO.auxillary = isAuxiliaryProcess(processDefinition); processDefinitionDTO.name = I18nUtils.getProcessName(processDefinition); processDefitionDTOList.add(processDefinitionDTO); activityDTOList = CollectionUtils.newArrayList(); List<Activity> activities = processDefinition.getAllActivities(); // Create ActivityDTO list for (Activity activity : activities) { ActivityDTO activityDTO = DTOBuilder.build(activity, ActivityDTO.class); activityDTO.auxillary = isAuxiliaryActivity(activity); activityDTO.name = I18nUtils.getActivityName(activity); activityDTO.runtimeElementOid = activity.getRuntimeElementOID(); activityDTOList.add(activityDTO); } processDefinitionDTO.activities = activityDTOList; } modelDTO.processDefinitions = processDefitionDTOList; modelDTO.data = dataDTOList; modelList.add(modelDTO); // Add all top-level Organizations modelDTO.allTopLevelOrganizations = updateTopLevelOrganizations(model); // Add all top-level Roles modelDTO.allTopLevelRoles = updateTopLevelRoles(model); } } } catch (Exception e) { throw e; } return modelList; }
private void addDepartmentData(Department department) { Map<String, Object> map = null; if (department != null) { map = CollectionUtils.newMap(); Department department1 = department; do { if (department1 == null) { break; } Organization organization = department1.getOrganization(); if (organization != null) { String s = (String) organization.getAttribute("carnot:engine:dataId"); if (s != null) { ModelCache modelCache = ModelCache.findModelCache(); Model model = modelCache.getModel(organization.getModelOID()); Data data = model.getData(s); String s1 = data.getTypeId(); if ("primitive".equals(s1)) { map.put(s, department1.getId()); } else if ("struct".equals(s1)) { Object obj = map.get(s); if (!(obj instanceof Map)) { obj = CollectionUtils.newMap(); map.put(s, obj); } Map map1 = (Map) obj; String s2 = (String) organization.getAttribute("carnot:engine:dataPath"); if (StringUtils.isEmpty(s2)) { map.put(s, department1.getId()); } else { do { int i; if (0 >= (i = s2.indexOf('/'))) { break; } String s3 = s2.substring(0, i).trim(); s2 = s2.substring(i + 1); if (s3.length() > 0) { Map map2 = (Map) map1.get(s3); if (map2 == null) { map2 = CollectionUtils.newMap(); map1.put(s3, map2); } map1 = map2; } } while (true); s2 = s2.trim(); if (s2.length() > 0) { map1.put(s2, department1.getId()); } } } else { throw new PublicException( (new StringBuilder()) .append("Unsupported data type in manual triggers: ") .append(s1) .toString()); } department1 = department1.getParentDepartment(); } } } while (true); } ActivityInstance nextActivityInstance = PPUtils.activateNextActivityInstance( PPUtils.startProcess(getProcessDefinition(), map, true)); if (nextActivityInstance != null) { ActivityInstanceUtils.openActivity(nextActivityInstance); } else { MessageDialog.addInfoMessage( MessagePropertiesBean.getInstance() .getParamString("common.processStarted.message", new String[] {getName()})); } }