/*
   * (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;
  }
Exemplo n.º 2
0
 public void addItem(Project project, ItemRecord itemRecord) {
   ProjectNode node = projects.get(project.getTechnicalLabel());
   if (node == null) {
     node = new ProjectNode(project);
     projects.put(project.getTechnicalLabel(), node);
   }
   node.addItem(itemRecord);
 }
 private void addDQDependencies(IFolder parentFolder, List<Item> items) throws IOException {
   if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQItemService.class)) {
     ITDQItemService tdqItemService =
         (ITDQItemService) GlobalServiceRegister.getDefault().getService(ITDQItemService.class);
     for (Item item : items) {
       if (tdqItemService != null
           && tdqItemService.hasProcessItemDependencies(Arrays.asList(new Item[] {item}))) {
         // add .Talend.definition file
         String defIdxFolderName = "TDQ_Libraries"; // $NON-NLS-1$
         String defIdxFileName = ".Talend.definition"; // $NON-NLS-1$
         Project pro = getProject(processItem);
         IFolder itemsProjectFolder =
             parentFolder.getFolder(pro.getTechnicalLabel().toLowerCase());
         File itemsFolderDir = new File(parentFolder.getLocation().toFile().getAbsolutePath());
         IProject project = ReponsitoryContextBridge.getRootProject();
         String defIdxRelativePath = defIdxFolderName + PATH_SEPARATOR + defIdxFileName;
         IFile defIdxFile = project.getFile(defIdxRelativePath);
         if (defIdxFile.exists()) {
           File defIdxFileSource =
               new File(
                   project
                       .getLocation()
                       .makeAbsolute()
                       .append(defIdxFolderName)
                       .append(defIdxFileName)
                       .toFile()
                       .toURI());
           File defIdxFileTarget =
               new File(
                   itemsProjectFolder
                       .getFile(defIdxRelativePath)
                       .getLocation()
                       .toFile()
                       .getAbsolutePath());
           FilesUtils.copyFile(defIdxFileSource, defIdxFileTarget);
         }
         // add report header image & template files
         String reportingBundlePath =
             PluginChecker.getBundlePath("org.talend.dataquality.reporting"); // $NON-NLS-1$
         File imageFolder =
             new File(reportingBundlePath + PATH_SEPARATOR + "images"); // $NON-NLS-1$
         if (imageFolder.exists()) {
           FilesUtils.copyDirectory(imageFolder, itemsFolderDir);
         }
         File templateFolder =
             new File(reportingBundlePath + PATH_SEPARATOR + "reports"); // $NON-NLS-1$
         if (templateFolder.exists() && templateFolder.isDirectory()) {
           FilesUtils.copyDirectory(templateFolder, itemsFolderDir);
         }
       }
     }
   }
 }
 protected IProject getCorrespondingProjectRootFolder(Item item) throws CoreException {
   // for bug 17685
   org.talend.core.model.properties.Project p = getProject(item);
   IProject project = null;
   if (p != null) {
     project =
         ResourcesPlugin.getWorkspace().getRoot().getProject(p.getTechnicalLabel().toUpperCase());
     if (project != null) {
       return project;
     }
   }
   return null;
 }
  /** 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
    }
  }
Exemplo n.º 6
0
 public ExchangeUser getExchangeUser() {
   ExchangeUser user = PropertiesFactory.eINSTANCE.createExchangeUser();
   if (project.getAuthor() != null) {
     IPreferenceStore prefStore = PlatformUI.getPreferenceStore();
     String connectionEmail = project.getAuthor().getLogin();
     String string = prefStore.getString(connectionEmail);
     if (string != null) {
       String[] split = string.split(":");
       if (split.length == 3) {
         user.setLogin(split[0]);
         user.setUsername(split[1]);
         user.setPassword(split[2]);
       } else {
         user.setLogin("");
         user.setUsername("");
         user.setPassword("");
       }
     }
   }
   return user;
 }
  /** 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
      }
    }
  }
Exemplo n.º 8
0
 /**
  * Sets the label.
  *
  * @param label the label to set
  */
 public void setLabel(String label) {
   project.setLabel(label);
 }
