示例#1
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);
     }
   }
 }
示例#2
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);
   }
 }
 /**
  * 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(' ', '.')));
   }
 }
  /**
   * 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;
  }