/** ldong Comment method "resetJobProblemList". */
 public static void resetJobProblemList(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)) {
     for (Iterator<Problem> iter = Problems.getProblemList().getProblemList().iterator();
         iter.hasNext(); ) {
       Problem problem = iter.next();
       if (problem instanceof TalendProblem) {
         TalendProblem routineProblem = (TalendProblem) problem;
         if (routineProblem.getJavaUnitName() != null
             && (routineProblem.getJavaUnitName().equals(oldLabel))) {
           // TDI-24683:if rename the jobItem,need clear the problem view to avoid use the old
           // problem list
           iter.remove();
         }
       }
     }
   }
 }
  /**
   * create jrxml file.
   *
   * @param path
   * @param label
   * @param initFile
   * @param extendtion
   * @return
   */
  public TDQJrxmlItem createJrxml(IPath path, String label, File initFile, String extendtion) {
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    property.setVersion(VersionUtils.DEFAULT_VERSION);
    property.setStatusCode(PluginConstant.EMPTY_STRING);
    property.setLabel(label);

    TDQJrxmlItem routineItem =
        org.talend.dataquality.properties.PropertiesFactory.eINSTANCE.createTDQJrxmlItem();
    routineItem.setProperty(property);
    routineItem.setExtension(extendtion);
    routineItem.setName(label);

    ByteArray byteArray = duplicateByteArray(initFile);
    routineItem.setContent(byteArray);
    IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
    try {
      property.setId(repositoryFactory.getNextId());
      if (path != null) {
        repositoryFactory.createParentFoldersRecursively(
            ERepositoryObjectType.getItemType(routineItem), path);
      }
      repositoryFactory.create(routineItem, path);
    } catch (PersistenceException e) {
      ExceptionHandler.process(e);
    }
    return routineItem;
  }
  /**
   * Test method for {@link
   * org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject#getProperty()}.
   */
  @Test
  public void testGetProperty() {
    Catalog catalog = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog();
    catalog.setName(CATALOG_NAME);

    IRepositoryViewObject mockViewObject = mock(IRepositoryViewObject.class);
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    when(mockViewObject.getProperty()).thenReturn(property);

    ConnectionItem connItem = PropertiesFactory.eINSTANCE.createConnectionItem();
    Connection conn = ConnectionFactory.eINSTANCE.createConnection();
    connItem.setConnection(conn);
    Catalog catalog2 = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog();
    catalog2.setName(CATALOG_NAME);
    conn.getDataPackage().add(catalog2);

    property.setItem(connItem);

    MetadataCatalogRepositoryObject catalogRepObject =
        new MetadataCatalogRepositoryObject(mockViewObject, catalog);

    Property property2 = catalogRepObject.getProperty();
    Assert.assertTrue(property2.equals(property));
    Assert.assertTrue(catalog2.equals(catalogRepObject.getCatalog()));
  }
Exemplo n.º 4
0
 protected Item copyFromResource(Resource createResource, String newItemLabel)
     throws PersistenceException, BusinessException {
   if (newItemLabel != null) {
     Item newItem =
         (Item)
             EcoreUtil.getObjectByType(
                 createResource.getContents(), PropertiesPackage.eINSTANCE.getItem());
     Property property = newItem.getProperty();
     property.setId(getNextId());
     property.setAuthor(getRepositoryContext().getUser());
     property.setLabel(newItemLabel);
     property.setDisplayName(newItemLabel);
     // BUG TDI-25050:If here throw exception,it will block the copy action
     // if (!isNameAvailable(getRepositoryContext().getProject(), property.getItem(), null)) {
     // throw new
     // BusinessException(Messages.getString("AbstractEMFRepositoryFactory.cannotGenerateItem"));
     // //$NON-NLS-1$
     // }
     EcoreUtil.resolveAll(createResource);
     return newItem;
   } else {
     boolean changeLabelWithCopyPrefix = true;
     return copyFromResource(createResource, changeLabelWithCopyPrefix);
   }
 }
Exemplo n.º 5
0
 public String getConnectionName() {
   DataManager connection = analysis.getContext().getConnection();
   if (connection == null) {
     return PluginConstant.EMPTY_STRING;
   } else {
     Property property = PropertyHelper.getProperty(connection);
     return property == null ? PluginConstant.EMPTY_STRING : property.getLabel();
   }
 }
