/*
   * (non-Jsdoc)
   *
   * @see
   * org.talend.designer.codegen.ITalendSynchronizer#getRoutinesFile(org.talend.core.model.properties.RoutineItem)
   */
  @Override
  public IFile getRoutinesFile(Item item) throws SystemException {
    try {
      if (item instanceof BeanItem) {
        BeanItem routineItem = (BeanItem) item;
        ProjectManager projectManager = ProjectManager.getInstance();
        org.talend.core.model.properties.Project project = projectManager.getProject(routineItem);
        IProject iProject =
            ResourcesPlugin.getWorkspace().getRoot().getProject(project.getTechnicalLabel());
        String repositoryPath =
            ERepositoryObjectType.getFolderName(CamelRepositoryNodeType.repositoryBeansType);
        String folderPath =
            RepositoryNodeUtilities.getPath(routineItem.getProperty().getId()).toString();
        String fileName =
            routineItem.getProperty().getLabel()
                + '_'
                + routineItem.getProperty().getVersion()
                + JavaUtils.ITEM_EXTENSION;
        String path = null;
        if (folderPath != null && folderPath.trim().length() > 0) {
          path = repositoryPath + '/' + folderPath + '/' + fileName;
        } else {
          path = repositoryPath + '/' + fileName;
        }

        IFile file = iProject.getFile(path);
        return file;
      }

    } catch (Exception e) {
      throw new SystemException(e);
    }

    return null;
  }
 /*
  * (non-Javadoc)
  *
  * @see org.talend.commons.ui.swt.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
  * org.eclipse.jface.viewers.IStructuredSelection)
  */
 @Override
 public void init(TreeViewer viewer, IStructuredSelection selection) {
   boolean canWork = !selection.isEmpty() && selection.size() == 1;
   IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
   if (factory.isUserReadOnlyOnCurrentProject()) {
     canWork = false;
   }
   if (canWork) {
     Object o = selection.getFirstElement();
     RepositoryNode node = (RepositoryNode) o;
     switch (node.getType()) {
       case SIMPLE_FOLDER:
       case SYSTEM_FOLDER:
         ERepositoryObjectType nodeType =
             (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
         if (nodeType != ERepositoryObjectType.PIG_UDF) {
           canWork = false;
         }
         if (node.getObject() != null && node.getObject().isDeleted()) {
           canWork = false;
         }
         break;
       default:
         canWork = false;
     }
     if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
       canWork = false;
     }
   }
   setEnabled(canWork);
 }
 /*
  * (non-Javadoc)
  *
  * @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
  * org.eclipse.jface.viewers.IStructuredSelection)
  */
 @Override
 public void init(TreeViewer viewer, IStructuredSelection selection) {
   super.init(viewer, selection);
   boolean canWork = !selection.isEmpty() && selection.size() == 1;
   IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
   if (factory.isUserReadOnlyOnCurrentProject()) {
     canWork = false;
   }
   RepositoryNode node = (RepositoryNode) selection.getFirstElement();
   if (canWork) {
     if (node.getObjectType() != ERepositoryObjectType.ROUTINES
         || !ProjectManager.getInstance().isInCurrentMainProject(node)
         || !isLastVersion(node)) {
       canWork = false;
     } else {
       Item item = node.getObject().getProperty().getItem();
       if (item instanceof RoutineItem) {
         canWork = !((RoutineItem) item).isBuiltIn();
       }
     }
   }
   if (canWork) {
     canWork = (factory.getStatus(node.getObject()) != ERepositoryStatus.DELETED);
   }
   setEnabled(canWork);
 }
