Exemplo n.º 1
0
  /**
   * @param model
   * @param modelDto
   * @param adminRoleAdded
   * @return
   */
  private ArrayList<ParticipantDTO> updateTopLevelRoles(Model model) {
    List<Role> topLevelRoles = null;
    topLevelRoles = model.getAllTopLevelRoles();
    ArrayList<ParticipantDTO> allTopLevelRoles = new ArrayList<ParticipantDTO>();

    for (Role role : topLevelRoles) {
      // We the "Administrator" role that belong to Predefined model
      if (PredefinedConstants.ADMINISTRATOR_ROLE.equals(role.getId())) {
        if (PredefinedConstants.PREDEFINED_MODEL_ID.equals(model.getId())) {
          ParticipantDTO participantDTO = new ParticipantDTO(role);
          participantDTO.type = ParticipantManagementUtils.getParticipantType(role).name();
          allTopLevelRoles.add(participantDTO);
        }
        continue;
      }

      String modelId = ModelUtils.extractModelId(role.getQualifiedId());

      if ((modelId == null) || (modelId.equals(model.getId()))) {
        ParticipantDTO participantDTO = new ParticipantDTO(role);
        participantDTO.type = ParticipantManagementUtils.getParticipantType(role).name();
        allTopLevelRoles.add(participantDTO);
      }
    }
    return allTopLevelRoles;
  }
Exemplo n.º 2
0
  /** @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;
  }