Exemplo n.º 6
0
 protected void computePropertyMaxInformationLevel(Property property) {
   EList<Information> informations = property.getInformations();
   InformationLevel maxLevel = null;
   for (Information information : informations) {
     int value = information.getLevel().getValue();
     if (maxLevel == null || value > maxLevel.getValue()) {
       maxLevel = information.getLevel();
     }
   }
   property.setMaxInformationLevel(maxLevel);
 }
 private void getProcess() {
   initPerlArray();
   this.component.setNumber(number);
   if (component.getProcess() instanceof IProcess2) { // get current job context manager.
     jobContextManager = component.getProcess().getContextManager();
   }
   Property property = PropertiesFactory.eINSTANCE.createProperty();
   property.setLabel(PREVIEW + "_RowGenerator2"); // $NON-NLS-1$
   property.setId(PREVIEW + "_RowGenerator2"); // $NON-NLS-1$
   proc = new RowGenProcess(property, component);
 }
Exemplo n.º 8
0
  /**
   * Test method for {@link
   * org.talend.dataprofiler.core.CorePlugin#itemIsOpening(org.talend.core.model.properties.Item,
   * boolean)}.
   */
  @Test
  public void testItemIsOpeningItemBoolean() {
    try {
      CorePlugin cpMock = mock(CorePlugin.class);
      PowerMockito.mockStatic(CorePlugin.class);
      when(CorePlugin.getDefault()).thenReturn(cpMock);

      IWorkbench workbenchMock = mock(IWorkbench.class);
      when(cpMock.getWorkbench()).thenReturn(workbenchMock);

      IWorkbenchWindow workbenchWindowMock = mock(IWorkbenchWindow.class);
      when(workbenchMock.getActiveWorkbenchWindow()).thenReturn(workbenchWindowMock);

      IWorkbenchPage workbenchPageMock = mock(IWorkbenchPage.class);
      when(workbenchWindowMock.getActivePage()).thenReturn(workbenchPageMock);

      IEditorReference editorRefMock = mock(IEditorReference.class);
      IEditorReference[] editorRefMocks = new IEditorReference[] {editorRefMock};
      when(workbenchPageMock.getEditorReferences()).thenReturn(editorRefMocks);

      FileEditorInput fileEditorInputMock = mock(FileEditorInput.class);
      when(editorRefMock.getEditorInput()).thenReturn(fileEditorInputMock);

      String path1 = "/abc1"; // $NON-NLS-1$
      String path2 = "/abc2"; // $NON-NLS-1$

      IFile inputFileMock = mock(IFile.class);
      when(fileEditorInputMock.getFile()).thenReturn(inputFileMock);

      IPath inputFilePathMock = mock(IPath.class);
      when(inputFileMock.getFullPath()).thenReturn(inputFilePathMock);

      when(inputFilePathMock.toString()).thenReturn(path1);

      Item itemMock = mock(Item.class);
      Property propertyMock = mock(Property.class);
      when(itemMock.getProperty()).thenReturn(propertyMock);

      Resource resourceMock = mock(Resource.class);
      when(propertyMock.eResource()).thenReturn(resourceMock);

      IPath ipathMock = mock(IPath.class);
      PowerMockito.mockStatic(PropertyHelper.class);
      when(PropertyHelper.getItemPath(propertyMock)).thenReturn(ipathMock);
      when(ipathMock.toString()).thenReturn(path2);

      CorePlugin cp = new CorePlugin();
      assertFalse(cp.itemIsOpening(itemMock, false));
    } catch (PartInitException e) {
      fail(e.getMessage());
    }
  }
 /**
  * Added yyin 20130118 TDQ-3249, when importing, should also consider the international as init.
  */
 @Override
 public void updateProperty(ModelElement element) {
   super.updateProperty(element);
   Property property = PropertyHelper.getProperty(element);
   // if the indicator is the user defined indicator, no need to internationalize it.
   if (isUserDefinedIndicator((IndicatorDefinition) element)) {
     return;
   }
   if (property != null) {
     property.setDisplayName(
         org.talend.cwm.management.i18n.Messages.getString(element.getName().replace(' ', '.')));
   }
 }
 /**
  * DOC talend Comment method "setConnection".
  *
  * @param object
  */
 private void getConnectionFromViewObject() {
   IRepositoryViewObject object =
       this.getObject() == null ? this.getParent().getObject() : this.getObject();
   if (object != null && object instanceof ISubRepositoryObject) {
     Property property = ((ISubRepositoryObject) object).getProperty();
     if (property == null) {
       return;
     }
     Item theItem = property.getItem();
     if (theItem != null && theItem instanceof ConnectionItem) {
       connection = ((ConnectionItem) theItem).getConnection();
     }
   }
 }