Exemplo n.º 9
0
 /**
  * Getter for label.
  *
  * @return the label
  */
 public String getLabel() {
   return project.getLabel();
 }
Exemplo n.º 10
0
 public Project(String label) {
   this.project = PropertiesFactory.eINSTANCE.createProject();
   project.setLabel(label);
 }
Exemplo n.º 11
0
 /**
  * Sets the author.
  *
  * @param author the author to set
  */
 public void setAuthor(User author) {
   project.setAuthor(author);
 }
Exemplo n.º 12
0
 /**
  * Getter for technicalLabel.
  *
  * @return the technicalLabel
  */
 public String getTechnicalLabel() {
   return project.getTechnicalLabel();
 }
Exemplo n.º 13
0
 /**
  * Sets the technicalLabel.
  *
  * @param technicalLabel the technicalLabel to set
  */
 public void setTechnicalLabel(String technicalLabel) {
   project.setTechnicalLabel(technicalLabel);
 }
Exemplo n.º 14
0
 /**
  * Getter for local.
  *
  * @return the local
  */
 public boolean isLocal() {
   return project.isLocal();
 }
Exemplo n.º 15
0
 /**
  * Sets the language.
  *
  * @param language the language to set
  */
 public void setLanguage(ECodeLanguage language) {
   project.setLanguage(language.getName());
 }
Exemplo n.º 16
0
 /**
  * Getter for language.
  *
  * @return the language
  */
 public ECodeLanguage getLanguage() {
   return ECodeLanguage.getCodeLanguage(project.getLanguage());
 }
Exemplo n.º 17
0
 /**
  * Sets the description.
  *
  * @param description the description to set
  */
 public void setDescription(String description) {
   project.setDescription(description);
 }