Пример #4
0
 private String getTmpFolderPath() {
   Project project = ProjectManager.getInstance().getCurrentProject();
   String tmpFolder;
   try {
     IProject physProject = ResourceModelUtils.getProject(project);
     tmpFolder = physProject.getFolder(TEMP).getLocation().toPortableString();
   } catch (Exception e) {
     tmpFolder = System.getProperty("user.dir"); // $NON-NLS-1$
   }
   tmpFolder = tmpFolder + "/talendExporter"; // $NON-NLS-1$
   return tmpFolder;
 }
 /**
  * DOC msjian Comment method "extractFolder".
  *
  * @param oldItem
  * @param oldModelElement
  * @return
  */
 @Override
 protected IFolder extractFolder(Item oldItem, ModelElement oldObject) {
   boolean inCurrentMainProject = ProjectManager.getInstance().isInCurrentMainProject(oldItem);
   if (inCurrentMainProject) {
     Resource resource = oldItem.eResource();
     IPath path = new Path(resource.getURI().toPlatformString(false));
     IFile oldFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
     return (IFolder) oldFile.getParent();
   } else {
     // for the reference project node, we get its folder in current project.
     return ResourceManager.getOneFolder(EResourceConstant.JRXML_TEMPLATE);
   }
 }
  /** cli Comment method "removeJobLaunch". */
  public static void removeJobLaunch(IRepositoryViewObject objToDelete) {
    if (objToDelete == null) {
      return;
    }
    Property property = objToDelete.getProperty();
    if (property == null || !(property.getItem() instanceof ProcessItem)) {
      return;
    }
    Project project = ProjectManager.getInstance().getProject(property);
    if (project == null) {
      return;
    }
    final String objProjectName = project.getLabel();
    final String objId = property.getId();
    // final String objName = property.getLabel();
    final String objVersion = property.getVersion();

    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    if (launchManager == null) {
      return;
    }
    try {
      ILaunchConfiguration configuration = null;
      for (ILaunchConfiguration config : launchManager.getLaunchConfigurations()) {
        String jobId = config.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null);
        // String jobName = configuration.getAttribute(TalendDebugUIConstants.JOB_NAME, (String)
        // null);
        String jobVersion = config.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null);
        String projectName =
            config.getAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null);
        ILaunchConfigurationType type = config.getType();
        if (type != null
            && TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE.equals(
                type.getIdentifier())
            && objProjectName.equals(projectName)
            && objId.equals(jobId)
            && objVersion.equals(jobVersion)) {
          configuration = config;
          break;
        }
      }
      if (configuration == null) {
        return;
      }
      configuration.delete();
    } catch (CoreException e) {
      // nothing to do
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse
   * .jface.viewers.TreeViewer,
   * org.eclipse.jface.viewers.IStructuredSelection)
   */
  public void init(TreeViewer viewer, IStructuredSelection selection) {
    boolean canWork = !selection.isEmpty() && selection.size() == 1;
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()) {
      canWork = false;
    }
    if (canWork) {
      Object o = selection.getFirstElement();
      RepositoryNode node = (RepositoryNode) o;
      switch (node.getType()) {
        case REPOSITORY_ELEMENT:
          if (node.getObjectType() != CamelRepositoryNodeType.repositoryRouteResourceType) {
            canWork = false;
          } else {
            IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
            IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
            if (repFactory.isPotentiallyEditable(node.getObject())) {
              this.setText(""); // $NON-NLS-1$
            } else {
              this.setText(""); // $NON-NLS-1$
            }
          }
          break;
        default:
          canWork = false;
      }
      RepositoryNode parent = node.getParent();
      if (canWork && parent != null && parent instanceof BinRepositoryNode) {
        canWork = false;
      }
      if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
        canWork = false;
      }

      // If the editProcess action canwork is true, then detect that the
      // job version is the latest verison or not.
      if (canWork) {
        canWork = isLastVersion(node);
      }
    }
    setEnabled(canWork);

    this.setText("Open another version");
    this.setToolTipText("Open another version");
    this.setImageDescriptor(
        RouteResourceActivator.createImageDesc("icons/open-another-version.png"));
  }
 private boolean refreshNewJob() {
   if (alreadyEditedByUser) {
     return false;
   }
   IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
   try {
     repositoryFactory.save(getProperty(), this.originaleObjectLabel, this.originalVersion);
     ExpressionPersistance.getInstance()
         .jobNameChanged(originaleObjectLabel, repoObject.getLabel());
     ProxyRepositoryFactory.getInstance()
         .saveProject(ProjectManager.getInstance().getCurrentProject());
     return true;
   } catch (PersistenceException e) {
     MessageBoxExceptionHandler.process(e);
     return false;
   }
 }
  private void initProperty() {
    JobInfo jobInfo =
        new JobInfo(
            processItem,
            processItem.getProcess().getDefaultContext(),
            processItem.getProperty().getVersion());
    Project currentProject = ProjectManager.getInstance().getCurrentProject();
    setProperty(PROJECT_ID, String.valueOf(currentProject.getEmfProject().getId()));
    setProperty(PROJECT_NAME, currentProject.getTechnicalLabel());

    String branchKey =
        IProxyRepositoryFactory.BRANCH_SELECTION
            + UNDER_LINE_CHAR
            + currentProject.getTechnicalLabel();
    Context ctx = CoreRuntimePlugin.getInstance().getContext();
    RepositoryContext rc = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
    if (rc.getFields().containsKey(branchKey) && rc.getFields().get(branchKey) != null) {
      String branchSelection = rc.getFields().get(branchKey);
      setProperty(BRANCH, branchSelection);
    }

    setProperty(JOB_ID, jobInfo.getJobId());
    setProperty(JOB_NAME, jobInfo.getJobName());
    String jobType = processItem.getProcess().getJobType();
    if (jobType == null) {
      /*
       * should call ConvertJobsUtil.getJobTypeFromFramework(processItem)
       *
       * ConvertJobsUtil.JobType.STANDARD.getDisplayName
       */
      jobType = "Standard"; // $NON-NLS-1$
    }
    setProperty(JOB_TYPE, jobType);
    setProperty(JOB_VERSION, jobInfo.getJobVersion());
    setProperty(CONTEXT_NAME, this.contextName);
    setProperty(DATE, DATAFORMAT.format(new Date()));

    setProperty(APPLY_CONTEXY_CHILDREN, String.valueOf(applyContextToChild));
    if (CommonsPlugin.isHeadless()) {
      setProperty(ADD_STATIC_CODE, String.valueOf(addStat));
    } else {
      setProperty(ADD_STATIC_CODE, Boolean.TRUE.toString()); // TDI-23641, in studio, false always.
    }
    setProperty(COMMANDLINE_VERSION, VersionUtils.getVersion());
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.repository.ui.actions.metadata.AbstractCreateAction#init(org.talend.repository.model.RepositoryNode)
   */
  @Override
  protected void init(RepositoryNode node) {
    ERepositoryObjectType nodeType =
        (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()
        || !ProjectManager.getInstance().isInCurrentMainProject(node)) {
      setEnabled(false);
    } else {
      if (ENodeType.REPOSITORY_ELEMENT.equals(node.getType())) {
        if (node.getObject().getRepositoryStatus() == ERepositoryStatus.DELETED
            || node.getObject().getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER) {
          setEnabled(false);
          return;
        }
        if ((factory.getStatus(node.getObject()) == ERepositoryStatus.DELETED)
            || (factory.getStatus(node.getObject()) == ERepositoryStatus.LOCK_BY_OTHER)) {
          setEnabled(false);
          return;
        }

        if (ERepositoryObjectType.METADATA_CON_TABLE.equals(nodeType)
            || ERepositoryObjectType.METADATA_CON_COLUMN.equals(nodeType)) {
          RepositoryNode parent = node.getParent();
          if (parent != null
              && HCatalogRepositoryNodeType.HCATALOG.equals(
                  parent.getProperties(EProperties.CONTENT_TYPE))) {
            setText(EDIT_LABEL);
            collectSiblingNames(node);
            setEnabled(true);
            return;
          }
        } else if (HCatalogRepositoryNodeType.HCATALOG.equals(nodeType)) {
          setText(CREATE_LABEL);
          collectChildNames(node);
          setEnabled(true);
          return;
        }
      }
    }
  }
Пример #11
0
  @Override
  public boolean performFinish() {
    boolean formIsPerformed = false;
    formIsPerformed = page1.isPageComplete();
    if (formIsPerformed) {
      IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
      try {
        if (creation) {
          String nextId = factory.getNextId();
          connectionProperty.setId(nextId);
          factory.create(connectionItem, salesforceSchemaWizardPage0.getDestinationPath());
        } else {
          // update
          RepositoryUpdateManager.updateFileConnection(connectionItem);
          refreshInFinish(salesforceSchemaWizardPage0.isNameModifiedByUser());
          updateConnectionItem();
        }
        ProxyRepositoryFactory.getInstance()
            .saveProject(ProjectManager.getInstance().getCurrentProject());

      } catch (Exception e) {
        String detailError = e.toString();
        new ErrorDialogWidthDetailArea(
            getShell(),
            PID,
            Messages.getString("CommonWizard.persistenceException"), // $NON-NLS-1$
            detailError);
        log.error(
            Messages.getString("CommonWizard.persistenceException")
                + "\n"
                + detailError); //$NON-NLS-1$ //$NON-NLS-2$
        return false;
      }
      return true;
    } else {
      return false;
    }
  }
Пример #12
0
  private void getAllVersions(
      Project project, Property property, List<IRepositoryViewObject> allVersion)
      throws PersistenceException {
    ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(property.getItem());
    Object fullFolder = getFullFolder(project, itemType, property.getItem().getState().getPath());
    if (fullFolder != null) {
      allVersion.addAll(
          getSerializableFromFolder(
              project, fullFolder, property.getId(), itemType, true, false, false, true));
      if (allVersion.size() == 0) {
        // if no item found in current directory, look for all directory
        allVersion.addAll(getAllVersion(project, property.getId(), false));
      }
    } else {
      allVersion.addAll(getAllVersion(project, property.getId(), false));
    }
    if (allVersion.size() == 0 && project.getEmfProject().getReferencedProjects().size() > 0) {
      String parentBranch = ProjectManager.getInstance().getMainProjectBranch(project);

      for (ProjectReference refProject :
          (List<ProjectReference>) project.getEmfProject().getReferencedProjects()) {
        if (refProject.getBranch() != null && !parentBranch.equals(refProject.getBranch())) {
          continue;
        }
        org.talend.core.model.properties.Project emfProject = refProject.getReferencedProject();
        getAllVersions(new Project(emfProject), property, allVersion);
        if (allVersion.size() > 0) {
          break;
        }
      }
    }
    // MOD mzhao Temporary return original object. In this case, the object hasn't been updated from
    // svn server.
    if (allVersion.size() == 0) {
      allVersion.add(new RepositoryViewObject(property));
    }
  }
Пример #13
0
 public ImportProjectSettings(String path) {
   this.path = path;
   this.pro = ProjectManager.getInstance().getCurrentProject();
 }
  /*
   * (non-Javadoc)
   *
   * @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
   * org.eclipse.jface.viewers.IStructuredSelection)
   */
  @Override
  public void init(TreeViewer viewer, IStructuredSelection selection) {
    boolean canWork = !selection.isEmpty() && selection.size() == 1;
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()) {
      canWork = false;
    }
    if (canWork) {
      Object o = selection.getFirstElement();
      RepositoryNode node = (RepositoryNode) o;
      Object property = node.getProperties(EProperties.CONTENT_TYPE);
      switch (node.getType()) {
        case REPOSITORY_ELEMENT:
        case STABLE_SYSTEM_FOLDER:
          canWork = false;
          break;
        case SYSTEM_FOLDER:
          if (ERepositoryObjectType.GENERATED.equals(property)
              || ERepositoryObjectType.JOBS.equals(property)
              || ERepositoryObjectType.JOBLETS.equals(property)
              || ERepositoryObjectType.SQLPATTERNS.equals(property)
              || ERepositoryObjectType.REFERENCED_PROJECTS.equals(property)
              || ERepositoryObjectType.SVN_ROOT.equals(property)) {
            canWork = false;
          } else if (property != null
              && GlobalServiceRegister.getDefault()
                  .isServiceRegistered(ICamelDesignerCoreService.class)) {
            ICamelDesignerCoreService camelService =
                (ICamelDesignerCoreService)
                    GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
            if (property.equals(camelService.getRouteDocsType())) {
              canWork = false;
            }
          }
          break;
        case SIMPLE_FOLDER:
          if (ERepositoryObjectType.JOB_DOC.equals(property)
              || ERepositoryObjectType.JOBLET_DOC.equals(property)
              || (ERepositoryObjectType.SQLPATTERNS.equals(property)
                  && !isUnderUserDefined(node))) {
            canWork = false;
          } else if (property != null
              && GlobalServiceRegister.getDefault()
                  .isServiceRegistered(ICamelDesignerCoreService.class)) {
            ICamelDesignerCoreService camelService =
                (ICamelDesignerCoreService)
                    GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
            if (property.equals(camelService.getRouteDocType())) {
              canWork = false;
            }
          }
          if (node.getObject().isDeleted()) {
            canWork = false;
          }
          break;
        default:
          // Nothing to do
      }

      if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
        canWork = false;
      }
    }
    setEnabled(canWork);
  }