Exemplo n.º 11
0
  @Override
  public Property getUptodateProperty(Project project, Property property)
      throws PersistenceException {

    List<IRepositoryViewObject> allVersion = new ArrayList<IRepositoryViewObject>();
    getAllVersions(project, property, allVersion);
    for (IRepositoryViewObject repositoryObject : allVersion) {
      Property uptodateProperty = repositoryObject.getProperty();
      if (uptodateProperty.getVersion().equals(property.getVersion())) {
        return uptodateProperty;
      }
    }
    return null;
  }
Exemplo n.º 12
0
  /**
   * DOC smallet Comment method "createRoutine".
   *
   * @param url
   * @throws PersistenceException
   */
  private void createRoutine(URL url, IPath path, String label, List<LibraryInfo> neededJars)
      throws PersistenceException {
    if (url == null) {
      throw new IllegalArgumentException();
    }
    InputStream stream = null;
    try {
      Property property = PropertiesFactory.eINSTANCE.createProperty();
      property.setId(getNextId());
      property.setLabel(label);

      ByteArray byteArray = PropertiesFactory.eINSTANCE.createByteArray();
      stream = url.openStream();
      byte[] innerContent = new byte[stream.available()];
      stream.read(innerContent);
      stream.close();
      byteArray.setInnerContent(innerContent);

      // String basePath = System.getProperty("user.dir") + File.separator + "plugins";

      RoutineItem routineItem = PropertiesFactory.eINSTANCE.createRoutineItem();
      routineItem.setProperty(property);
      routineItem.setContent(byteArray);
      routineItem.setBuiltIn(true);
      if (neededJars != null) {
        for (LibraryInfo jar : neededJars) {
          IMPORTType type = ComponentFactory.eINSTANCE.createIMPORTType();
          type.setMESSAGE("");
          type.setNAME(label);
          type.setREQUIRED(true);
          type.setMODULE(jar.getLibName());
          type.setBundleID(jar.getBundleId());
          routineItem.getImports().add(type);
        }
      }

      if (!routineItem.getProperty().getLabel().equals(coreSerivce.getTemplateString())) {
        create(getRepositoryContext().getProject(), routineItem, path, true);
      }
    } catch (IOException ioe) {
      if (stream != null) {
        try {
          stream.close();
        } catch (IOException e) {
          throw new PersistenceException(ioe);
        }
      }
      throw new PersistenceException(ioe);
    }
  }
  /** 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
    }
  }
  /**
   * Added 20130115 yyin TDQ-3249, make the system indicator display international. but for the user
   * defined indicator, no need.
   */
  @Override
  public Property initProperty(ModelElement modelElement) {
    Property property = super.initProperty(modelElement);

    // if the indicator is the user defined indicator, no need to internationalize it.
    if (isUserDefinedIndicator((IndicatorDefinition) modelElement)) {
      return property;
    }
    // For system indicator, make its display name international.(means its display name is in the
    // messages file)
    // MOD sizhaoliu TDQ-7454 do not translate here, but during the initialization of
    // RepositoryViewObjects
    property.setDisplayName(modelElement.getName());
    return property;
  }
Exemplo n.º 15
0
 public String getLabel(boolean checkVersion) {
   if (label == null && property != null) {
     if (checkVersion) {
       IBrandingService brandingService =
           (IBrandingService)
               GlobalServiceRegister.getDefault().getService(IBrandingService.class);
       boolean allowVerchange = brandingService.getBrandingConfiguration().isAllowChengeVersion();
       if (allowVerchange && property.getItem().isNeedVersion()) {
         label = property.getLabel() + " " + property.getVersion(); // $NON-NLS-1$
         return label;
       }
     }
     label = property.getLabel();
   }
   return label;
 }
Exemplo n.º 16
0
  protected Item copyFromResource(Resource createResource, boolean changeLabelWithCopyPrefix)
      throws PersistenceException, BusinessException {
    Item newItem =
        (Item)
            EcoreUtil.getObjectByType(
                createResource.getContents(), PropertiesPackage.eINSTANCE.getItem());
    Property property = newItem.getProperty();
    property.setId(getNextId());
    property.setAuthor(getRepositoryContext().getUser());

    if (changeLabelWithCopyPrefix) {
      setPropNewName(property);
    }
    EcoreUtil.resolveAll(createResource);
    return newItem;
  }
