use of org.talend.repository.model.IProxyRepositoryFactory 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;
}
use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.
the class ContextRepositoryReviewDialog method okPressed.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.dialog.RepositoryReviewDialog#okPressed()
*/
@SuppressWarnings("unchecked")
@Override
protected void okPressed() {
if (params == null || params.isEmpty()) {
super.okPressed();
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (createNewButton.getSelection()) {
if (nameInvalid(contextNameText)) {
//$NON-NLS-1$
MessageDialog.openError(getShell(), "Context", msg);
return;
} else {
item = PropertiesFactory.eINSTANCE.createContextItem();
if (item == null) {
return;
}
Property createProperty = PropertiesFactory.eINSTANCE.createProperty();
createProperty.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
createProperty.setVersion(VersionUtils.DEFAULT_VERSION);
//$NON-NLS-1$
createProperty.setStatusCode("");
try {
String nextId = factory.getNextId();
createProperty.setId(nextId);
item.setProperty(createProperty);
for (IContext context : contextManager.getListContext()) {
ContextType contextType = TalendFileFactory.eINSTANCE.createContextType();
contextType.setName(context.getName());
item.getContext().add(contextType);
}
item.setDefaultContext(contextManager.getDefaultContext().getName());
item.getProperty().setLabel(contextNameText.getText().trim());
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory repositoryFactory = service.getProxyRepositoryFactory();
try {
boolean nameAvaliabe = repositoryFactory.isNameAvailable(createProperty.getItem(), contextNameText.getText());
if (!nameAvaliabe) {
MessageDialog.openError(getShell(), "Context", //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"PropertiesWizardPage.ItemExistsError"));
return;
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
super.okPressed();
}
//$NON-NLS-1$
factory.create(item, new Path(""));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
super.okPressed();
}
}
} else {
IStructuredSelection selection = (IStructuredSelection) getRepositoryTreeViewer().getSelection();
RepositoryNode context = (RepositoryNode) selection.getFirstElement();
try {
// get the item from file
IRepositoryViewObject contextObj = factory.getLastVersion(context.getObject().getProperty().getId());
item = (ContextItem) contextObj.getProperty().getItem();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
super.okPressed();
}
}
super.okPressed();
}
use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.
the class EditSqlpatternAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
protected void doRun() {
RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
Property property = node.getObject().getProperty();
Property updatedProperty = null;
try {
updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(property.getItem())), property.getId()).getProperty();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// update the property of the node repository object
// node.getObject().setProperty(updatedProperty);
SQLPatternItem sqlPatternItem = (SQLPatternItem) node.getObject().getProperty().getItem();
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean readonly = factory.getStatus(sqlPatternItem) == ERepositoryStatus.LOCK_BY_OTHER;
try {
openSQLPatternEditor(sqlPatternItem, readonly);
// TDI-21143 : Studio repository view : remove all refresh call to repo view
// IRepositoryView view = getViewPart();
// if (view != null) {
// view.refresh(node);
// }
} catch (PartInitException e) {
MessageBoxExceptionHandler.process(e);
} catch (SystemException e) {
MessageBoxExceptionHandler.process(e);
}
}
use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.
the class EditSqlpatternAction method init.
/*
* (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;
}
RepositoryNode node = (RepositoryNode) selection.getFirstElement();
if (canWork) {
if (node.getObjectType() != ERepositoryObjectType.SQLPATTERNS || !ProjectManager.getInstance().isInCurrentMainProject(node) || !isLastVersion(node)) {
canWork = false;
} else {
Item item = node.getObject().getProperty().getItem();
if (item instanceof SQLPatternItem) {
canWork = !((SQLPatternItem) item).isSystem();
}
}
}
if (canWork) {
canWork = (factory.getStatus(node.getObject()) != ERepositoryStatus.DELETED);
}
setEnabled(canWork);
}
use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.
the class PaletteSettingsDialog method okPressed.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@Override
protected void okPressed() {
super.okPressed();
IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
try {
prf.saveProject(project);
// ComponentUtilities.updatePalette(false);
ShowStandardAction.getInstance().doRun();
} catch (Exception ex) {
ExceptionHandler.process(ex);
}
}
Aggregations