Search in sources :

Example 1 with ImportBasicHandler

use of org.talend.repository.items.importexport.handlers.imports.ImportBasicHandler in project tdi-studio-se by Talend.

the class ResetItemLabelMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    IProxyRepositoryFactory repositoryFactory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    ImportBasicHandler handler = new ImportBasicHandler();
    Property property = item.getProperty();
    if (property == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    String label = property.getLabel();
    if (label == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        boolean isAvailable = WorkspaceUtils.checkNameIsOK(label);
        if (!isAvailable) {
            property.setLabel(handler.getPropertyLabel(StringUtils.trimToNull(label)));
            property.setDisplayName(StringUtils.trimToNull(label));
            repositoryFactory.save(item, true);
        }
    } catch (PersistenceException e) {
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.SUCCESS_WITH_ALERT;
}
Also used : PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ImportBasicHandler(org.talend.repository.items.importexport.handlers.imports.ImportBasicHandler)

Aggregations

PersistenceException (org.talend.commons.exception.PersistenceException)1 Property (org.talend.core.model.properties.Property)1 ImportBasicHandler (org.talend.repository.items.importexport.handlers.imports.ImportBasicHandler)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1