Exemplo n.º 17
0
 /**
  * Method "setPropNewName". Try first the new name with "[PROPERTY_NAME]_Copy", then, if it
  * already exists, try again with "[PROPERTY_NAME]_CopyN" where N is number between 1 and
  * Integer.MAX.
  *
  * @param copiedProperty
  * @throws PersistenceException
  * @throws BusinessException
  */
 private void setPropNewName(Property copiedProperty)
     throws PersistenceException, BusinessException {
   String originalLabel = copiedProperty.getDisplayName();
   String copy = "_Copy"; // $NON-NLS-1$
   String initialTry = originalLabel + copy;
   copiedProperty.setLabel(initialTry);
   // changed by hqzhang for TDI-19965
   copiedProperty.setDisplayName(initialTry);
   if (isNameAvailable(getRepositoryContext().getProject(), copiedProperty.getItem(), null)) {
     return;
   } else {
     long index = 1;
     while (!isNameAvailable(
         getRepositoryContext().getProject(), copiedProperty.getItem(), null)) {
       if (index < 0) {
         throw new BusinessException(
             Messages.getString("AbstractEMFRepositoryFactory.cannotGenerateItem")); // $NON-NLS-1$
       }
       String nextTry = originalLabel + copy + (index++);
       copiedProperty.setLabel(nextTry);
       // changed by hqzhang for TDI-19965
       copiedProperty.setDisplayName(nextTry);
     }
   }
 }
Exemplo n.º 18
0
  private void createSQLPattern(URL url, String sqlPatternLabel, String categoryName)
      throws PersistenceException {
    if (url == null) {
      throw new IllegalArgumentException();
    }
    InputStream stream = null;
    try {
      Property property = PropertiesFactory.eINSTANCE.createProperty();
      property.setId(getNextId());

      property.setLabel(sqlPatternLabel);

      ByteArray byteArray = PropertiesFactory.eINSTANCE.createByteArray();
      stream = url.openStream();
      byte[] innerContent = new byte[stream.available()];
      stream.read(innerContent);
      stream.close();
      byteArray.setInnerContent(innerContent);

      SQLPatternItem sqlpatternItem = PropertiesFactory.eINSTANCE.createSQLPatternItem();
      sqlpatternItem.setProperty(property);
      sqlpatternItem.setEltName(categoryName);
      sqlpatternItem.setContent(byteArray);
      sqlpatternItem.setSystem(true);

      // set the item's relative path in the repository view
      IPath categoryPath = new Path(categoryName);
      IPath systemPath = categoryPath.append(RepositoryConstants.SYSTEM_DIRECTORY);

      create(getRepositoryContext().getProject(), sqlpatternItem, systemPath, true);

    } catch (IOException ioe) {
      if (stream != null) {
        try {
          stream.close();
        } catch (IOException e) {
          throw new PersistenceException(ioe);
        }
      }
      throw new PersistenceException(ioe);
    }
  }
Exemplo n.º 19
0
  public String getItemName() {
    if (itemName == null) {
      IBrandingService brandingService =
          (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
      boolean allowVerchange = brandingService.getBrandingConfiguration().isAllowChengeVersion();
      ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(property.getItem());

      StringBuffer sb = new StringBuffer();
      if (itemType != null) {
        sb.append(itemType.toString());
        sb.append(' ');
      }
      sb.append(property.getLabel());

      if (allowVerchange) {
        sb.append(' ');
        sb.append(property.getVersion());
      }
      itemName = sb.toString();
    }
    return itemName;
  }
  /** yzhang Comment method "updateProblems". */
  private void updateProblems(List<IRepositoryViewObject> routineObjectList, String filePath) {

    IRunProcessService runProcessService = CorePlugin.getDefault().getRunProcessService();
    try {
      ITalendProcessJavaProject talendProcessJavaProject =
          runProcessService.getTalendProcessJavaProject();
      if (talendProcessJavaProject == null) {
        return;
      }
      IProject javaProject = talendProcessJavaProject.getProject();
      IFile file = javaProject.getFile(filePath);
      String fileName = file.getName();

      for (IRepositoryViewObject repositoryObject : routineObjectList) {
        Property property = repositoryObject.getProperty();
        ITalendSynchronizer synchronizer =
            CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
        Item item = property.getItem();
        if (GlobalServiceRegister.getDefault()
            .isServiceRegistered(ICamelDesignerCoreService.class)) {
          ICamelDesignerCoreService service =
              (ICamelDesignerCoreService)
                  GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
          if (service.isInstanceofCamel(item)) {
            synchronizer =
                CorePlugin.getDefault().getCodeGeneratorService().createCamelBeanSynchronizer();
          }
        }
        IFile currentFile = synchronizer.getFile(item);
        if (currentFile != null && fileName.equals(currentFile.getName()) && currentFile.exists()) {
          Problems.addRoutineFile(currentFile, property);
          break;
        }
      }
    } catch (SystemException e) {
      ExceptionHandler.process(e);
    }
  }
Exemplo n.º 21
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));
    }
  }