Пример #15
0
 /**
  * create technical name.
  *
  * @param name
  * @return
  */
 public static String createTechnicalName(String name) {
   return ProjectManager.getLocalTechnicalProjectName(name);
 }
  /** cli Comment method "renameJobLaunch". */
  public static void renameJobLaunch(IRepositoryViewObject obj, String oldLabel) {
    if (obj == null) {
      return;
    }
    Property property = obj.getProperty();
    if (property == null || !(property.getItem() instanceof ProcessItem)) {
      return;
    }
    String newLabel = property.getLabel();
    if (!newLabel.equals(oldLabel)) {
      Project project = ProjectManager.getInstance().getProject(property);
      if (project == null) {
        return;
      }

      final String objProjectName = project.getLabel();
      final String id = property.getId();
      final String version = property.getVersion();

      ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
      if (launchManager == null) {
        return;
      }
      try {
        for (ILaunchConfiguration configuration : launchManager.getLaunchConfigurations()) {

          String jobId = configuration.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null);
          String jobVersion =
              configuration.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null);
          String projectName =
              configuration.getAttribute(
                  TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null);

          // ILaunchConfigurationType type = launchManager
          // .getLaunchConfigurationType(TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE);
          ILaunchConfigurationType type = configuration.getType();
          if (type != null
              && TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE.equals(
                  type.getIdentifier())
              && objProjectName.equals(projectName)
              && id.equals(jobId)
              && version.equals(jobVersion)
              && type != null) {
            String displayName = newLabel + " " + jobVersion; // $NON-NLS-1$
            ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
            workingCopy.setAttribute(TalendDebugUIConstants.JOB_NAME, newLabel);
            // workingCopy.setAttribute(TalendDebugUIConstants.JOB_ID, jobId);
            // update to new version
            workingCopy.setAttribute(TalendDebugUIConstants.JOB_VERSION, jobVersion);
            // workingCopy.setAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, projectName);
            workingCopy.rename(displayName);
            workingCopy.doSave();
            break;
          }
        }
        clearUnusedLaunchs();
      } catch (CoreException e) {
        // nothing to do
      }
    }
  }
  @SuppressWarnings("unchecked")
  public static List<String> getRequiredRoutineName(IProcess process) {
    Set<String> neededRoutines = process.getNeededRoutines();
    ECodeLanguage currentLanguage = LanguageManager.getCurrentLanguage();
    String perlConn = "::"; // $NON-NLS-1$
    String builtInPath =
        ILibrariesService.SOURCE_PERL_ROUTINES_FOLDER
            + perlConn
            + "system"
            + perlConn; //$NON-NLS-1$

    if (neededRoutines == null || neededRoutines.isEmpty()) {
      try {
        IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
        List<IRepositoryViewObject> routines =
            factory.getAll(
                ProjectManager.getInstance().getCurrentProject(), ERepositoryObjectType.ROUTINES);
        for (Project project : ProjectManager.getInstance().getAllReferencedProjects()) {
          List<IRepositoryViewObject> routinesFromRef =
              factory.getAll(project, ERepositoryObjectType.ROUTINES);
          for (IRepositoryViewObject routine : routinesFromRef) {
            if (!((RoutineItem) routine.getProperty().getItem()).isBuiltIn()) {
              routines.add(routine);
            }
          }
        }
        neededRoutines = new HashSet<String>();
        for (IRepositoryViewObject object : routines) {
          neededRoutines.add(object.getLabel());
        }
      } catch (PersistenceException e) {
        ExceptionHandler.process(e);
      }
    }
    if (currentLanguage == ECodeLanguage.PERL) {
      List<IRepositoryViewObject> routines;
      try {
        IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
        routines = factory.getAll(ERepositoryObjectType.ROUTINES);
        for (Project project : ProjectManager.getInstance().getAllReferencedProjects()) {
          List<IRepositoryViewObject> routinesFromRef =
              factory.getAll(project, ERepositoryObjectType.ROUTINES);
          for (IRepositoryViewObject routine : routinesFromRef) {
            if (!((RoutineItem) routine.getProperty().getItem()).isBuiltIn()) {
              routines.add(routine);
            }
          }
        }
        Set<String> newNeededRoutines = new HashSet<String>();
        for (IRepositoryViewObject object : routines) {
          if (neededRoutines.contains(object.getLabel())) {
            neededRoutines.remove(object.getLabel());
            if (((RoutineItem) object.getProperty().getItem()).isBuiltIn()) {
              newNeededRoutines.add(builtInPath + object.getLabel());
            } else {
              String userPath =
                  ILibrariesService.SOURCE_PERL_ROUTINES_FOLDER
                      + perlConn
                      + ProjectManager.getInstance()
                          .getProject(object.getProperty().getItem())
                          .getTechnicalLabel()
                      + perlConn;
              newNeededRoutines.add(userPath + object.getLabel());
            }
          }
        }
        neededRoutines = newNeededRoutines;
      } catch (PersistenceException e) {
        ExceptionHandler.process(e);
      }
    }
    return new ArrayList<String>(neededRoutines);
  }
  public static List<ContextTableTabParentModel> constructContextDatas(
      List<IContextParameter> contextDatas) {
    List<ContextTableTabParentModel> output = new ArrayList<ContextTableTabParentModel>();
    if (!contextDatas.isEmpty()) {
      int i = 0;
      for (IContextParameter para : contextDatas) {
        String sourceId = para.getSource();
        if (IContextParameter.BUILT_IN.equals(sourceId)) {
          sourceId = para.getSource();
          ContextTableTabParentModel firstLevelNode = new ContextTableTabParentModel();
          String sourceLabel = sourceId;
          ContextItem contextItem = ContextUtils.getContextItemById2(sourceId);
          if (contextItem != null) {
            sourceLabel = contextItem.getProperty().getLabel();
            final ProjectManager pm = ProjectManager.getInstance();
            if (!pm.isInCurrentMainProject(contextItem)) {
              final Project project = pm.getProject(contextItem);
              if (project != null) {
                firstLevelNode.setProjectLabel(project.getLabel());
              }
            }
          }
          firstLevelNode.setOrder(i);
          firstLevelNode.setSourceName(sourceLabel);
          firstLevelNode.setSourceId(sourceId);
          firstLevelNode.setContextParameter(para);
          output.add(firstLevelNode);
        } else {
          ContextTableTabParentModel firstLevelNode = null;
          if (sourceId != null) {
            firstLevelNode = lookupContextParentForNonBuiltinNode(sourceId, output);
            if (firstLevelNode == null) {
              firstLevelNode = new ContextTableTabParentModel();
              output.add(firstLevelNode);
              String sourceLabel = sourceId;
              // the item maybe a joblet item now
              Item contextItem = ContextUtils.getRepositoryContextItemById(sourceId);
              if (contextItem != null) {
                sourceLabel = contextItem.getProperty().getLabel();
                final ProjectManager pm = ProjectManager.getInstance();
                if (!pm.isInCurrentMainProject(contextItem)) {
                  final Project project = pm.getProject(contextItem);
                  if (project != null) {
                    firstLevelNode.setProjectLabel(project.getLabel());
                  }
                }
              }
              firstLevelNode.setSourceName(sourceLabel);
              firstLevelNode.setOrder(i);
              firstLevelNode.setSourceId(sourceId);
            }

            ContextTableTabChildModel child = new ContextTableTabChildModel();
            child.setSourceId(sourceId);
            child.setContextParameter(para);
            child.setParent(firstLevelNode);
            firstLevelNode.addChild(child);
          }
        }
        i++;
      }
    }
    return output;
  }