Exemplo n.º 18
0
 /**
  * Getter for description.
  *
  * @return the description
  */
 public String getDescription() {
   return project.getDescription();
 }
  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;
  }
 /**
  * DOC smallet Comment method "afterImportAs".
  *
  * @param newName
  * @param technicalName
  * @throws InvocationTargetException
  */
 private static Project afterImportAs(String newName, String technicalName)
     throws InvocationTargetException {
   // Rename in ".project" and "talendProject" or "talend.project"
   // TODO SML Optimize
   final IWorkspace workspace = org.eclipse.core.resources.ResourcesPlugin.getWorkspace();
   IContainer containers = (IProject) workspace.getRoot().findMember(new Path(technicalName));
   IResource file2 = containers.findMember(IProjectDescription.DESCRIPTION_FILE_NAME);
   try {
     FilesUtils.replaceInFile(
         "<name>.*</name>",
         file2.getLocation().toOSString(),
         "<name>" + technicalName + "</name>"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     // TDI-19269
     final IProject project = workspace.getRoot().getProject(technicalName);
     XmiResourceManager xmiManager = new XmiResourceManager();
     try {
       final Project loadProject = xmiManager.loadProject(project);
       loadProject.setTechnicalLabel(technicalName);
       loadProject.setLabel(newName);
       loadProject.setLocal(true);
       loadProject.setId(0);
       loadProject.setUrl(null);
       loadProject.setCreationDate(null);
       loadProject.setDescription("");
       loadProject.setType(null);
       // ADD xqliu 2012-03-12 TDQ-4771 clear the list of Folders
       if (loadProject.getFolders() != null) {
         loadProject.getFolders().clear();
       }
       // ~ TDQ-4771
       xmiManager.saveResource(loadProject.eResource());
       return loadProject;
     } catch (PersistenceException e) {
       //
     }
   } catch (IOException e) {
     throw new InvocationTargetException(e);
   }
   return null;
 }
Exemplo n.º 21
0
 public void setMasterJobId(String masterJobId) {
   if (masterJobId != null) {
     project.setMasterJobId(masterJobId);
   }
 }
Exemplo n.º 22
0
 /**
  * Sets the local.
  *
  * @param local the local to set
  */
 public void setLocal(boolean local) {
   project.setLocal(local);
 }
Exemplo n.º 23
0
 /**
  * Getter for author.
  *
  * @return the author
  */
 public User getAuthor() {
   return project.getAuthor();
 }
Exemplo n.º 24
0
  public void updateProjectSettings()
      throws ParserConfigurationException, SAXException, IOException {
    if (this.path == null) {
      return;
    }

    File file = new File(path);
    org.talend.core.model.properties.Project project = pro.getEmfProject();

    final DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance();
    DocumentBuilder analyseur = fabrique.newDocumentBuilder();
    analyseur.setErrorHandler(
        new ErrorHandler() {

          public void error(final SAXParseException exception) throws SAXException {
            throw exception;
          }

          public void fatalError(final SAXParseException exception) throws SAXException {
            throw exception;
          }

          public void warning(final SAXParseException exception) throws SAXException {
            throw exception;
          }
        });

    final Document document = analyseur.parse(file);
    final NodeList nodes = document.getElementsByTagName("exportParameter"); // $NON-NLS-1$
    List addedComponentSetting = new ArrayList();
    List technical = project.getTechnicalStatus();
    List documentation = project.getDocumentationStatus();
    technical.clear();
    documentation.clear();

    for (int i = 0; i < nodes.getLength(); i++) {
      final Node node = nodes.item(i);
      final NamedNodeMap attrMap = node.getAttributes();
      final Node typeAttr = attrMap.getNamedItem("type"); // $NON-NLS-1$

      if ("technicalStatus".equals(typeAttr.getTextContent())) { // $NON-NLS-1$
        updateStatus(node, attrMap, technical, "technicalStatus"); // $NON-NLS-1$
      } else if ("documentationStatus".equals(typeAttr.getTextContent())) { // $NON-NLS-1$
        updateStatus(node, attrMap, documentation, "documentationStatus"); // $NON-NLS-1$
      } else if ("security".equals(typeAttr.getTextContent())) { // $NON-NLS-1$
        project.isHidePassword();
        project.setHidePassword(Boolean.valueOf(node.getTextContent()));
      } else if ("statAndLogs".equals(typeAttr.getTextContent())) { // $NON-NLS-1$
        if (project.getStatAndLogsSettings() == null) {
          TalendFileFactory talendF = TalendFileFactory.eINSTANCE;
          StatAndLogsSettings stats = PropertiesFactory.eINSTANCE.createStatAndLogsSettings();
          project.setStatAndLogsSettings(stats);
          stats.setParameters(talendF.createParametersType());
        }

        List statAndLogs = project.getStatAndLogsSettings().getParameters().getElementParameter();
        updateParameters(node, attrMap, statAndLogs);

      } else if ("implicitContext".equals(typeAttr.getTextContent())) { // $NON-NLS-1$
        if (project.getImplicitContextSettings() == null) {
          TalendFileFactory talendF = TalendFileFactory.eINSTANCE;

          ImplicitContextSettings implicit =
              PropertiesFactory.eINSTANCE.createImplicitContextSettings();
          project.setImplicitContextSettings(implicit);
          implicit.setParameters(talendF.createParametersType());
        }

        List implicitContexts =
            project.getImplicitContextSettings().getParameters().getElementParameter();
        updateParameters(node, attrMap, implicitContexts);

      } else if ("palette".equals(typeAttr.getTextContent())) { // $NON-NLS-1$
        List componentSettings = project.getComponentsSettings();
        boolean existed = false;
        String name = attrMap.getNamedItem("name").getTextContent(); // $NON-NLS-1$
        final Node familyAttr = attrMap.getNamedItem("family"); // $NON-NLS-1$
        Boolean hide = Boolean.valueOf(node.getTextContent());

        for (Object obj : componentSettings) {
          ComponentSetting setting = (ComponentSetting) obj;

          if (setting.getName().equals(name)) {
            if (familyAttr != null && familyAttr.getTextContent().equals(setting.getFamily())) {
              existed = true;
              setting.setHidden(hide);
            }
          }
        }
        if (!existed && familyAttr != null) {
          ComponentSetting setting = PropertiesFactory.eINSTANCE.createComponentSetting();
          setting.setFamily(familyAttr.getTextContent());
          setting.setName(name);
          setting.setHidden(hide);
          addedComponentSetting.add(setting);
        }
      }
    }

    project.getComponentsSettings().addAll(addedComponentSetting);
  }
Exemplo n.º 25
0
 public String getMasterJobId() {
   return project.getMasterJobId();
 }