Exemplo n.º 22
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;
    }
  }
  /** 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.º 24
0
  public SalesforceSchemaWizard(
      IWorkbench workbench,
      boolean creation,
      RepositoryNode node,
      String[] existingNames,
      boolean isSinglePageOnly) {
    super(workbench, creation);
    this.existingNames = existingNames;
    this.isSinglePageOnly = isSinglePageOnly;
    setNeedsProgressMonitor(true);

    // TODO: should to changed icon.
    setDefaultPageImageDescriptor(ImageProvider.getImageDesc(ECoreImage.DEFAULT_WIZ));
    switch (node.getType()) {
      case SIMPLE_FOLDER:
      case REPOSITORY_ELEMENT:
        pathToSave = RepositoryNodeUtilities.getPath(node);
        break;
      case SYSTEM_FOLDER:
        pathToSave = new Path(""); // $NON-NLS-1$
        break;
    }

    switch (node.getType()) {
      case SIMPLE_FOLDER:
      case SYSTEM_FOLDER:
        connection = ConnectionFactory.eINSTANCE.createSalesforceSchemaConnection();
        connection.setName(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA.getKey());
        MetadataTable metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        metadataTable.setId(factory.getNextId());
        RecordFile record =
            (RecordFile)
                ConnectionHelper.getPackage(connection.getName(), connection, RecordFile.class);
        if (record != null) { // hywang
          PackageHelper.addMetadataTable(metadataTable, record);
        } else {
          RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
          newrecord.setName(connection.getName());
          ConnectionHelper.addPackage(newrecord, connection);
          PackageHelper.addMetadataTable(metadataTable, newrecord);
        }
        connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
        connectionProperty.setAuthor(
            ((RepositoryContext)
                    CoreRuntimePlugin.getInstance()
                        .getContext()
                        .getProperty(Context.REPOSITORY_CONTEXT_KEY))
                .getUser());
        connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
        connectionProperty.setStatusCode(""); // $NON-NLS-1$

        connectionItem = PropertiesFactory.eINSTANCE.createSalesforceSchemaConnectionItem();
        connectionItem.setProperty(connectionProperty);
        connectionItem.setConnection(connection);
        initProxySettings(connection);
        break;

      case REPOSITORY_ELEMENT:
        connection =
            (SalesforceSchemaConnection)
                ((ConnectionItem) node.getObject().getProperty().getItem()).getConnection();
        connectionProperty = node.getObject().getProperty();
        connectionItem = (ConnectionItem) node.getObject().getProperty().getItem();
        // set the repositoryObject, lock and set isRepositoryObjectEditable
        setRepositoryObject(node.getObject());
        isRepositoryObjectEditable();
        initLockStrategy();
        break;
    }
    if (!creation) {
      this.originaleObjectLabel = this.connectionItem.getProperty().getLabel();
      this.originalVersion = this.connectionItem.getProperty().getVersion();
      this.originalDescription = this.connectionItem.getProperty().getDescription();
      this.originalPurpose = this.connectionItem.getProperty().getPurpose();
      this.originalStatus = this.connectionItem.getProperty().getStatusCode();
    }
    initConnection();
  }
Exemplo n.º 25
0
 public Item getItem() {
   if (property != null) {
     return property.getItem();
   }
   return null;
 }
Exemplo n.º 26
0
 public ERepositoryObjectType getRepositoryType() {
   if (repositoryType == null) {
     repositoryType = ERepositoryObjectType.getItemType(property.getItem());
   }
   return repositoryType;
 }